From: James Vega Date: Mon, 07 Dec 2009 21:35:36 GMT Subject: Re: git-apply fails on creating a new file, with both -p and --directory specified Message-ID: In-Reply-To: <7vws1e3ma1.fsf@alter.siamese.dyndns.org> Junio C Hamano pobox.com> writes: > > "Steven J. Murdoch" cl.cam.ac.uk> writes: > > > 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. > > A very nicely done report. > > In addition to your test case, I suspect that a patch that only changes > mode would have acted funny with -p option. > It looks like this may have introduced a bug when staging a file removal. Here's an example git session showing the issue: $ git init test Initialized empty Git repository in /local_disk/tmp/test/.git/ $ cd test $ echo "foo" > foo $ git add foo $ git commit -m 'Add foo' [master (root-commit) 3643b5d] Add foo 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 foo $ mv foo bar $ git add -p diff --git a/foo b/foo index 257cc56..0000000 --- a/foo +++ /dev/null @@ -1 +0,0 @@ -foo Stage this hunk [y,n,q,a,d,/,e,?]? y $ git status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # new file: dev/null # deleted: foo # # Changed but not updated: # (use "git add/rm ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # deleted: dev/null # # Untracked files: # (use "git add ..." to include in what will be committed) # # bar Replacing the 'git add -p' with git diff | sed '/^deleted file/d' | git apply --cached also exhibits the problem.