Why does git-patch-id(1) sometimes print two lines, one of which has commit = 0000000000000000000000000000000000000000

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

Why does git-patch-id(1) sometimes print two lines, one of which has commit = 0000000000000000000000000000000000000000

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:50:34

This behaves as I'd expect on git.git, i.e. shows a patch id and the commit id:

    $ git show 24231e063f0f003f8ffd7b64c7ba6a0baaaa5283 | git patch-id
    f10c69e0e5b33da206f37bd93639875555ac9b79
24231e063f0f003f8ffd7b64c7ba6a0baaaa5283

But what does this mean, also on git.git:

    $ git show 7d48e9e6f77d336376c1a554eeff0590f77e1ee1 | git patch-id
    4ba8a248731c5fcbd09cacb248d3128e742d1c90
7d48e9e6f77d336376c1a554eeff0590f77e1ee1
    d019b35e0b859cdd6907ee170927de1124c0ed6e
0000000000000000000000000000000000000000

7d48e9e6f77d336376c1a554eeff0590f77e1ee1 is just one of the commits
that results in this output:

    $ git log --pretty=format:%H -p | git patch-id | grep
0000000000000000000000000000000000000000
    d019b35e0b859cdd6907ee170927de1124c0ed6e
0000000000000000000000000000000000000000
    3b23a2a11055aef557369971e825010879a8c4d7
0000000000000000000000000000000000000000
    d498fbbad6f1374d952925df699da237c3e8f2df
0000000000000000000000000000000000000000
    b0c930dc1926ffae9cca022797856762fa908be6
0000000000000000000000000000000000000000

And on another repository where I'm dealing with this I have a bunch
more of them.

Why are they there and what do they mean? Maybe it's a bug, or
something I can explain in the manual page.

Re: Why does git-patch-id(1) sometimes print two lines, one of which has commit = 0000000000000000000000000000000000000000

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:34

Ævar Arnfjörð Bjarmason venit, vidit, dixit 16.02.2011 15:56:
This behaves as I'd expect on git.git, i.e. shows a patch id and the commit id:

    $ git show 24231e063f0f003f8ffd7b64c7ba6a0baaaa5283 | git patch-id
    f10c69e0e5b33da206f37bd93639875555ac9b79
24231e063f0f003f8ffd7b64c7ba6a0baaaa5283

But what does this mean, also on git.git:

    $ git show 7d48e9e6f77d336376c1a554eeff0590f77e1ee1 | git patch-id
    4ba8a248731c5fcbd09cacb248d3128e742d1c90
7d48e9e6f77d336376c1a554eeff0590f77e1ee1
    d019b35e0b859cdd6907ee170927de1124c0ed6e
0000000000000000000000000000000000000000

7d48e9e6f77d336376c1a554eeff0590f77e1ee1 is just one of the commits
that results in this output:

    $ git log --pretty=format:%H -p | git patch-id | grep
0000000000000000000000000000000000000000
    d019b35e0b859cdd6907ee170927de1124c0ed6e
0000000000000000000000000000000000000000
    3b23a2a11055aef557369971e825010879a8c4d7
0000000000000000000000000000000000000000
    d498fbbad6f1374d952925df699da237c3e8f2df
0000000000000000000000000000000000000000
    b0c930dc1926ffae9cca022797856762fa908be6
0000000000000000000000000000000000000000
You're telling us that patch-ids, not the sha1's of affected commits here.
And on another repository where I'm dealing with this I have a bunch
more of them.

Why are they there and what do they mean? Maybe it's a bug, or
something I can explain in the manual page.
You would have to explain that git-patch-id trips over "\ Now
newline..." lines in our diffs. Alternatively, wait a few minutes for my
patch (done) with a test (the boring part...).

Cheers,
Michael

[PATCH 1/2] git-patch-id: test for "no newline" markers

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:34

Currently, patch-id trips over our very own diff extension for marking
the absence of newline at EOF.

Expose this in a test.

Signed-off-by: Michael J Gruber <redacted>
---
 t/t4204-patch-id.sh |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index 68e2652..db96064 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -63,4 +63,40 @@ test_expect_success 'patch-id supports git-format-patch MIME output' '
 	test_cmp patch-id_master patch-id_same
 '
 
+cat >nonl <<\EOF
+diff --git i/a w/a
+index e69de29..2e65efe 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+\ No newline at end of file
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+cat >withnl <<\EOF
+diff --git i/a w/a
+index e69de29..7898192 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+test_expect_failure 'patch-id handles no-nl-at-eof markers' '
+	cat nonl | calc_patch_id nonl &&
+	cat withnl | calc_patch_id withnl &&
+	test_cmp patch-id_nonl patch-id_withnl
+'
 test_done
-- 
1.7.4.1.74.gf39475.dirty

[PATCH 2/2] git-patch-id: do not trip over "no newline" markers

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:34

Currently, patch-id trips over our very own diff extension for marking
the absence of newline at EOF.

Fix it. (Ignore it, it's whitespace.)

Signed-off-by: Michael J Gruber <redacted>
---
 builtin/patch-id.c  |    2 ++
 t/t4204-patch-id.sh |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 5125300..653d958 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -73,6 +73,8 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
 			p += 7;
 		else if (!memcmp(line, "From ", 5))
 			p += 5;
+		else if (!memcmp(line, "\\ No newline at end of file", 27))
+			continue;
 
 		if (!get_sha1_hex(p, next_sha1)) {
 			found_next = 1;
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index db96064..d2c930d 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -94,7 +94,7 @@ index e69de29..6178079 100644
 +b
 EOF
 
-test_expect_failure 'patch-id handles no-nl-at-eof markers' '
+test_expect_success 'patch-id handles no-nl-at-eof markers' '
 	cat nonl | calc_patch_id nonl &&
 	cat withnl | calc_patch_id withnl &&
 	test_cmp patch-id_nonl patch-id_withnl
-- 
1.7.4.1.74.gf39475.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help