Skip to contentSkip to conversation

Document change in format of raw diff output format

PATCH In review Greg Hurrell 3 participants 7 messages Nov 22, 2018 – Nov 26, 2018 Documentation

lore
Share & tools
lore
#0 lore raw

I was troubleshooting some breakage in some code that consumes the output of git log --raw and looking on two machines with different versions of Git just now I discovered the output format has changed somewhere between v2.14.5:

:000000 100644 000000000... 9773b7718... A content/snippets/1157.md

and v2.19.0:

:000000 100644 000000000 9773b7718 A content/snippets/1157.md

A quick search turns up some patches related to the GIT_PRINT_SHA1_ELLIPSIS env variable, which can be used to force the old output format, and which landed in v2.16.0, I think.

Does it sound right that we should update the documentation in diff-format.txt to show what the new output format is? The examples all show the old output format, which isn't produced by default any more.

Something like the following? If the answer is yes, I can turn it into a real patch.

Cheers,
Greg

Documentation/diff-format.txt +8 -8
index 706916c94c..33776459d0 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd123456 012345678 M file0
+copy-edit      :100644 100644 abcd12345 123456789 C68 file1 file2
+rename-edit    :100644 100644 abcd12345 123456789 R86 file1 file3
+create         :000000 100644 000000000 123456789 A file4
+delete         :100644 000000 123456789 000000000 D file5
+unmerged       :000000 000000 000000000 000000000 U file6
 ------------------------------------------------
 
 That is, from the left to the right:
@@ -75,7 +75,7 @@ and it is out of sync with the index.
 Example:
 
 ------------------------------------------------
-:100644 100644 5be4a4...... 000000...... M file.c
+:100644 100644 5be4a4abc 000000000 M file.c
 ------------------------------------------------
 
 Without the `-z` option, pathnames with "unusual" characters are
@@ -100,7 +100,7 @@ from the format described above in the following way:
 Example:
 
 ------------------------------------------------
-::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM     describe.c
+::100644 100644 100644 fabadb827 cc95eb0f2 4866510ea MM        describe.c
 ------------------------------------------------
 
 Note that 'combined diff' lists only files which were modified from
#1 lore raw
Quoted 7 lines · Greg Hurrell

I was troubleshooting some breakage in some code that consumes the output of git log --raw and looking on two machines with different versions of Git just now I discovered the output format has changed somewhere between v2.14.5:

:000000 100644 000000000... 9773b7718... A content/snippets/1157.md

Quoted 7 lines

and v2.19.0:

:000000 100644 000000000 9773b7718 A content/snippets/1157.md

A quick search turns up some patches related to the GIT_PRINT_SHA1_ELLIPSIS env variable, which can be used to force the old output format, and which landed in v2.16.0, I think.

Yes. The actual commit that flipped the default is 7cb6ac1e4b (diff:
diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value, 2017-12-03). There's more discussion of the possibility of breakage in this subthread:

https://public-inbox.org/git/83D263E58ABD46188756D41FE311E469@PhilipOakley/

Quoted 4 lines

Does it sound right that we should update the documentation in diff-format.txt to show what the new output format is? The examples all show the old output format, which isn't produced by default any more.

Yes, we should definitely update the documentation to show the modern format. I think that was just an oversight in the original series.

Quoted 11 lines
Documentation/diff-format.txt +0 -3
index 706916c94c..33776459d0 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3

Documentation/diff-format.txt line per changed file. · line 35

Quoted 10 lines
Documentation/diff-format.txt +6 -3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd123456 012345678 M file0
+copy-edit      :100644 100644 abcd12345 123456789 C68 file1 file2
+rename-edit    :100644 100644 abcd12345 123456789 R86 file1 file3
+create         :000000 100644 000000000 123456789 A file4
+delete         :100644 000000 123456789 000000000 D file5
+unmerged       :000000 000000 000000000 000000000 U file6
 ------------------------------------------------

Yeah, this looks like an improvement.

I think in general that we'd continue to show 7 characters now, just without the extra dots (though it's auto-scaled based on the number of objects in the repo these days, so it's not even really a constant).

Documentation/diff-format.txt and it is out of sync with the index. · line 79

