git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Recording cherry-picked commits

From
JQJean-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
fi
if 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/
Previous: Jean-Baptiste QuenotNext: Rafael Garcia-Suarez
Message 2 of 8 in “Recording cherry-picked commits”
  1. Jean-Baptiste QuenotMar 21, 2008
  2. Jean-Baptiste QuenotMar 22, 2008
  3. Rafael Garcia-SuarezMar 22, 2008
  4. Junio C HamanoMar 23, 2008
  5. Jean-Baptiste QuenotMar 23, 2008
  6. Johannes SchindelinMar 23, 2008
  7. Rafael Garcia-SuarezMar 23, 2008
  8. Johannes SchindelinMar 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.