]> git.ipfire.org Git - thirdparty/git.git/blame - git-rebase.sh
Do not show .exe in git command list.
[thirdparty/git.git] / git-rebase.sh
CommitLineData
59e6b23a
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano.
4#
5
215a7ad1 6. git-sh-setup || die "Not a git archive."
4282c4fb 7
59e6b23a
JH
8usage="usage: $0 "'<upstream> [<head>]
9
10Uses output from git-cherry to rebase local commits to the new head of
11upstream tree.'
12
4282c4fb
JH
13case "$#,$1" in
141,*..*)
15 upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
16 set x "$upstream" "$ours"
17 shift ;;
18esac
59e6b23a 19
215a7ad1 20git-update-index --refresh || exit
99a92f92 21
59e6b23a 22case "$#" in
99a92f92
JH
231) ours_symbolic=HEAD ;;
242) ours_symbolic="$2" ;;
25*) die "$usage" ;;
59e6b23a
JH
26esac
27
99a92f92 28upstream=`git-rev-parse --verify "$1"` &&
66e06b6a 29ours=`git-rev-parse --verify "$ours_symbolic"` || exit
215a7ad1
JH
30different1=$(git-diff-index --name-only --cached "$ours") &&
31different2=$(git-diff-index --name-only "$ours") &&
a8055f8a 32test "$different1$different2" = "" ||
99a92f92
JH
33die "Your working tree does not match $ours_symbolic."
34
4282c4fb 35git-read-tree -m -u $ours $upstream &&
bf7960eb
JH
36new_head=$(git-rev-parse --verify "$upstream^0") &&
37git-update-ref HEAD "$new_head" || exit
59e6b23a
JH
38
39tmp=.rebase-tmp$$
40fail=$tmp-fail
48313592 41trap "rm -rf $tmp-*" 1 2 3 15
59e6b23a
JH
42
43>$fail
44
48313592
JH
45git-cherry -v $upstream $ours |
46while read sign commit msg
59e6b23a
JH
47do
48 case "$sign" in
48313592
JH
49 -)
50 echo >&2 "* Already applied: $msg"
51 continue ;;
59e6b23a 52 esac
48313592 53 echo >&2 "* Applying: $msg"
bf7960eb 54 S=$(git-rev-parse --verify HEAD) &&
215a7ad1 55 git-cherry-pick --replay $commit || {
48313592 56 echo >&2 "* Not applying the patch and continuing."
59e6b23a 57 echo $commit >>$fail
215a7ad1 58 git-reset --hard $S
59e6b23a
JH
59 }
60done
61if test -s $fail
62then
48313592
JH
63 echo >&2 Some commits could not be rebased, check by hand:
64 cat >&2 $fail
65 echo >&2 "(the same list of commits are found in $tmp)"
66 exit 1
67else
68 rm -f $fail
59e6b23a 69fi