Re: FEATURE REQUEST: Cherry pick in not checked out branch
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 15, 2010, 13:12 UTC
- Message-ID
- <alpine.DEB.1.00.1003151359440.7596@pacific.mpi-cbg.de>
- In-Reply-To
- <4B9E13A4.3090502@drmicha.warpmail.net>
Hi,
On Mon, 15 Mar 2010, Michael J Gruber wrote:
Show 6 quoted lines
> Tim Mazid venit, vidit, dixit 15.03.2010 10:54: > > > Could we not make cherry-pick "stash, checkout, cherry-pick, checkout, > > pop"? > > Sure, that would be 5 command invocations requiring a work tree ;)
Actually, if you want something that does not change all the timestamps, and that does only trivial merges (i.e. no conflicts), you may have luck with something like this:
test $# = 2 || {
echo "Usage: $0 <commit> <branch>" >&2
exit 1
}
GIT_INDEX_FILE=.git/tmp.index &&
export GIT_INDEX_FILE &&
git read-tree "$2" &&
git diff "$1"^! | git apply --index &&
tree=$(git write-tree) &&
msg="$(git cat-file commit "$1" | sed '1,/^$/d')" &&
commit=$(echo "$msg" | git commit-tree $tree -p "$2") &&
git update-ref -m cherry-pick-2.0 "$2" $commitTotally Untested(tm), Dscho