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

Re: Patches produced with format-patch under specific config aren't applicable

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Sep 7, 2022, 02:19 UTC
Message-ID
<Yxf/opwDZb/dLp29@danh.dev>
In-Reply-To
<CAOC8YXak_QfPgxc=JWvzpaPGe9ZnFhDnR-36PrMG16qXFkQmsw@mail.gmail.com>
On 2022-09-06 10:45:41-0300, Felipe Oliveira Carvalho <felipekde@gmail.com> wrote:
Show 34 quoted lines
> Patches produced with format-patch under specific config aren't applicable
> 
> Inbox
> I have diff.noprefix=true on my ~/.gitconfig
> 
>     [diff]
>         noprefix = true
> 
> I generate a .patch file from the last commit with
> 
>     git format-patch HEAD^
> 
> Due to noprefix=true, I get this line in the patch file
> 
>     diff --git src/filesystem/PhutilProcessQuery.php
> src/filesystem/PhutilProcessQuery.php
> 
> instead of the default
> 
>     diff --git a/src/filesystem/PhutilProcessQuery.php
> b/src/filesystem/PhutilProcessQuery.php
> 
> So when I try to apply that patch, I get
> 
>     $ git apply --check ./0001-my.patch
>     error: filesystem/PhutilProcessQuery.php: No such file or directory
> 
> In trying to remove the a/ and b/ that apply expects, it removes src/
> from the path, then fails to find filesystem/PhutilProcessQuery.php.
> 
> As a mitigation, I'm setting diff.noprefix to false, but a more robust
> solution would be for the format-patch command to ignore this setting
> as patches are expected to work on repos configured by different
> people.
You can use "-p0" with git-am or git-apply to apply such patches.

There's a RFE in the past to add log.noprefix and/or format.noprefix but it seems noone interested enough to work on it [1]

1: https://lore.kernel.org/git/xmqqr1auvs7m.fsf@gitster.g/
-- 
Danh
Previous: Felipe Oliveira Carvalho
Message 2 of 2 in “Patches produced with format-patch under specific config aren't applicable”
  1. Felipe Oliveira CarvalhoSep 6, 2022
  2. Đoàn Trần Công DanhSep 7, 2022

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.