Bug 1671640 - git am does garbage commit summary
Summary: git am does garbage commit summary
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: git
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Todd Zullinger
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-01 07:07 UTC by Milan Crha
Modified: 2019-02-01 08:01 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-01 07:44:29 UTC


Attachments (Terms of Use)

Description Milan Crha 2019-02-01 07:07:03 UTC
Using:

   git format-patch -2

and then revert the patches (or using a different checkout) and apply the first of them with

   git am /path/to/0001-.....patch

does change/garbage the commit summary, when it contains prefix "[something] ".
I use this prefix to mark which part of the code the commit belongs to, which is sometimes useful. It's properly saved in the format-patch result:

   Subject: [PATCH 1/2] [some part] Text

the same as in the git log result before reverting the commit:

   [some part] Text

but after git am the git log result changes to:

   Text

which is wrong. I'd expect that format-patch and am will produce exactly the same result.

Maybe this is a known bug. I faced it earlier too. My currently installed git is git-2.17.0-3.fc28.x86_64.

Comment 1 Todd Zullinger 2019-02-01 07:40:07 UTC
Hi Milan,

You may want to look into the `--keep-non-patch` option to git-am.  That passes the `-b` option to git-mailinfo which limits stripping bracketed strings in the subject to those that contain PATCH.  See also the `-k/--keep-subject` option to git-format-patch.

I don't think there's any bug here, just a needed adjustment if your workflow uses git-am on patches which contain bracketed strings that you wish to keep.  I believe this has been discussed on the git list a few times in the past, but I don't have any links handy.  (You may find some via the list archive at <https://public-inbox.org/git/>.)

Comment 2 Milan Crha 2019-02-01 07:44:29 UTC
Thanks for a quick reply and a pointer for the parameters. I can imagine it could be discussed elsewhere many times. My personal opinion would be to keep them by default, it avoids data loss, thus is safer default. Not a thing you might change only for Fedora for sure, thus I'm closing this. Thanks again.

Comment 3 Todd Zullinger 2019-02-01 08:01:12 UTC
Yeah, I think some past discussions have suggested having the `-b` option be the default in git-mailinfo (or effectively similar/same behavior).  Surprisingly, it doesn't come up all that often.  I can only guess that most projects that have an email-based workflow (or one that uses git format-patch/am) use a format like git and the kernel.  That is, where the area of the code is given as "area: fix frotz" rather than "[area] fix frotz" which avoids this rather awkward interaction of git-format-patch and git-am.  Either that or it bites each new project maintainer a few times and then they alias `git am` to `git am --keep-non-patch`.  In any case, I'm glad that there are existing options to make this work better for you.  Sorry the defaults don't work as well.  With a little luck it will be further improved in the future.


Note You need to log in before you can comment on or make changes to this bug.