{"thread":{"id":"22274","subject":"builtin-apply.c: fix the --- and +++ header filename consistency check","startedAt":"2010-01-18T21:37:38Z","lastAt":"2010-01-18T21:37:38Z","messageCount":1,"participants":["Andreas Gruenbacher"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"132052","messageId":"201001182237.38562.agruen@suse.de","threadId":"22274","inReplyTo":null,"subject":"builtin-apply.c: fix the --- and +++ header filename consistency check","fromName":"Andreas Gruenbacher","fromEmail":"agruen@suse.de","sentAt":"2010-01-18T21:37:38Z","receivedAt":"2010-01-18T21:37:38Z","isPatch":false,"sender":{"key":"agruen@suse.de","avatar":null},"body":"gitdiff_verify_name() only did a filename prefix check because of an\noff-by-one error.\n\nSigned-off-by: Andreas Gruenbacher <agruen@suse.de>\n---\n builtin-apply.c            |    2 +-\n t/t4133-apply-filenames.sh |   38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 39 insertions(+), 1 deletions(-)\n create mode 100755 t/t4133-apply-filenames.sh\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 541493e..c8be66e 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -686,7 +686,7 @@ static char *gitdiff_verify_name(const char *line, int \nisnull, char *orig_name,\n \t\tif (isnull)\n \t\t\tdie(\"git apply: bad git-diff - expected /dev/null, got %s on line %d\", \nname, linenr);\n \t\tanother = find_name(line, NULL, p_value, TERM_TAB);\n-\t\tif (!another || memcmp(another, name, len))\n+\t\tif (!another || memcmp(another, name, len + 1))\n \t\t\tdie(\"git apply: bad git-diff - inconsistent %s filename on line %d\", \noldnew, linenr);\n \t\tfree(another);\n \t\treturn orig_name;\ndiff --git a/t/t4133-apply-filenames.sh b/t/t4133-apply-filenames.sh\nnew file mode 100755\nindex 0000000..3421807\n--- /dev/null\n+++ b/t/t4133-apply-filenames.sh\n@@ -0,0 +1,38 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Andreas Gruenbacher\n+#\n+\n+test_description='git apply filename consistency check'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\tcat > bad1.patch <<EOF\n+diff --git a/f b/f\n+new file mode 100644\n+index 0000000..d00491f\n+--- /dev/null\n++++ b/f-blah\n+@@ -0,0 +1 @@\n++1\n+EOF\n+\tcat > bad2.patch <<EOF\n+diff --git a/f b/f\n+deleted file mode 100644\n+index d00491f..0000000\n+--- b/f-blah\n++++ /dev/null\n+@@ -1 +0,0 @@\n+-1\n+EOF\n+'\n+\n+test_expect_success 'apply diff with inconsistent filenames in headers' '\n+\ttest_must_fail git apply bad1.patch 2>err\n+\tgrep \"inconsistent new filename\" err\n+\ttest_must_fail git apply bad2.patch 2>err\n+\tgrep \"inconsistent old filename\" err\n+'\n+\n+test_done\n-- \n1.6.6.243.gff6d2\n"}]}