apply: handle Subversion diffs with /dev/null gracefully

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>

Tatyana Krasnukha committed Feb 15, 2018 at 01:29 UTC e454ad4becff73588b1b3cc24dba3a0e740c7f7c
2 files changed +2 -2
apply.c
+1 -1
@@ -975,7 +975,7 @@ static int gitdiff_verify_name(struct apply_state *state,
975 }
976 free(another);
977 } else {
978 - if (!starts_with(line, "/dev/null\n"))
978 + if (!is_dev_null(line))
979 return error(_("git apply: bad git-diff - expected /dev/null on line %d"), state->linenr);
980 }
981
t/t4135-apply-weird-filenames.sh
+1 -1
@@ -100,7 +100,7 @@ deleted file mode 100644
100 -
101 EOF
102
103 -test_expect_failure 'apply handles a diff generated by Subversion' '
103 +test_expect_success 'apply handles a diff generated by Subversion' '
104 >Makefile &&
105 git apply -p2 diff-from-svn &&
106 test_path_is_missing Makefile