Merge master.kernel.org:/pub/scm/gitk/gitk
[git/git.git] / git-rebase-script
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano.
4 #
5
6 usage="usage: $0 "'<upstream> [<head>]
7
8 Uses output from git-cherry to rebase local commits to the new head of
9 upstream tree.'
10
11 : ${GIT_DIR=.git}
12
13 case "$#" in
14 1) linus=`git-rev-parse "$1"` &&
15 junio=`git-rev-parse HEAD` || exit
16 ;;
17 2) linus=`git-rev-parse "$1"` &&
18 junio=`git-rev-parse "$2"` || exit
19 ;;
20 *) echo >&2 "$usage"; exit 1 ;;
21 esac
22
23 git-read-tree -m -u $junio $linus &&
24 echo "$linus" >"$GIT_DIR/HEAD" || exit
25
26 tmp=.rebase-tmp$$
27 fail=$tmp-fail
28 trap "rm -rf $tmp-*" 0 1 2 3 15
29
30 >$fail
31
32 git-cherry $linus $junio |
33 while read sign commit
34 do
35 case "$sign" in
36 -) continue ;;
37 esac
38 S=`cat "$GIT_DIR/HEAD"` &&
39 GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
40 git-commit-script -m "$commit" || {
41 echo $commit >>$fail
42 git-read-tree --reset -u $S
43 }
44 done
45 if test -s $fail
46 then
47 echo Some commits could not be rebased, check by hand:
48 cat $fail
49 fi