3 # Copyright (c) 2005 Junio C Hamano.
6 . git-sh-setup || die
"Not a git archive."
8 usage
="usage: $0 "'<upstream> [<head>]
10 Uses output from git-cherry to rebase local commits to the new head of
15 upstream
=$
(expr "$1" : '\(.*\)\.\.') ours
=$
(expr "$1" : '.*\.\.\(.*\)$')
16 set x
"$upstream" "$ours"
20 git-update-index
--refresh ||
exit
23 1) ours_symbolic
=HEAD
;;
24 2) ours_symbolic
="$2" ;;
28 upstream
=`git-rev-parse --verify "$1"` &&
29 ours
=`git-rev-parse --verify "$ours_symbolic"` ||
exit
30 different1
=$
(git-diff-index
--name-only --cached "$ours") &&
31 different2
=$
(git-diff-index
--name-only "$ours") &&
32 test "$different1$different2" = "" ||
33 die
"Your working tree does not match $ours_symbolic."
35 git-read-tree
-m -u $ours $upstream &&
36 new_head
=$
(git-rev-parse
--verify "$upstream^0") &&
37 git-update-ref HEAD
"$new_head" ||
exit
41 trap "rm -rf $tmp-*" 1 2 3 15
45 git-cherry
-v $upstream $ours |
46 while read sign commit msg
50 echo >&2 "* Already applied: $msg"
53 echo >&2 "* Applying: $msg"
54 S
=$
(git-rev-parse
--verify HEAD
) &&
55 git-cherry-pick
--replay $commit ||
{
56 echo >&2 "* Not applying the patch and continuing."
63 echo >&2 Some commits could not be rebased
, check by hand
:
65 echo >&2 "(the same list of commits are found in $tmp)"