patch, 3 partsSome more "Raw output format" doc improvements
4 messages between May 15, 2026 and May 15, 2026, from Philippe Blain via GitGitGadget.
Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.
Philippe Blain via GitGitGadgetMay 15, 2026, 15:48 UTC on loreHere are some small improvements to the "Raw output format" documentation that I noticed while working on another topic.
Philippe Blain (3):
diff-format.adoc: remove mention of diff-tree specific output
diff-format.adoc: 'git diff-files' prints two lines for unmerged files
diff-format.adoc: mode and hash are 0* for unmerged paths from index
only Documentation/diff-format.adoc | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
base-commit: 59ff4886a579f4bc91e976fe18590b9ae02c7a08
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2304%2Fphil-blain%2Fdiff-raw-format-doc-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2304/phil-blain/diff-raw-format-doc-v1
Pull-Request: https://github.com/git/git/pull/2304
--
gitgitgadget
[PATCH 1/3] diff-format.adoc: remove mention of diff-tree specific output
From: Philippe Blain <levraiphilippeblain@gmail.com>
In the "Raw output format" section, we start by mentioning that 'git diff-tree' prints the hashes of what is being compared. This is only true in --stdin mode, and is already mentioned in the description of '--stdin' in git-diff-tree.adoc. Remove this sentence such that we only focus on the common output between diff-tree, diff-index, diff-files and diff --raw.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
Documentation/diff-format.adoc | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Show changes to Documentation/diff-format.adoc +1 −3
diff --git a/Documentation/diff-format.adoc b/Documentation/diff-format.adoc
index 9f7e988241..7f18c64f1e 100644
--- a/Documentation/diff-format.adoc
+++ b/Documentation/diff-format.adoc
@@ -19,9 +19,7 @@ compared differs:
`git-diff-files [<pattern>...]`::
compares the index and the files on the filesystem.
-The `git-diff-tree` command begins its output by printing the hash of
-what is being compared. After that, all the commands print one output
-line per changed file.
+All the commands print one output line per changed file.
An output line is formatted this way:
--
gitgitgadget
[PATCH 2/3] diff-format.adoc: 'git diff-files' prints two lines for unmerged files
From: Philippe Blain <levraiphilippeblain@gmail.com>
Since 10637b84d9 (diff-files: -1/-2/-3 to diff against unmerged stage., 2005-11-29), for unmerged entries 'git diff-files' print both an "unmerged" line ('U'), as well as an "in-place edit" line ('M') comparing stage 2 (by default) with the working tree. The "Raw output format" documentation however mentions that all commands print a single line per changed file. Adjust diff-format.adoc to also mention this special case, for completeness.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
Documentation/diff-format.adoc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Show changes to Documentation/diff-format.adoc +3 −1
diff --git a/Documentation/diff-format.adoc b/Documentation/diff-format.adoc
index 7f18c64f1e..43d91ef868 100644
--- a/Documentation/diff-format.adoc
+++ b/Documentation/diff-format.adoc
@@ -19,7 +19,9 @@ compared differs:
`git-diff-files [<pattern>...]`::
compares the index and the files on the filesystem.
-All the commands print one output line per changed file.
+All the commands print one output line per changed file,
+except `git diff-files` in the case of an unmerged file, which prints
+both an "unmerged" and an "in-place edit" line.
An output line is formatted this way:
--
gitgitgadget
[PATCH 3/3] diff-format.adoc: mode and hash are 0* for unmerged paths from index only
From: Philippe Blain <levraiphilippeblain@gmail.com>
In the "Raw output format" section, we mention that the 'mode' and 'sha1' for "src" and "dst" are 0* if "(creation|deletion) or unmerged". For unmerged entries, 'mode' and 'sha1' are in fact 0* only when we are looking at the index, i.e. on the left side for 'git diff-files' and on the right side for 'git diff-index --cached'. Be more precise by mentioning this, and while at it uniformize the wording of the "work tree out of sync with the index" case.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
Documentation/diff-format.adoc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Show changes to Documentation/diff-format.adoc +4 −4
diff --git a/Documentation/diff-format.adoc b/Documentation/diff-format.adoc
index 43d91ef868..ef5df140fe 100644
--- a/Documentation/diff-format.adoc
+++ b/Documentation/diff-format.adoc
@@ -37,13 +37,13 @@ unmerged :000000 000000 0000000 0000000 U file6
That is, from the left to the right:
. a colon.
-. mode for "src"; 000000 if creation or unmerged.
+. mode for "src"; 000000 if creation, or if "src" is from the index and is unmerged.
. a space.
-. mode for "dst"; 000000 if deletion or unmerged.
+. mode for "dst"; 000000 if deletion, or if "dst" is from the index and is unmerged.
. a space.
-. sha1 for "src"; 0\{40\} if creation or unmerged.
+. sha1 for "src"; 0\{40\} if creation, or if "src" is from the index and is unmerged.
. a space.
-. sha1 for "dst"; 0\{40\} if deletion, unmerged or "work tree out of sync with the index".
+. sha1 for "dst"; 0\{40\} if deletion, if "dst" is from the index and is unmerged, or if "dst" is from the work tree and is out of sync with the index.
. a space.
. status, followed by optional "score" number.
. a tab or a NUL when `-z` option is used.
--
gitgitgadget