author | Junio C Hamano <gitster@pobox.com> | |
Sat, 17 May 2008 08:51:31 +0000 (01:51 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 17 May 2008 08:51:31 +0000 (01:51 -0700) | ||
commit | 5c47f4c6e71e6de08348f837f38a446a2f2b0ed7 | |
tree | c3f388e53beec55d52e14015cbdc3b7771827702 | tree | snapshot |
parent | 88f6dbaf99f43053f86474b28beedd91e77c64d9 | commit | diff |
builtin-apply: accept patch to an empty file
A patch from a foreign SCM (or plain "diff" output) often have both
preimage and postimage filename on ---/+++ lines even for a patch that
creates a new file. However, when there is a filename for preimage, we
used to insist the file to exist (either in the work tree and/or in the
index). When we cannot be sure by parsing the patch that it is not a
creation patch, we shouldn't complain when if there is no such a file.
This commit fixes the logic.
Refactor the code that validates the preimage file into a separate
function while we are at it, as it is getting rather big.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
A patch from a foreign SCM (or plain "diff" output) often have both
preimage and postimage filename on ---/+++ lines even for a patch that
creates a new file. However, when there is a filename for preimage, we
used to insist the file to exist (either in the work tree and/or in the
index). When we cannot be sure by parsing the patch that it is not a
creation patch, we shouldn't complain when if there is no such a file.
This commit fixes the logic.
Refactor the code that validates the preimage file into a separate
function while we are at it, as it is getting rather big.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | diff | blob | history |