Skip to content

Commit

Permalink
Merge branch 'mg/patch-id' into maint
Browse files Browse the repository at this point in the history
* mg/patch-id:
  git-patch-id: do not trip over "no newline" markers
  git-patch-id: test for "no newline" markers
  • Loading branch information
Junio C Hamano committed Mar 16, 2011
2 parents 5b8aac3 + 2485eab commit bd2700d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin/patch-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "\\ ", 2) && 12 < strlen(line))
continue;

if (!get_sha1_hex(p, next_sha1)) {
found_next = 1;
Expand Down
36 changes: 36 additions & 0 deletions t/t4204-patch-id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_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

0 comments on commit bd2700d

Please sign in to comment.