Re: FEATURE REQUEST: Cherry pick in not checked out branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 15 Mar 2010, Michael J Gruber wrote:

> 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" $commit

Totally Untested(tm),
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]