Quoted 8 lines
Documentation/diff-format.txt +1 -1
 That is, from the left to the right:
@@ -75,7 +75,7 @@ and it is out of sync with the index.
 Example:
 
 ------------------------------------------------
-:100644 100644 5be4a4...... 000000...... M file.c
+:100644 100644 5be4a4abc 000000000 M file.c
 ------------------------------------------------

I'm not even sure what this original was trying to show. I don't think we ever produced that any dots. :)

Thanks for noticing.

-Peff

PS As you noticed, "git log" we don't promise that git-log output will
never change between versions. For machine-consumption you probably want to use plumbing like "git rev-list | git diff-tree --stdin", which produces unabbreviated hashes.

#2 lore raw
Quoted 26 lines · Jeff King
Quoted 11 lines · Greg Hurrell
Documentation/diff-format.txt +0 -3
index 706916c94c..33776459d0 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3

Documentation/diff-format.txt line per changed file. · line 35

Quoted 10 lines
Documentation/diff-format.txt +6 -3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd123456 012345678 M file0
+copy-edit      :100644 100644 abcd12345 123456789 C68 file1 file2
+rename-edit    :100644 100644 abcd12345 123456789 R86 file1 file3
+create         :000000 100644 000000000 123456789 A file4
+delete         :100644 000000 123456789 000000000 D file5
+unmerged       :000000 000000 000000000 000000000 U file6
 ------------------------------------------------

Yeah, this looks like an improvement.

Quoted 3 lines

I think in general that we'd continue to show 7 characters now, just without the extra dots (though it's auto-scaled based on the number of objects in the repo these days, so it's not even really a constant).

That's funny. I looked at the output on (what I thought was) a small repo and it was showing me 9-character abbreviated hashes. I guess I just got lucky. Tested on a basically empty repo and 7 does look to be the default.

Quoted 4 lines

PS As you noticed, "git log" we don't promise that git-log output will
never change between versions. For machine-consumption you probably want to use plumbing like "git rev-list | git diff-tree --stdin", which produces unabbreviated hashes.

Thanks for the tip. My mistake was thinking that the --raw made the git log output somehow more plumbing-ish, but I've gone ahead and switched to using git-rev-list plus git-diff-tree instead.

Anyway, patch follows.

#3 lore raw

PATCH 1/1 doc: update diff-format.txt for removed ellipses

Commit 7cb6ac1e4b made the diff format omit ellipses by default, but there is still this place in the documentation where we show examples of output with ellipses.

The GIT_PRINT_SHA1_ELLIPSIS environment variable can be used, for now, to bring back the old output format, but that is already documented in git.txt, so I am not mentioning it here.

---
 Documentation/diff-format.txt | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/diff-format.txt +8 -8
index 706916c94c..cdcc17f0ad 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd1234 0123456 M file0
+copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
+rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
+create         :000000 100644 0000000 1234567 A file4
+delete         :100644 000000 1234567 0000000 D file5
+unmerged       :000000 000000 0000000 0000000 U file6
 ------------------------------------------------
 
 That is, from the left to the right:
@@ -75,7 +75,7 @@ and it is out of sync with the index.
 Example:
 
 ------------------------------------------------
-:100644 100644 5be4a4...... 000000...... M file.c
+:100644 100644 5be4a4a 0000000 M file.c
 ------------------------------------------------
 
 Without the `-z` option, pathnames with "unusual" characters are
@@ -100,7 +100,7 @@ from the format described above in the following way:
 Example:
 
 ------------------------------------------------
-::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM	describe.c
+::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	describe.c
 ------------------------------------------------
 
 Note that 'combined diff' lists only files which were modified from
Signature · 1 line
2.19.0
#4 lore raw

Re: [PATCH] doc: update diff-format.txt for removed ellipses

Thanks for a patch.

Quoted 3 lines · Greg Hurrell

Commit 7cb6ac1e4b made the diff format omit ellipses by default, but there is still this place in the documentation where we show examples of output with ellipses.

We prefer to cite an existing commit with its title and date these days, not just with its object name.

Since 7cb6ac1e ("diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value", 2017-12-03), the "--raw" format of diff does not add ellipsis in an attempt to align the output, but...

