Don't special-case a zero-sized compression.
[git/dscho.git] / git-rebase-script
blob10ab700d044d22509004182c5a5c55bafffc36d7
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano.
6 usage="usage: $0 "'<upstream> [<head>]
8 Uses output from git-cherry to rebase local commits to the new head of
9 upstream tree.'
11 : ${GIT_DIR=.git}
13 case "$#" in
14 1) linus=`git-rev-parse "$1"` &&
15 junio=`git-rev-parse HEAD` || exit
17 2) linus=`git-rev-parse "$1"` &&
18 junio=`git-rev-parse "$2"` || exit
20 *) echo >&2 "$usage"; exit 1 ;;
21 esac
23 git-read-tree -m -u $junio $linus &&
24 echo "$linus" >"$GIT_DIR/HEAD" || exit
26 tmp=.rebase-tmp$$
27 fail=$tmp-fail
28 trap "rm -rf $tmp-*" 0 1 2 3 15
30 >$fail
32 git-cherry $linus $junio |
33 while read sign commit
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
44 done
45 if test -s $fail
46 then
47 echo Some commits could not be rebased, check by hand:
48 cat $fail