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

Re: git apply does not honor diff.noprefix config setting

From
Junio C Hamano <gitster@pobox.com>
Date
May 21, 2018, 02:03 UTC
Message-ID
<xmqqefi53gva.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAM_JFCza0Az32RC-ytu_6PxG9JnteySPEDyKEeDzZAv9MdadAQ@mail.gmail.com>
hIpPy <hippy2981@gmail.com> writes:
Show 5 quoted lines
> If I disable mnemonic prefix,
>
> $ git config --global diff.noprefix true
>
> and do a round-trip of format-patch and apply,

Setting diff.noprefix does not disable "mnemonic prefix". It asks "diff" family of commands to use no prefix, not even the normal, non-mnemonic, prefix.

Show 7 quoted lines
> $ git format-patch -1 @
> $ git apply <some-file.patch>
>
> git apply fails with,
>
> error: git diff header lacks filename information when removing 1
> leading pathname component (line 16)
Totally expected.
> Without 'diff.noprefix' config setting, git apply works. It seems git
> apply does not honor the diff.noprefix config setting.

Yes, and because "diff" and "format-patch" are for producers of, and "apply" and "am" are for consumers of a patch, which are likely to be different people, "apply" or "am" should never pay attention to "diff.noprefix".

It is a different issue if we should have
 - format-patch.noprefix, which defaults to the same as
   diff.noprefix, but allows people to configure "format-patch"
   differently from "diff" and "show"
 - am.pvalue, which defaults to 1, but can be set to e.g. 0 to
   accept format-patch output from those who set
   format-patch.noprefix to true

I haven't thought things through, but offhand I do not see why we shouldn't. But I am reasonably firm on that diff.noprefix should never affect anything on the "apply/am" side.

Previous: hIpPy
Message 2 of 2 in “git apply does not honor diff.noprefix config setting”
  1. hIpPyMay 19, 2018
  2. Junio C HamanoMay 21, 2018

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.