git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG?] Patches created with 'diff.noprefix=true' don't 'git apply'.
@ 2014-05-01  1:36 Nathan Collins
  2014-05-01  2:40 ` Jonathan Nieder
  0 siblings, 1 reply; 13+ messages in thread
From: Nathan Collins @ 2014-05-01  1:36 UTC (permalink / raw)
  To: git

Bug?
====

Patches created with 'diff.noprefix=true' don't 'git apply' without
specifying '-p0'.

I'm not sure this is a bug -- the 'man git-apply' just says "Reads the
supplied diff output (i.e. "a patch") and applies it to files" -- but
I would expect patches I create locally to apply cleanly locally. In
real life the 'diff.noprefix=true' is in my ~/.gitconfig, so this was
pretty confusing.

Here's an old bug that's kind of related:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=607044

I'm using Git 1.9.2.

Example
=======

Create a repo with a test commit:

  git init bug.git
  cd bug.git
  git add test
  git commit test -m Test

Revert the test commit in a contrived way (like
'git revert HEAD --no-commit; git reset'). This works:

  git -c diff.noprefix=false show | git -c diff.noprefix=false apply --reverse

And this works:

  git reset --hard
  git -c diff.noprefix=true show | git -c diff.noprefix=true apply -p0 --reverse

But this fails:

  git reset --hard
  git -c diff.noprefix=true show | git -c diff.noprefix=true apply --reverse

    fatal: git diff header lacks filename information when removing 1
leading pathname component (line 12)

Use Case
========

Partially reverting a commit:

http://git.661346.n2.nabble.com/Revert-a-single-commit-in-a-single-file-td6064050.html#a6064406

Cheers,

-nathan

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-05-08 16:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01  1:36 [BUG?] Patches created with 'diff.noprefix=true' don't 'git apply' Nathan Collins
2014-05-01  2:40 ` Jonathan Nieder
2014-05-06  1:33   ` Nathan Collins
2014-05-06  1:59     ` Jonathan Nieder
2014-05-06 18:10     ` Junio C Hamano
2014-05-06 19:36       ` Nathan Collins
2014-05-06 21:12         ` Junio C Hamano
2014-05-07  1:16           ` Nathan Collins
2014-05-07 18:42             ` Junio C Hamano
2014-05-07 23:39               ` Nathan Collins
2014-05-08  4:38                 ` Nathan Collins
2014-05-08  4:53                   ` Nathan Collins
2014-05-08 16:56                 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).