Re: [PATCH] format-patch: generate valid patch with diff.noprefix config
- From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
- Date
- Jun 4, 2020, 23:26 UTC
- Message-ID
- <20200604232619.GA6329@danh.dev>
- In-Reply-To
- <xmqq367aposu.fsf@gitster.c.googlers.com>
On 2020-06-04 13:18:57-0700, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Laurent Arnoud <laurent@spkdev.net> writes: > > > I don't know if its a bug but I founded strange that I needed to use an alias > > "git -c diff.noprefix=false format-patch" to generate a patch that I can apply > > directly with "git am". > > The same thing can be said about the diff.relative option. > > As I do not use either of these variables myself, I am somewhat > indifferent, if those who set these variables find the consequences > of doing so unpleasant. As people often say, if it hurts, then... > ;-)
FWIW, people need to dig into git-config(1) to know diff.noprefix We don't mention it in git-diff(1). Me neither until today.
Show 5 quoted lines
> Because the recipient of format-patch output who consumes it is > typically different from the one who generates it, it probably does > not make much sense to attempt linking diff.noprefix=true with the > -p0 option (there isn't even a configuration for 'git am -p<num>', > if I am not mistaken).
Could we extend the patch in someway that can hint git-am(1) to use "-p0" if patch was generated by --no-prefix? I couldn't come up with any idea right now, since all parts of the patch is very busy with a lot of information. An RFC 822 header, perhap?
Of course old git-am(1) couldn't understand the extension. And the new git-am may come up with false positive?
Show 23 quoted lines
> Depending on the project a user works with, allowing > log/show/format-patch to honor certain diff.* configuration > variables, without a way to countermand them with more specific > configuration for log/show/format-patch, may smell like a bug. > > I am not sure where to draw the line, though. Would we treat only > format-patch and no other commands in the log family specially? > Would we treat each commands in the log family specially and > separately, so that you could say "diff and show uses noprefix, but > 'log -p' and 'whatchanged' uses the standard a/ and b/ prefix and > format-patch uses old/ and new/ prefix" independently? > > > I didn't know the -p option but to send a patch to a > > mailinglist it should have the prefix I guess ? > > The participants in this project would certainly find it unusual > when they see a prefix-less patch. > > There probably are projects older than Git whose convention is to > use .noprefix; we didn't want to force them to switch and instead > accomodated their preference with .noprefix but in hindsight, it may > have been a better idea to force one true way to everybody, which > would have kept the world simpler. I dunno.
I do use format-patch --no-prefix. It's unlikely that I will use diff.noprefix, though. I think other people also have different preferences.
-- Danh