author | Junio C Hamano <gitster@pobox.com> | |
Mon, 28 Feb 2011 05:58:30 +0000 (21:58 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 28 Feb 2011 05:58:30 +0000 (21:58 -0800) |
* mg/patch-id:
git-patch-id: do not trip over "no newline" markers
git-patch-id: test for "no newline" markers
git-patch-id: do not trip over "no newline" markers
git-patch-id: test for "no newline" markers
builtin/patch-id.c | patch | blob | history | |
t/t4204-patch-id.sh | patch | blob | history |
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 512530022edac398f8541ee6c400c7312659e730..49a0472a9bd28274c4be1352996e700a1db4b94a 100644 (file)
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
p += 7;
else if (!memcmp(line, "From ", 5))
p += 5;
+ else if (!memcmp(line, "\\ ", 2) && 12 < strlen(line))
+ 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 68e2652814c6a52265407b0fdfb70162eb634d53..d2c930de87f721a0e876351e511295ae0b094108 100755 (executable)
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
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_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
+'
test_done