Skip to content

Commit c8cdbf2

Browse files
committed
Merge branch 'mg/patch-id'
* mg/patch-id: git-patch-id: do not trip over "no newline" markers git-patch-id: test for "no newline" markers
2 parents 66a6a31 + 2485eab commit c8cdbf2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

builtin/patch-id.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
7373
p += 7;
7474
else if (!memcmp(line, "From ", 5))
7575
p += 5;
76+
else if (!memcmp(line, "\\ ", 2) && 12 < strlen(line))
77+
continue;
7678

7779
if (!get_sha1_hex(p, next_sha1)) {
7880
found_next = 1;

t/t4204-patch-id.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,40 @@ test_expect_success 'patch-id supports git-format-patch MIME output' '
6363
test_cmp patch-id_master patch-id_same
6464
'
6565

66+
cat >nonl <<\EOF
67+
diff --git i/a w/a
68+
index e69de29..2e65efe 100644
69+
--- i/a
70+
+++ w/a
71+
@@ -0,0 +1 @@
72+
+a
73+
\ No newline at end of file
74+
diff --git i/b w/b
75+
index e69de29..6178079 100644
76+
--- i/b
77+
+++ w/b
78+
@@ -0,0 +1 @@
79+
+b
80+
EOF
81+
82+
cat >withnl <<\EOF
83+
diff --git i/a w/a
84+
index e69de29..7898192 100644
85+
--- i/a
86+
+++ w/a
87+
@@ -0,0 +1 @@
88+
+a
89+
diff --git i/b w/b
90+
index e69de29..6178079 100644
91+
--- i/b
92+
+++ w/b
93+
@@ -0,0 +1 @@
94+
+b
95+
EOF
96+
97+
test_expect_success 'patch-id handles no-nl-at-eof markers' '
98+
cat nonl | calc_patch_id nonl &&
99+
cat withnl | calc_patch_id withnl &&
100+
test_cmp patch-id_nonl patch-id_withnl
101+
'
66102
test_done

0 commit comments

Comments
 (0)