Re: Recording cherry-picked commits
- From
- Jean-Baptiste Quenot <jbq@caraldi.com>
- Date
- Mar 22, 2008, 16:37 UTC
- Message-ID
- <ae63f8b50803220937k78571fbdl1eeb60966ec7aa40@mail.gmail.com>
- In-Reply-To
- <ae63f8b50803210533n12645fb3w9a8be601c4cc394@mail.gmail.com>
What about using a hidden ".gitcherry" file in the current branch to store the commits that have been applied? With the simple shell scripts below I'm able to achieve the same effect as svnmerge:
Wrapper around git-cherry-pick: ------------------------------------------------------------------------ #! /bin/sh -e
# Write the commit in .gitcherry, stage .gitcherry for commit and call # git-cherry-pick. If a conflict occurs, resolve it and invoke this script with # --continue, in order to commit with the original author and commit message
if test "$1" = "--continue" ; then
cont=1
commit=$(tail -1 .gitcherry)
else
cont=0
commit=$1
fiif test $cont = 0 ; then
echo $commit >> .gitcherry
git add .gitcherry
git cherry-pick $commit
else
git commit -c $commit
fi
-------------------------------------------------------------------------Wrapper around git-cherry: ------------------------------------------------------------------------ #! /bin/sh -e
# List all commits with git-cherry and exclude all the ones that are specified # in .gitcherry. For each commit, invoke 'git show' to print the commit message
for commit in $(git-cherry $* | sed -ne 's/^+ //p' | grep -v -f .gitcherry) ; do
git show -s --pretty=format:"%H %s" $commit
done
------------------------------------------------------------------------WDYT?
-- Jean-Baptiste Quenot http://caraldi.com/jbq/blog/