# git apply does not honor diff.noprefix config setting

2 messages from 2018-05-19 to 2018-05-21. Participants: hIpPy, Junio C Hamano.
Thread: https://gitlist.dev/t/48526

## hIpPy, 2018-05-19 23:18

Subject: git apply does not honor diff.noprefix config setting
Message-ID: <CAM_JFCza0Az32RC-ytu_6PxG9JnteySPEDyKEeDzZAv9MdadAQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAM_JFCza0Az32RC-ytu_6PxG9JnteySPEDyKEeDzZAv9MdadAQ%40mail.gmail.com

```
If I disable mnemonic prefix,

$ git config --global diff.noprefix true

and do a round-trip of format-patch and apply,

$ 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)

Without 'diff.noprefix' config setting, git apply works. It seems git
apply does not honor the diff.noprefix config setting.


Thanks,
Rish

```

## Junio C Hamano, 2018-05-21 02:03

Subject: Re: git apply does not honor diff.noprefix config setting
Message-ID: <xmqqefi53gva.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqefi53gva.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <CAM_JFCza0Az32RC-ytu_6PxG9JnteySPEDyKEeDzZAv9MdadAQ@mail.gmail.com>

```
hIpPy <hippy2981@gmail.com> writes:

> 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.

> $ 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.





```
