While trying to apply a patch from one repository (created by git-format-patch), to another (using git-am), git fails with: "fatal: git apply: bad git-diff - inconsistent new filename on line X" This appears to be because I was both using -p to strip some path components, and --directory to add different ones in. Only creating new files was affected. This was the case in git 1.6.5.2, and also the development version 1.6.6.rc0.15.g4fa80. I have tested this on MacOS X Snow Leopard. This appears related to the bug discussed in: http://marc.info/?l=git&m=122237537312597&w=2 in which the following fix was posted: http://git.kernel.org/?p=git/git.git;a=commitdiff;h=969c877506cf8cc760c7b251fef6c5b6850bfc19 I have included a patch below to the test cases, which currently fails but, if I understand correctly, should succeed. Steven Murdoch. -- >8 -- Test git-apply creating a new file, combining --directory and -p flags Signed-off-by: Steven Murdoch <Steven.Murdoch@xxxxxxxxxxxx> --- t/t4128-apply-root.sh | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh index 8f6aea4..6cc741a 100755 --- a/t/t4128-apply-root.sh +++ b/t/t4128-apply-root.sh @@ -58,6 +58,23 @@ test_expect_success 'apply --directory (new file)' ' ' cat > patch << EOF +diff --git a/c/newfile2 b/c/newfile2 +new file mode 100644 +index 0000000..d95f3ad +--- /dev/null ++++ b/c/newfile2 +@@ -0,0 +1 @@ ++content +EOF + +test_expect_success 'apply --directory -p (new file)' ' + git reset --hard initial && + git apply -p2 --directory=some/sub/dir/ --index patch && + test content = $(git show :some/sub/dir/newfile2) && + test content = $(cat some/sub/dir/newfile2) +' + +cat > patch << EOF diff --git a/delfile b/delfile deleted file mode 100644 index d95f3ad..0000000 -- 1.6.5.2 -- http://www.cl.cam.ac.uk/users/sjm217/ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html