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:
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.
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/>.)
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.
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.