or something like that. Note that saying this is about the raw format is quite essential thing to tell the readers to explain this hange.

Quoted 3 lines

The GIT_PRINT_SHA1_ELLIPSIS environment variable can be used, for now, to bring back the old output format, but that is already documented in git.txt, so I am not mentioning it here.

Yeah, I do not think it makes sense to use the workaround that is planned for removal, which will later make us revise the example in the documentation again, to end up with the text that you have right now. I do not think this three-line paragraph needs to be in the log message, either, though. Perhaps below the three-dash line.

Also please sign-off your patch here (see
Documentation/SubmittingPatches).

Quoted 1 line

---

Thanks.

Quoted 44 lines
 Documentation/diff-format.txt | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/diff-format.txt +8 -8
index 706916c94c..cdcc17f0ad 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd1234 0123456 M file0
+copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
+rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
+create         :000000 100644 0000000 1234567 A file4
+delete         :100644 000000 1234567 0000000 D file5
+unmerged       :000000 000000 0000000 0000000 U file6
 ------------------------------------------------
 
 That is, from the left to the right:
@@ -75,7 +75,7 @@ and it is out of sync with the index.
 Example:
 
 ------------------------------------------------
-:100644 100644 5be4a4...... 000000...... M file.c
+:100644 100644 5be4a4a 0000000 M file.c
 ------------------------------------------------
 
 Without the `-z` option, pathnames with "unusual" characters are
@@ -100,7 +100,7 @@ from the format described above in the following way:
 Example:
 
 ------------------------------------------------
-::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM	describe.c
+::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	describe.c
 ------------------------------------------------
 
 Note that 'combined diff' lists only files which were modified from
#5 lore raw

PATCH 1/1 doc: update diff-format.txt for removed ellipses in --raw

Since 7cb6ac1e4b ("diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value", 2017-12-03), the "--raw" format of diff does not add ellipses in an attempt to align the output, but the documentation was not updated to reflect this.

---

The GIT_PRINT_SHA1_ELLIPSIS environment variable can be used, for now, to bring back the old output format, but that is already documented in git.txt, so I am not mentioning it here.

 Documentation/diff-format.txt | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/diff-format.txt +8 -8
index 706916c94c..cdcc17f0ad 100644
@@ -26,12 +26,12 @@ line per changed file.
 An output line is formatted this way:
 
 ------------------------------------------------
-in-place edit  :100644 100644 bcd1234... 0123456... M file0
-copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
-rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
-create         :000000 100644 0000000... 1234567... A file4
-delete         :100644 000000 1234567... 0000000... D file5
-unmerged       :000000 000000 0000000... 0000000... U file6
+in-place edit  :100644 100644 bcd1234 0123456 M file0
+copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
+rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
+create         :000000 100644 0000000 1234567 A file4
+delete         :100644 000000 1234567 0000000 D file5
+unmerged       :000000 000000 0000000 0000000 U file6
 ------------------------------------------------
 
 That is, from the left to the right:
@@ -75,7 +75,7 @@ and it is out of sync with the index.
 Example:
 
 ------------------------------------------------
-:100644 100644 5be4a4...... 000000...... M file.c
+:100644 100644 5be4a4a 0000000 M file.c
 ------------------------------------------------
 
 Without the `-z` option, pathnames with "unusual" characters are
@@ -100,7 +100,7 @@ from the format described above in the following way:
 Example:
 
 ------------------------------------------------
-::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM	describe.c
+::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	describe.c
 ------------------------------------------------
 
 Note that 'combined diff' lists only files which were modified from
Signature · 1 line
2.19.0
#6 lore raw

Re: [PATCH] doc: update diff-format.txt for removed ellipses in --raw

Quoted 11 lines · Greg Hurrell

Since 7cb6ac1e4b ("diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value", 2017-12-03), the "--raw" format of diff does not add ellipses in an attempt to align the output, but the documentation was not updated to reflect this.

---

The GIT_PRINT_SHA1_ELLIPSIS environment variable can be used, for now, to bring back the old output format, but that is already documented in git.txt, so I am not mentioning it here.

Thanks. Will queue.