apply: handle Subversion diffs with /dev/null gracefully
authorTatyana Krasnukha <tatyana@synopsys.com>
Thu, 15 Feb 2018 00:29:34 +0000 (01:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Feb 2018 19:09:02 +0000 (11:09 -0800)
Subversion generates diffs that can contain lines like this one:

--- /dev/null (nonexistent)

Let's teach Git's apply machinery to handle such a line gracefully.

This fixes https://github.com/git-for-windows/git/isues/1489

Signed-off-by: Tatyana Krasnukha <tatyana@synopsys.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t4135-apply-weird-filenames.sh
diff --git a/apply.c b/apply.c
index 0c7b25989cdf58b411190744c97d93450be9b53e..3aadbae30523d7f41140220363805da3fd593118 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -975,7 +975,7 @@ static int gitdiff_verify_name(struct apply_state *state,
                }
                free(another);
        } else {
-               if (!starts_with(line, "/dev/null\n"))
+               if (!is_dev_null(line))
                        return error(_("git apply: bad git-diff - expected /dev/null on line %d"), state->linenr);
        }
 
index b14b8085786f579a301d584a0175ba1079960108..c7c688fcc4bbdfe97a5c595fddc96e2590e021a2 100755 (executable)
@@ -100,7 +100,7 @@ deleted file mode 100644
 -
 EOF
 
-test_expect_failure 'apply handles a diff generated by Subversion' '
+test_expect_success 'apply handles a diff generated by Subversion' '
        >Makefile &&
        git apply -p2 diff-from-svn &&
        test_path_is_missing Makefile