git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [Bug report] git format-patch + git am doesn't preserve original commit message
@ 2021-06-10 15:04 Nikita Bobko
  2021-06-10 15:11 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Bobko @ 2021-06-10 15:04 UTC (permalink / raw)
  To: git

Steps to reproduce:
```
git init
git commit --allow-empty -m 'root'
echo foo > foo
git add .
git commit -m '[tag] foo'
git checkout @~
git format-patch master~..master
cat 0001-tag-foo.patch | git am
```
Expected: commit message generated by `git am` is `[tag] foo`
Actual: commit message generated by `git am` is `foo`

[System Info]
git version:
git version 2.31.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.4.98-1-lts #1 SMP Sat, 13 Feb 2021 19:22:14 +0000 x86_64
compiler info: gnuc: 10.2
libc info: glibc: 2.33
$SHELL (typically, interactive shell): /bin/zsh


[Enabled Hooks]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bug report] git format-patch + git am doesn't preserve original commit message
  2021-06-10 15:04 [Bug report] git format-patch + git am doesn't preserve original commit message Nikita Bobko
@ 2021-06-10 15:11 ` Jeff King
  2021-06-10 15:36   ` Nikita Bobko
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2021-06-10 15:11 UTC (permalink / raw)
  To: Nikita Bobko; +Cc: git

On Thu, Jun 10, 2021 at 05:04:58PM +0200, Nikita Bobko wrote:

> Steps to reproduce:
> ```
> git init
> git commit --allow-empty -m 'root'
> echo foo > foo
> git add .
> git commit -m '[tag] foo'
> git checkout @~
> git format-patch master~..master
> cat 0001-tag-foo.patch | git am
> ```
> Expected: commit message generated by `git am` is `[tag] foo`
> Actual: commit message generated by `git am` is `foo`

This is working as intended. See the "-k" option of git-am and
git-mailinfo (and also "-b" for mailinfo).

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bug report] git format-patch + git am doesn't preserve original commit message
  2021-06-10 15:11 ` Jeff King
@ 2021-06-10 15:36   ` Nikita Bobko
  2021-06-10 16:29     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Bobko @ 2021-06-10 15:36 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Oh, I see, thank you, it works.

But actually, I am not sure that it's "expected" behavior. I would
expect git to preserve original message by default without any
additional flags. Shouldn't `--keep-non-patch` flag in `git am` be
enabled by default then?

On Thu, Jun 10, 2021 at 5:11 PM Jeff King <peff@peff.net> wrote:
>
> On Thu, Jun 10, 2021 at 05:04:58PM +0200, Nikita Bobko wrote:
>
> > Steps to reproduce:
> > ```
> > git init
> > git commit --allow-empty -m 'root'
> > echo foo > foo
> > git add .
> > git commit -m '[tag] foo'
> > git checkout @~
> > git format-patch master~..master
> > cat 0001-tag-foo.patch | git am
> > ```
> > Expected: commit message generated by `git am` is `[tag] foo`
> > Actual: commit message generated by `git am` is `foo`
>
> This is working as intended. See the "-k" option of git-am and
> git-mailinfo (and also "-b" for mailinfo).
>
> -Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bug report] git format-patch + git am doesn't preserve original commit message
  2021-06-10 15:36   ` Nikita Bobko
@ 2021-06-10 16:29     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2021-06-10 16:29 UTC (permalink / raw)
  To: Nikita Bobko; +Cc: git

On Thu, Jun 10, 2021 at 05:36:43PM +0200, Nikita Bobko wrote:

> Oh, I see, thank you, it works.
> 
> But actually, I am not sure that it's "expected" behavior. I would
> expect git to preserve original message by default without any
> additional flags. Shouldn't `--keep-non-patch` flag in `git am` be
> enabled by default then?

I'd be hesitant to change that, since it would break any communities
using other tags. I think 17635fc900 (mailinfo: -b option keeps
[bracketed] strings that is not a [PATCH] marker, 2009-07-15) has some
examples.

In your example, I think passing "-k" to both git-format-patch and
git-am is the right solution. But presumably that's a toy example. In
the real world, the person running "am" is probably not the same as the
one running format-patch (and if it is, probably something like
cherry-pick is a better solution anyway).

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-10 16:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 15:04 [Bug report] git format-patch + git am doesn't preserve original commit message Nikita Bobko
2021-06-10 15:11 ` Jeff King
2021-06-10 15:36   ` Nikita Bobko
2021-06-10 16:29     ` Jeff King

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git