about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2023-01-02 17:35:09 -0600
committerGitHub <noreply@github.com>2023-01-02 15:35:09 -0800
commitbc7f527e6dc441f1d6a97691a96c356991d9a028 (patch)
tree4d9b11c16451407a07135934de4e0ee5b3af8804 /src/doc/rustc-dev-guide
parentee2c4f3e2779ff91177acef17fc6ad31463fe230 (diff)
downloadrust-bc7f527e6dc441f1d6a97691a96c356991d9a028.tar.gz
rust-bc7f527e6dc441f1d6a97691a96c356991d9a028.zip
Add a section for how to review code more easily (#1538)
- How to hide whitespace
- Fetching PRs without having to add a new remote or copy-paste the URL of the author's fork
- How to review large blocks that have moved
- Suggest `git range-diff`. This section is still mostly incomplete; fixing an exact command that will work seems kinda tricky and I don't currently have time for it.
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/git.md38
-rw-r--r--src/doc/rustc-dev-guide/src/img/github-cli.pngbin0 -> 26790 bytes
-rw-r--r--src/doc/rustc-dev-guide/src/img/github-whitespace-changes.pngbin0 -> 29217 bytes
3 files changed, 38 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/git.md b/src/doc/rustc-dev-guide/src/git.md
index dfcf49656ff..6fd78011c0b 100644
--- a/src/doc/rustc-dev-guide/src/git.md
+++ b/src/doc/rustc-dev-guide/src/git.md
@@ -468,6 +468,44 @@ tradeoff. The main advantage is the generally linear commit history. This
 greatly simplifies bisecting and makes the history and commit log much easier
 to follow and understand.
 
+## Tips for reviewing
+
+**NOTE**: This section is for *reviewing* PRs, not authoring them.
+
+### Hiding whitespace
+
+Github has a button for disabling whitespace changes that may be useful.
+You can also use `git diff -w origin/master` to view changes locally.
+
+![hide whitespace](./img/github-whitespace-changes.png)
+
+### Fetching PRs
+
+To checkout PRs locally, you can use `git fetch upstream pull/NNNNN/head && git checkout
+FETCH_HEAD`.
+
+You can also use github's cli tool. Github shows a button on PRs where you can copy-paste the
+command to check it out locally. See <https://cli.github.com/> for more info.
+
+![`gh` suggestion](./img/github-cli.png)
+
+### Moving large sections of code
+
+Git and Github's default diff view for large moves *within* a file is quite poor; it will show each
+line as deleted and each line as added, forcing you to compare each line yourself. Git has an option
+to show moved lines in a different color:
+
+```
+git log -p --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change
+```
+
+See [the docs for `--color-moved`](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---color-movedltmodegt) for more info.
+
+### range-diff
+
+See [the relevant section for PR authors](#git-range-diff). This can be useful for comparing code
+that was force-pushed to make sure there are no unexpected changes.
+
 ## Git submodules
 
 **NOTE**: submodules are a nice thing to know about, but it *isn't* an absolute
diff --git a/src/doc/rustc-dev-guide/src/img/github-cli.png b/src/doc/rustc-dev-guide/src/img/github-cli.png
new file mode 100644
index 00000000000..c3b0e7707eb
--- /dev/null
+++ b/src/doc/rustc-dev-guide/src/img/github-cli.png
Binary files differdiff --git a/src/doc/rustc-dev-guide/src/img/github-whitespace-changes.png b/src/doc/rustc-dev-guide/src/img/github-whitespace-changes.png
new file mode 100644
index 00000000000..9a19a10aace
--- /dev/null
+++ b/src/doc/rustc-dev-guide/src/img/github-whitespace-changes.png
Binary files differ