[PATCH] Make get_sha1_basic() more careful
[git/repo.git] / git-rebase-script
blob7779813d11b92867219818de65a4cba50ca76758
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano.
6 . git-sh-setup-script || 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
11 upstream tree.'
13 case "$#,$1" in
14 1,*..*)
15 upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
16 set x "$upstream" "$ours"
17 shift ;;
18 esac
20 case "$#" in
21 1) upstream=`git-rev-parse --verify "$1"` &&
22 ours=`git-rev-parse --verify HEAD` || exit
24 2) upstream=`git-rev-parse --verify "$1"` &&
25 ours=`git-rev-parse --verify "$2"` || exit
27 *) echo >&2 "$usage"; exit 1 ;;
28 esac
30 git-read-tree -m -u $ours $upstream &&
31 echo "$upstream" >"$GIT_DIR/HEAD" || exit
33 tmp=.rebase-tmp$$
34 fail=$tmp-fail
35 trap "rm -rf $tmp-*" 0 1 2 3 15
37 >$fail
39 git-cherry $upstream $ours |
40 while read sign commit
42 case "$sign" in
43 -) continue ;;
44 esac
45 S=`cat "$GIT_DIR/HEAD"` &&
46 GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
47 git-commit-script -C "$commit" || {
48 echo $commit >>$fail
49 git-read-tree --reset -u $S
51 done
52 if test -s $fail
53 then
54 echo Some commits could not be rebased, check by hand:
55 cat $fail