git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG?] Patches created with 'diff.noprefix=true' don't 'git apply'.

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2014, 18:10 UTC
Message-ID
<xmqqa9aug4my.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAO8RVveV4SgXmJzWpYnyB3rnQALQkrrLNtLL5Ej5Y9Mjjekmmw@mail.gmail.com>
Nathan Collins <nathan.collins@gmail.com> writes:
> Hmmm. Maybe a warning that the patch is expected to be in '-p1'
> format, and that setting 'diff.noprefix=true' makes some commands
> generate '-p0' patches?
"some"?  Do you have exceptions in mind?
> But I worry this would just confuse / distract
> the people that don't have 'diff.noprefix=true' set,

Probably. But that would suggest that the place to improve the doc is for diff.noprefix configuration variable, no?

> Better I think would be for 'git apply' to be
> smarter, as you suggest below.

As it is a plumbing command behind "add -p", "am", and friends, I would hate to see "git apply" pretend to be smarter than its users. When the user tells it to use -p0, it shouldn't guess, and when the user tells it to use -p1 by not giving any -p$n, it shouldn't guess.

As long as we make it clear "git apply" without any explicit -p$n means the user is telling it to do -p1 in its documentation, I think it would be fine.

>> I personally think setting diff.noprefix is not very sane (it also
>> breaks "patch -p1"), and I suppose I should have been louder about
>> that when it was introduced.

I share the same feeling ;-) But the boat has sailed, so the best we could do is to warn in its doc (i.e. where diff.noprefix is described) about its pitfalls.

Previous: Jonathan NiederNext: Nathan Collins
Message 5 of 13 in “[BUG?] Patches created with 'diff.noprefix=true' don't 'git apply'.”
  1. Nathan CollinsMay 1, 2014
  2. Jonathan NiederMay 1, 2014
  3. Nathan CollinsMay 6, 2014
  4. Jonathan NiederMay 6, 2014
  5. Junio C HamanoMay 6, 2014
  6. Nathan CollinsMay 6, 2014
  7. Junio C HamanoMay 6, 2014
  8. Nathan CollinsMay 7, 2014
  9. Junio C HamanoMay 7, 2014
  10. Nathan CollinsMay 7, 2014
  11. Nathan CollinsMay 8, 2014
  12. Nathan CollinsMay 8, 2014
  13. Junio C HamanoMay 8, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.