[PATCHv3 2/2] git-patch-id: do not trip over "no newline" markers
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Feb 18, 2011, 10:12 UTC
- Message-ID
- <c0ee81b29d902e773dc851aaf86b99c9337079c9.1298023827.git.git@drmicha.warpmail.net>
- In-Reply-To
- <4D5E278F.2010509@drmicha.warpmail.net>
Currently, patch-id trips over the diff extension for marking the absence of newline at EOF.
Fix it. (Ignore it, it's whitespace.)
This uses the same detection rationale as in buitlin/apply.c, which was introduced in
433ef8a ([PATCH] Make git-apply understand incomplete lines in non-C locales, 2005-09-04)
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> --- 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..e1c3cb9 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, "\\ ", 2) && strlen(line)>=12) + 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