All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
To: Felipe Oliveira Carvalho <felipekde@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Patches produced with format-patch under specific config aren't applicable
Date: Wed, 7 Sep 2022 09:19:14 +0700	[thread overview]
Message-ID: <Yxf/opwDZb/dLp29@danh.dev> (raw)
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:
> 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

      reply	other threads:[~2022-09-07  2:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 13:45 Patches produced with format-patch under specific config aren't applicable Felipe Oliveira Carvalho
2022-09-07  2:19 ` Đoàn Trần Công Danh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yxf/opwDZb/dLp29@danh.dev \
    --to=congdanhqx@gmail.com \
    --cc=felipekde@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.