I spent just my last night going through few months worth of patches and cherry-picking the bugfixy ones to glibc’s release/2.11/master. But I was tired and didn’t pay attention to git’s messages, so at the end of the evening, I noticed that for all conflicting patches, I have done
git commit -a instead of
git commit -a -c commitid. This had a definite advantage since the “(cherry picked from commit …)” notices inserted by
git cherry-pick -x got preserved, but also a very definitive problem – the author name and date info for each commit was wrong.
(Note that AIUI, 1.7.5 cherry-pick might not have this problem anymore. I’m still using 1.7.4, content with Debian’s packaged version nowadays.)
Due to the -x lines, we still have mapping to original history. Therefore, some scripting should fix this quickly. And sure enough…! Maybe this recipe will come useful to someone:
git filter-branch --commit-filter ' if [ "$GIT_AUTHOR_NAME" = "Petr Baudis" ]; then # Author of this commit is wrong! We could also simply correct # all commits containing the "cherry picked" notice. cat >/tmp/logm$$ # save log message ocommit="$(sed -n '\''s/^(cherry picked from commit \(.*\))$/\1/p'\'' </tmp/logm$$)" # Load original authorship information: IFS=: read GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE \ <<<"$(git log -1 --pretty=format:"%an:%ae:%at" $ocommit)" # Redo the commit: export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE git commit-tree "$@" </tmp/logm$$ rm /tmp/logm$$ else git commit-tree "$@" # preserve commit intact fi' c55cc45ed76603b380489ee8c91ab5dce92e92f1..HEAD
Note that this requires that /bin/sh is bash (which may NOT be the case on debian!). Otherwise, you need to rewrite the <<< bit.
The c55cc45ed… commit is the first wrong cherry-pick. You may omit that altogether if you wish but the complete branch history is going to be rewritten. Also note that you should never rewrite commits that are already pushed out to a public place.