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

Re: Bug: With diff.noprefix=true, `git format-patch` creates a patch that `git am` rejects

From
Gwyneth Morgan <gwymor@tilde.club>
Date
Jan 8, 2022, 02:45 UTC
Message-ID
<Ydj6aYySwK5qP/uo@tilde.club>
In-Reply-To
<CAAHpriMPdahH2xbrrQbeCJPYpLhr6tuvT6xsG3nACmskKF1v2w@mail.gmail.com>
On 2022-01-07 16:36:27-0800, Keith Thompson wrote:
Show 31 quoted lines
> The details: I had this in my $HOME/.gitconfig:
> 
> [diff]
>         noprefix = true
> 
> This caused `git format-patch` *not* to generate the `a/` and `b/`
> prefixes in the patch file.  Setting "noprefix = false" works around
> the problem.
> 
> Here are the first few lines of the resulting patch file:
> ===
> cat 0001-Fix-documented-argv-and-envp-params-for-posix_spawn.patch,000
> >From f4a41189d86bc208a90e754387294b9c4c11cdfc Mon Sep 17 00:00:00 2001
> From: Keith Thompson <Keith.S.Thompson@gmail.com>
> Date: Wed, 5 Jan 2022 13:30:16 -0800
> Subject: [PATCH] Fix documented argv and envp params for posix_spawn
> 
> ---
>  newlib/libc/posix/posix_spawn.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git newlib/libc/posix/posix_spawn.c newlib/libc/posix/posix_spawn.c
> index 005471fde..85bfa6477 100644
> --- newlib/libc/posix/posix_spawn.c
> +++ newlib/libc/posix/posix_spawn.c
> ===
> 
> Feeding this patch to `git am` caused it to strip the `newlib/`
> prefix from the file name.  There doesn't seem to be a way to coax
> `git format-patch` to ignore the current diff.noprefix setting,
> or `git am` to tolerate the missing prefixes.

The -p<num> flag controls how many segments `git am` or `git apply` removes. The default is -p1. `git am -p0` should apply the patch correctly.

Previous: Keith Thompson
Message 2 of 2 in “Bug: With diff.noprefix=true, `git format-patch` creates a patch that `git am` rejects”
  1. Keith ThompsonJan 8, 2022
  2. Gwyneth MorganJan 8, 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.