git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 3/3] Documentation: usage for diff combined commits

From
Chris Torek via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 12, 2020, 16:20 UTC
Message-ID
<d7bc9aca44bdff18ec2cee4f45d34c0965dc2002.1591978801.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.804.v4.git.git.1591978801.gitgitgadget@gmail.com>
From: Chris Torek <chris.torek@gmail.com>

Document the usage for producing combined commits with "git diff". This includes updating the synopsis section.

While here, add the three-dot notation to the synopsis.

Make "git diff -h" print the same usage summary as the manual page synopsis, minus the "A..B" form, which is now discouraged.

Signed-off-by: Chris Torek <chris.torek@gmail.com>
---
 Documentation/git-diff.txt | 20 ++++++++++++++++----
 builtin/diff.c             |  8 +++++++-
 2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 37781cf1755..1018110ddc2 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -11,15 +11,17 @@ SYNOPSIS
 [verse]
 'git diff' [<options>] [<commit>] [--] [<path>...]
 'git diff' [<options>] --cached [<commit>] [--] [<path>...]
-'git diff' [<options>] <commit> <commit> [--] [<path>...]
+'git diff' [<options>] <commit> [<commit>...] <commit> [--] [<path>...]
+'git diff' [<options>] <commit>...<commit> [--] [<path>...]
 'git diff' [<options>] <blob> <blob>
 'git diff' [<options>] --no-index [--] <path> <path>
 
 DESCRIPTION
 -----------
 Show changes between the working tree and the index or a tree, changes
-between the index and a tree, changes between two trees, changes between
-two blob objects, or changes between two files on disk.
+between the index and a tree, changes between two trees, changes resulting
+from a merge, changes between two blob objects, or changes between two
+files on disk.
 
 'git diff' [<options>] [--] [<path>...]::
 
@@ -67,6 +69,15 @@ two blob objects, or changes between two files on disk.
 	one side is omitted, it will have the same effect as
 	using HEAD instead.
 
+'git diff' [<options>] <commit> [<commit>...] <commit> [--] [<path>...]::
+
+	This form is to view the results of a merge commit.  The first
+	listed <commit> must be the merge itself; the remaining two or
+	more commits should be its parents.  A convenient way to produce
+	the desired set of revisions is to use the {caret}@ suffix.
+	For instance, if `master` names a merge commit, `git diff master
+	master^@` gives the same combined diff as `git show master`.
+
 'git diff' [<options>] <commit>\...<commit> [--] [<path>...]::
 
 	This form is to view the changes on the branch containing
@@ -196,7 +207,8 @@ linkgit:git-difftool[1],
 linkgit:git-log[1],
 linkgit:gitdiffcore[7],
 linkgit:git-format-patch[1],
-linkgit:git-apply[1]
+linkgit:git-apply[1],
+linkgit:git-show[1]
 
 GIT
 ---
diff --git a/builtin/diff.c b/builtin/diff.c
index 0f48b0d3e71..b3d17340ee3 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -24,7 +24,13 @@
 #define DIFF_NO_INDEX_IMPLICIT 2
 
 static const char builtin_diff_usage[] =
-"git diff [<options>] [<commit> [<commit>]] [--] [<path>...]";
+"git diff [<options>] [<commit>] [--] [<path>...]\n"
+"   or: git diff [<options>] --cached [<commit>] [--] [<path>...]\n"
+"   or: git diff [<options>] <commit> [<commit>...] <commit> [--] [<path>...]\n"
+"   or: git diff [<options>] <commit>...<commit>] [--] [<path>...]\n"
+"   or: git diff [<options>] <blob> <blob>]\n"
+"   or: git diff [<options>] --no-index [--] <path> <path>]\n"
+COMMON_DIFF_OPTIONS_HELP;
 
 static const char *blob_path(struct object_array_entry *entry)
 {
-- 
gitgitgadget
Previous: Chris Torek
Message 26 of 26 in “improve git-diff documentation and A...B handling”
  1. 0/3 improve git-diff documentation and A...B handlingChris Torek via GitGitGadget, Jun 9, 2020
  2. 2/3 git diff: improve A...B merge-base handlingChris Torek via GitGitGadget, Jun 9, 2020
  3. Junio C HamanoJun 9, 2020
  4. Philip OakleyJun 12, 2020
  5. Junio C HamanoJun 12, 2020
  6. 1/3 t/t3430: avoid undocumented git diff behaviorChris Torek via GitGitGadget, Jun 9, 2020
  7. Junio C HamanoJun 9, 2020
  8. 3/3 Documentation: tweak git diff help slightlyChris Torek via GitGitGadget, Jun 9, 2020
  9. Junio C HamanoJun 9, 2020
  10. 0/3 improve git-diff documentation and A...B handlingChris Torek via GitGitGadget, Jun 9, 2020
  11. 1/3 t/t3430: avoid undefined git diff behaviorChris Torek via GitGitGadget, Jun 9, 2020
  12. 2/3 git diff: improve A...B merge-base handlingChris Torek via GitGitGadget, Jun 9, 2020
  13. Junio C HamanoJun 9, 2020
  14. 3/3 Documentation: tweak git diff help slightlyChris Torek via GitGitGadget, Jun 9, 2020
  15. Junio C HamanoJun 9, 2020
  16. 0/3 improve git-diff documentation and A...B handlingChris Torek via GitGitGadget, Jun 11, 2020
  17. 1/3 t/t3430: avoid undefined git diff behaviorChris Torek via GitGitGadget, Jun 11, 2020
  18. 2/3 git diff: improve range handlingChris Torek via GitGitGadget, Jun 11, 2020
  19. Chris TorekJun 11, 2020
  20. 3/3 Documentation: usage for diff combined commitsChris Torek via GitGitGadget, Jun 11, 2020
  21. 0/3 improve git-diff documentation and A...B handlingChris Torek via GitGitGadget, Jun 12, 2020
  22. 1/3 t/t3430: avoid undefined git diff behaviorChris Torek via GitGitGadget, Jun 12, 2020
  23. 2/3 git diff: improve range handlingChris Torek via GitGitGadget, Jun 12, 2020
  24. Junio C HamanoJun 12, 2020
  25. Chris TorekJun 12, 2020
  26. 3/3 Documentation: usage for diff combined commitsChris Torek via GitGitGadget, Jun 12, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.