Junio C Hamano | 59e6b23 | 2005-06-25 02:23:43 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano. |
| 4 | # |
| 5 | |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 6 | USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]' |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 7 | LONG_USAGE='git-rebase replaces <branch> with a new branch of the |
| 8 | same name. When the --onto option is provided the new branch starts |
| 9 | out with a HEAD equal to <newbase>, otherwise it is equal to <upstream> |
| 10 | It then attempts to create a new commit for each commit from the original |
| 11 | <branch> that does not exist in the <upstream> branch. |
Carl Worth | 69a60af | 2006-02-21 17:10:12 -0800 | [diff] [blame] | 12 | |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 13 | It is possible that a merge failure will prevent this process from being |
| 14 | completely automatic. You will have to resolve any such merge failure |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 15 | and run git rebase --continue. Another option is to bypass the commit |
| 16 | that caused the merge failure with git rebase --skip. To restore the |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 17 | original <branch> and remove the .git/rebase-apply working files, use the |
| 18 | command git rebase --abort instead. |
Carl Worth | 69a60af | 2006-02-21 17:10:12 -0800 | [diff] [blame] | 19 | |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 20 | Note that if <branch> is not specified on the command line, the |
SZEDER Gábor | 702088a | 2008-03-10 15:38:33 +0100 | [diff] [blame] | 21 | currently checked out branch is used. |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 22 | |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 23 | Example: git-rebase master~1 topic |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 24 | |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 25 | A---B---C topic A'\''--B'\''--C'\'' topic |
| 26 | / --> / |
| 27 | D---E---F---G master D---E---F---G master |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 28 | ' |
Junio C Hamano | 533b703 | 2007-01-12 12:52:03 -0800 | [diff] [blame] | 29 | |
| 30 | SUBDIRECTORY_OK=Yes |
Junio C Hamano | 8f321a3 | 2007-11-06 01:50:02 -0800 | [diff] [blame] | 31 | OPTIONS_SPEC= |
Junio C Hamano | ae2b0f1 | 2005-11-24 00:12:11 -0800 | [diff] [blame] | 32 | . git-sh-setup |
Shawn O. Pearce | f947413 | 2006-12-28 02:34:48 -0500 | [diff] [blame] | 33 | set_reflog_action rebase |
Shawn O. Pearce | 7eff28a | 2006-12-30 23:32:38 -0500 | [diff] [blame] | 34 | require_work_tree |
Junio C Hamano | 533b703 | 2007-01-12 12:52:03 -0800 | [diff] [blame] | 35 | cd_to_toplevel |
Junio C Hamano | 4282c4f | 2005-08-07 15:51:09 -0700 | [diff] [blame] | 36 | |
Nanako Shiraishi | c442765 | 2008-10-06 14:14:29 +0900 | [diff] [blame] | 37 | OK_TO_SKIP_PRE_REBASE= |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 38 | RESOLVEMSG=" |
| 39 | When you have resolved this problem run \"git rebase --continue\". |
| 40 | If you would prefer to skip this patch, instead run \"git rebase --skip\". |
| 41 | To restore the original branch and stop rebasing run \"git rebase --abort\". |
| 42 | " |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 43 | unset newbase |
Junio C Hamano | a06f678 | 2006-09-24 19:49:47 -0700 | [diff] [blame] | 44 | strategy=recursive |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 45 | do_merge= |
Johannes Schindelin | 28ed6e7 | 2008-07-16 03:33:44 +0200 | [diff] [blame] | 46 | dotest="$GIT_DIR"/rebase-merge |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 47 | prec=4 |
Robert Shearman | b758789 | 2006-10-03 17:29:31 +0100 | [diff] [blame] | 48 | verbose= |
Tor Arne Vestbø | a9c3821 | 2009-03-01 23:11:38 +0100 | [diff] [blame] | 49 | diffstat=$(git config --bool rebase.stat) |
Michael S. Tsirkin | 67dad68 | 2007-02-08 15:57:08 +0200 | [diff] [blame] | 50 | git_am_opt= |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 51 | rebase_root= |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 52 | force_rebase= |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 53 | |
| 54 | continue_merge () { |
| 55 | test -n "$prev_head" || die "prev_head must be defined" |
| 56 | test -d "$dotest" || die "$dotest directory does not exist" |
| 57 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 58 | unmerged=$(git ls-files -u) |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 59 | if test -n "$unmerged" |
| 60 | then |
| 61 | echo "You still have unmerged paths in your index" |
Jonas Fonseca | 9b07873 | 2007-06-02 19:59:49 +0200 | [diff] [blame] | 62 | echo "did you forget to use git add?" |
Eric Wong | 66eb64c | 2006-06-28 02:11:06 -0700 | [diff] [blame] | 63 | die "$RESOLVEMSG" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 64 | fi |
| 65 | |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 66 | cmt=`cat "$dotest/current"` |
Johannes Schindelin | 6848d58 | 2008-05-14 18:03:59 +0100 | [diff] [blame] | 67 | if ! git diff-index --quiet --ignore-submodules HEAD -- |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 68 | then |
Junio C Hamano | e637122 | 2008-03-16 00:50:22 -0700 | [diff] [blame] | 69 | if ! git commit --no-verify -C "$cmt" |
Eric Wong | f0ef059 | 2006-06-28 03:24:23 -0700 | [diff] [blame] | 70 | then |
| 71 | echo "Commit failed, please do not call \"git commit\"" |
| 72 | echo "directly, but instead do one of the following: " |
| 73 | die "$RESOLVEMSG" |
| 74 | fi |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 75 | if test -z "$GIT_QUIET" |
| 76 | then |
| 77 | printf "Committed: %0${prec}d " $msgnum |
| 78 | fi |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 79 | else |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 80 | if test -z "$GIT_QUIET" |
| 81 | then |
| 82 | printf "Already applied: %0${prec}d " $msgnum |
| 83 | fi |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 84 | fi |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 85 | if test -z "$GIT_QUIET" |
| 86 | then |
| 87 | git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //' |
| 88 | fi |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 89 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 90 | prev_head=`git rev-parse HEAD^0` |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 91 | # save the resulting commit so we can read-tree on it later |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 92 | echo "$prev_head" > "$dotest/prev_head" |
| 93 | |
| 94 | # onto the next patch: |
| 95 | msgnum=$(($msgnum + 1)) |
Junio C Hamano | 5887ac8 | 2006-06-22 01:44:54 -0700 | [diff] [blame] | 96 | echo "$msgnum" >"$dotest/msgnum" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | call_merge () { |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 100 | cmt="$(cat "$dotest/cmt.$1")" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 101 | echo "$cmt" > "$dotest/current" |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 102 | hd=$(git rev-parse --verify HEAD) |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 103 | cmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD) |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 104 | msgnum=$(cat "$dotest/msgnum") |
| 105 | end=$(cat "$dotest/end") |
Shawn O. Pearce | 0bb733c | 2006-12-28 02:34:56 -0500 | [diff] [blame] | 106 | eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 107 | eval GITHEAD_$hd='$(cat "$dotest/onto_name")' |
Shawn O. Pearce | 0bb733c | 2006-12-28 02:34:56 -0500 | [diff] [blame] | 108 | export GITHEAD_$cmt GITHEAD_$hd |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 109 | if test -n "$GIT_QUIET" |
| 110 | then |
| 111 | export GIT_MERGE_VERBOSITY=1 |
| 112 | fi |
Shawn O. Pearce | 0bb733c | 2006-12-28 02:34:56 -0500 | [diff] [blame] | 113 | git-merge-$strategy "$cmt^" -- "$hd" "$cmt" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 114 | rv=$? |
| 115 | case "$rv" in |
| 116 | 0) |
Shawn O. Pearce | 0bb733c | 2006-12-28 02:34:56 -0500 | [diff] [blame] | 117 | unset GITHEAD_$cmt GITHEAD_$hd |
Eric Wong | 9e4bc7d | 2006-06-24 18:29:48 -0700 | [diff] [blame] | 118 | return |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 119 | ;; |
| 120 | 1) |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 121 | git rerere |
Eric Wong | 66eb64c | 2006-06-28 02:11:06 -0700 | [diff] [blame] | 122 | die "$RESOLVEMSG" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 123 | ;; |
| 124 | 2) |
| 125 | echo "Strategy: $rv $strategy failed, try another" 1>&2 |
Eric Wong | 66eb64c | 2006-06-28 02:11:06 -0700 | [diff] [blame] | 126 | die "$RESOLVEMSG" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 127 | ;; |
| 128 | *) |
| 129 | die "Unknown exit code ($rv) from command:" \ |
| 130 | "git-merge-$strategy $cmt^ -- HEAD $cmt" |
| 131 | ;; |
| 132 | esac |
| 133 | } |
| 134 | |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 135 | move_to_original_branch () { |
| 136 | test -z "$head_name" && |
| 137 | head_name="$(cat "$dotest"/head-name)" && |
| 138 | onto="$(cat "$dotest"/onto)" && |
| 139 | orig_head="$(cat "$dotest"/orig-head)" |
| 140 | case "$head_name" in |
| 141 | refs/*) |
| 142 | message="rebase finished: $head_name onto $onto" |
| 143 | git update-ref -m "$message" \ |
| 144 | $head_name $(git rev-parse HEAD) $orig_head && |
| 145 | git symbolic-ref HEAD $head_name || |
| 146 | die "Could not move back to $head_name" |
| 147 | ;; |
| 148 | esac |
| 149 | } |
| 150 | |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 151 | finish_rb_merge () { |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 152 | move_to_original_branch |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 153 | rm -r "$dotest" |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 154 | say All done. |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Johannes Schindelin | 1b1dce4 | 2007-06-25 01:11:14 +0100 | [diff] [blame] | 157 | is_interactive () { |
Andreas Ericsson | f8cca01 | 2008-09-29 22:28:57 +0200 | [diff] [blame] | 158 | while test $# != 0 |
| 159 | do |
| 160 | case "$1" in |
| 161 | -i|--interactive) |
| 162 | interactive_rebase=explicit |
| 163 | break |
| 164 | ;; |
| 165 | -p|--preserve-merges) |
| 166 | interactive_rebase=implied |
| 167 | ;; |
| 168 | esac |
Johannes Schindelin | 1b1dce4 | 2007-06-25 01:11:14 +0100 | [diff] [blame] | 169 | shift |
Andreas Ericsson | f8cca01 | 2008-09-29 22:28:57 +0200 | [diff] [blame] | 170 | done |
| 171 | |
| 172 | if [ "$interactive_rebase" = implied ]; then |
| 173 | GIT_EDITOR=: |
| 174 | export GIT_EDITOR |
| 175 | fi |
| 176 | |
| 177 | test -n "$interactive_rebase" || test -f "$dotest"/interactive |
Johannes Schindelin | 1b1dce4 | 2007-06-25 01:11:14 +0100 | [diff] [blame] | 178 | } |
| 179 | |
Nanako Shiraishi | d70b4a8 | 2008-10-06 14:14:24 +0900 | [diff] [blame] | 180 | run_pre_rebase_hook () { |
Nanako Shiraishi | c442765 | 2008-10-06 14:14:29 +0900 | [diff] [blame] | 181 | if test -z "$OK_TO_SKIP_PRE_REBASE" && |
| 182 | test -x "$GIT_DIR/hooks/pre-rebase" |
Nanako Shiraishi | d70b4a8 | 2008-10-06 14:14:24 +0900 | [diff] [blame] | 183 | then |
Stephen Boyd | bc2bbc4 | 2009-06-14 16:08:56 -0700 | [diff] [blame] | 184 | "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || |
| 185 | die "The pre-rebase hook refused to rebase." |
Nanako Shiraishi | d70b4a8 | 2008-10-06 14:14:24 +0900 | [diff] [blame] | 186 | fi |
| 187 | } |
| 188 | |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 189 | test -f "$GIT_DIR"/rebase-apply/applying && |
| 190 | die 'It looks like git-am is in progress. Cannot rebase.' |
| 191 | |
Johannes Schindelin | 1b1dce4 | 2007-06-25 01:11:14 +0100 | [diff] [blame] | 192 | is_interactive "$@" && exec git-rebase--interactive "$@" |
| 193 | |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 194 | if test $# -eq 0 |
| 195 | then |
| 196 | test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage |
| 197 | test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing && |
| 198 | die 'A rebase is in progress, try --continue, --skip or --abort.' |
| 199 | die "No arguments given and $GIT_DIR/rebase-apply already exists." |
| 200 | fi |
| 201 | |
David Kastrup | 822f7c7 | 2007-09-23 22:42:08 +0200 | [diff] [blame] | 202 | while test $# != 0 |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 203 | do |
| 204 | case "$1" in |
Nanako Shiraishi | c442765 | 2008-10-06 14:14:29 +0900 | [diff] [blame] | 205 | --no-verify) |
| 206 | OK_TO_SKIP_PRE_REBASE=yes |
| 207 | ;; |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 208 | --continue) |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 209 | test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || |
Stephan Beyer | cd5320f | 2008-06-22 16:07:02 +0200 | [diff] [blame] | 210 | die "No rebase in progress?" |
| 211 | |
Johannes Schindelin | 6848d58 | 2008-05-14 18:03:59 +0100 | [diff] [blame] | 212 | git diff-files --quiet --ignore-submodules || { |
Alex Riesen | 06aff47 | 2007-03-25 01:56:13 +0100 | [diff] [blame] | 213 | echo "You must edit all merge conflicts and then" |
Jonas Fonseca | 9b07873 | 2007-06-02 19:59:49 +0200 | [diff] [blame] | 214 | echo "mark them as resolved using git add" |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 215 | exit 1 |
Alex Riesen | 06aff47 | 2007-03-25 01:56:13 +0100 | [diff] [blame] | 216 | } |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 217 | if test -d "$dotest" |
| 218 | then |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 219 | prev_head=$(cat "$dotest/prev_head") |
| 220 | end=$(cat "$dotest/end") |
| 221 | msgnum=$(cat "$dotest/msgnum") |
| 222 | onto=$(cat "$dotest/onto") |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 223 | GIT_QUIET=$(cat "$dotest/quiet") |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 224 | continue_merge |
| 225 | while test "$msgnum" -le "$end" |
| 226 | do |
| 227 | call_merge "$msgnum" |
| 228 | continue_merge |
| 229 | done |
| 230 | finish_rb_merge |
| 231 | exit |
| 232 | fi |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 233 | head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && |
| 234 | onto=$(cat "$GIT_DIR"/rebase-apply/onto) && |
| 235 | orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 236 | GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet) |
Johannes Schindelin | 3f735b6 | 2007-11-12 13:11:46 +0000 | [diff] [blame] | 237 | git am --resolved --3way --resolvemsg="$RESOLVEMSG" && |
| 238 | move_to_original_branch |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 239 | exit |
| 240 | ;; |
| 241 | --skip) |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 242 | test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || |
Stephan Beyer | cd5320f | 2008-06-22 16:07:02 +0200 | [diff] [blame] | 243 | die "No rebase in progress?" |
| 244 | |
Mike Hommey | fb6e4e1 | 2007-11-08 08:03:06 +0100 | [diff] [blame] | 245 | git reset --hard HEAD || exit $? |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 246 | if test -d "$dotest" |
| 247 | then |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 248 | git rerere clear |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 249 | prev_head=$(cat "$dotest/prev_head") |
| 250 | end=$(cat "$dotest/end") |
| 251 | msgnum=$(cat "$dotest/msgnum") |
Eric Wong | d5e673b | 2006-06-24 18:29:49 -0700 | [diff] [blame] | 252 | msgnum=$(($msgnum + 1)) |
Jonathan del Strother | 889a50e | 2007-10-17 10:31:35 +0100 | [diff] [blame] | 253 | onto=$(cat "$dotest/onto") |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 254 | GIT_QUIET=$(cat "$dotest/quiet") |
Eric Wong | d5e673b | 2006-06-24 18:29:49 -0700 | [diff] [blame] | 255 | while test "$msgnum" -le "$end" |
| 256 | do |
| 257 | call_merge "$msgnum" |
| 258 | continue_merge |
| 259 | done |
| 260 | finish_rb_merge |
| 261 | exit |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 262 | fi |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 263 | head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && |
| 264 | onto=$(cat "$GIT_DIR"/rebase-apply/onto) && |
| 265 | orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 266 | GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet) |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 267 | git am -3 --skip --resolvemsg="$RESOLVEMSG" && |
| 268 | move_to_original_branch |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 269 | exit |
| 270 | ;; |
| 271 | --abort) |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 272 | test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || |
Stephan Beyer | cd5320f | 2008-06-22 16:07:02 +0200 | [diff] [blame] | 273 | die "No rebase in progress?" |
| 274 | |
Johannes Schindelin | b4372ef | 2007-07-06 13:05:59 +0100 | [diff] [blame] | 275 | git rerere clear |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 276 | if test -d "$dotest" |
| 277 | then |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 278 | GIT_QUIET=$(cat "$dotest/quiet") |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 279 | move_to_original_branch |
Stephan Beyer | cd5320f | 2008-06-22 16:07:02 +0200 | [diff] [blame] | 280 | else |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 281 | dotest="$GIT_DIR"/rebase-apply |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 282 | GIT_QUIET=$(cat "$dotest/quiet") |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 283 | move_to_original_branch |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 284 | fi |
Bryan Donlan | 97b88dd | 2008-05-04 01:37:51 -0400 | [diff] [blame] | 285 | git reset --hard $(cat "$dotest/orig-head") |
Mike Hommey | 48411d2 | 2008-03-01 11:32:14 +0100 | [diff] [blame] | 286 | rm -r "$dotest" |
sean | 031321c | 2006-04-26 10:49:38 -0400 | [diff] [blame] | 287 | exit |
| 288 | ;; |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 289 | --onto) |
| 290 | test 2 -le "$#" || usage |
| 291 | newbase="$2" |
| 292 | shift |
| 293 | ;; |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 294 | -M|-m|--m|--me|--mer|--merg|--merge) |
| 295 | do_merge=t |
| 296 | ;; |
| 297 | -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ |
| 298 | --strateg=*|--strategy=*|\ |
| 299 | -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) |
| 300 | case "$#,$1" in |
| 301 | *,*=*) |
Dennis Stosberg | 8096fae | 2006-06-27 18:54:26 +0200 | [diff] [blame] | 302 | strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 303 | 1,*) |
| 304 | usage ;; |
| 305 | *) |
| 306 | strategy="$2" |
| 307 | shift ;; |
| 308 | esac |
| 309 | do_merge=t |
| 310 | ;; |
Tor Arne Vestbø | a9c3821 | 2009-03-01 23:11:38 +0100 | [diff] [blame] | 311 | -n|--no-stat) |
| 312 | diffstat= |
| 313 | ;; |
| 314 | --stat) |
| 315 | diffstat=t |
| 316 | ;; |
Robert Shearman | b758789 | 2006-10-03 17:29:31 +0100 | [diff] [blame] | 317 | -v|--verbose) |
| 318 | verbose=t |
Tor Arne Vestbø | a9c3821 | 2009-03-01 23:11:38 +0100 | [diff] [blame] | 319 | diffstat=t |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 320 | GIT_QUIET= |
| 321 | ;; |
| 322 | -q|--quiet) |
| 323 | GIT_QUIET=t |
| 324 | git_am_opt="$git_am_opt -q" |
| 325 | verbose= |
| 326 | diffstat= |
Robert Shearman | b758789 | 2006-10-03 17:29:31 +0100 | [diff] [blame] | 327 | ;; |
J. Bruce Fields | 059f446 | 2007-09-07 10:20:50 -0400 | [diff] [blame] | 328 | --whitespace=*) |
| 329 | git_am_opt="$git_am_opt $1" |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 330 | case "$1" in |
| 331 | --whitespace=fix|--whitespace=strip) |
| 332 | force_rebase=t |
| 333 | ;; |
| 334 | esac |
J. Bruce Fields | 059f446 | 2007-09-07 10:20:50 -0400 | [diff] [blame] | 335 | ;; |
Michele Ballabio | 570ccad | 2009-03-18 21:53:49 +0100 | [diff] [blame] | 336 | --committer-date-is-author-date|--ignore-date) |
| 337 | git_am_opt="$git_am_opt $1" |
| 338 | force_rebase=t |
| 339 | ;; |
Michael S. Tsirkin | 67dad68 | 2007-02-08 15:57:08 +0200 | [diff] [blame] | 340 | -C*) |
J. Bruce Fields | 059f446 | 2007-09-07 10:20:50 -0400 | [diff] [blame] | 341 | git_am_opt="$git_am_opt $1" |
Michael S. Tsirkin | 67dad68 | 2007-02-08 15:57:08 +0200 | [diff] [blame] | 342 | ;; |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 343 | --root) |
| 344 | rebase_root=t |
| 345 | ;; |
Michele Ballabio | 3f7d992 | 2009-03-18 19:05:56 +0100 | [diff] [blame] | 346 | -f|--f|--fo|--for|--forc|force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase) |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 347 | force_rebase=t |
| 348 | ;; |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 349 | -*) |
| 350 | usage |
| 351 | ;; |
| 352 | *) |
| 353 | break |
| 354 | ;; |
| 355 | esac |
| 356 | shift |
| 357 | done |
Jay Soffian | 51b2ead | 2009-02-18 08:44:02 -0500 | [diff] [blame] | 358 | test $# -gt 2 && usage |
Junio C Hamano | 2db8aae | 2005-12-14 03:11:37 -0800 | [diff] [blame] | 359 | |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 360 | # Make sure we do not have $GIT_DIR/rebase-apply |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 361 | if test -z "$do_merge" |
Junio C Hamano | 7f4bd5d | 2005-11-28 13:00:31 -0800 | [diff] [blame] | 362 | then |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 363 | if mkdir "$GIT_DIR"/rebase-apply 2>/dev/null |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 364 | then |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 365 | rmdir "$GIT_DIR"/rebase-apply |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 366 | else |
| 367 | echo >&2 ' |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 368 | It seems that I cannot create a rebase-apply directory, and |
| 369 | I wonder if you are in the middle of patch application or another |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 370 | rebase. If that is not the case, please |
| 371 | rm -fr '"$GIT_DIR"'/rebase-apply |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 372 | and run me again. I am stopping in case you still have something |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 373 | valuable there.' |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 374 | exit 1 |
| 375 | fi |
| 376 | else |
| 377 | if test -d "$dotest" |
| 378 | then |
Johannes Schindelin | 28ed6e7 | 2008-07-16 03:33:44 +0200 | [diff] [blame] | 379 | die "previous rebase directory $dotest still exists." \ |
Stephan Beyer | 9b752a6 | 2008-08-17 06:25:43 +0200 | [diff] [blame] | 380 | 'Try git rebase (--continue | --abort | --skip)' |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 381 | fi |
Junio C Hamano | 7f4bd5d | 2005-11-28 13:00:31 -0800 | [diff] [blame] | 382 | fi |
| 383 | |
Junio C Hamano | 7f59dbb | 2005-11-14 00:41:53 -0800 | [diff] [blame] | 384 | # The tree must be really really clean. |
Jeff King | 07e62b7 | 2008-12-10 04:25:19 -0500 | [diff] [blame] | 385 | if ! git update-index --ignore-submodules --refresh; then |
Stephen Boyd | bc2bbc4 | 2009-06-14 16:08:56 -0700 | [diff] [blame] | 386 | die "cannot rebase: you have unstaged changes" |
Jeff King | 07e62b7 | 2008-12-10 04:25:19 -0500 | [diff] [blame] | 387 | fi |
Johannes Schindelin | 6848d58 | 2008-05-14 18:03:59 +0100 | [diff] [blame] | 388 | diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --) |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 389 | case "$diff" in |
Jeff King | 07e62b7 | 2008-12-10 04:25:19 -0500 | [diff] [blame] | 390 | ?*) echo >&2 "cannot rebase: your index contains uncommitted changes" |
| 391 | echo >&2 "$diff" |
Junio C Hamano | 7f59dbb | 2005-11-14 00:41:53 -0800 | [diff] [blame] | 392 | exit 1 |
| 393 | ;; |
Junio C Hamano | 59e6b23 | 2005-06-25 02:23:43 -0700 | [diff] [blame] | 394 | esac |
| 395 | |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 396 | if test -z "$rebase_root" |
| 397 | then |
| 398 | # The upstream head must be given. Make sure it is valid. |
| 399 | upstream_name="$1" |
| 400 | shift |
| 401 | upstream=`git rev-parse --verify "${upstream_name}^0"` || |
| 402 | die "invalid upstream $upstream_name" |
| 403 | unset root_flag |
| 404 | upstream_arg="$upstream_name" |
| 405 | else |
| 406 | test -z "$newbase" && die "--root must be used with --onto" |
| 407 | unset upstream_name |
| 408 | unset upstream |
| 409 | root_flag="--root" |
| 410 | upstream_arg="$root_flag" |
| 411 | fi |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 412 | |
Junio C Hamano | a1bf91e | 2007-03-22 02:54:59 -0700 | [diff] [blame] | 413 | # Make sure the branch to rebase onto is valid. |
| 414 | onto_name=${newbase-"$upstream_name"} |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 415 | onto=$(git rev-parse --verify "${onto_name}^0") || exit |
Junio C Hamano | a1bf91e | 2007-03-22 02:54:59 -0700 | [diff] [blame] | 416 | |
Junio C Hamano | 9a111c9 | 2006-02-12 23:17:04 -0800 | [diff] [blame] | 417 | # If a hook exists, give it a chance to interrupt |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 418 | run_pre_rebase_hook "$upstream_arg" "$@" |
Junio C Hamano | 9a111c9 | 2006-02-12 23:17:04 -0800 | [diff] [blame] | 419 | |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 420 | # If the branch to rebase is given, that is the branch we will rebase |
| 421 | # $branch_name -- branch being rebased, or HEAD (already detached) |
| 422 | # $orig_head -- commit object name of tip of the branch before rebasing |
| 423 | # $head_name -- refs/heads/<that-branch> or "detached HEAD" |
| 424 | switch_to= |
Junio C Hamano | 7f59dbb | 2005-11-14 00:41:53 -0800 | [diff] [blame] | 425 | case "$#" in |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 426 | 1) |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 427 | # Is it "rebase other $branchname" or "rebase other $commit"? |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 428 | branch_name="$1" |
| 429 | switch_to="$1" |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 430 | |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 431 | if git show-ref --verify --quiet -- "refs/heads/$1" && |
| 432 | branch=$(git rev-parse -q --verify "refs/heads/$1") |
Junio C Hamano | bcf3161 | 2007-01-20 19:11:29 -0800 | [diff] [blame] | 433 | then |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 434 | head_name="refs/heads/$1" |
| 435 | elif branch=$(git rev-parse -q --verify "$1") |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 436 | then |
| 437 | head_name="detached HEAD" |
Junio C Hamano | bcf3161 | 2007-01-20 19:11:29 -0800 | [diff] [blame] | 438 | else |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 439 | usage |
Junio C Hamano | bcf3161 | 2007-01-20 19:11:29 -0800 | [diff] [blame] | 440 | fi |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 441 | ;; |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 442 | *) |
| 443 | # Do not need to switch branches, we are already on it. |
| 444 | if branch_name=`git symbolic-ref -q HEAD` |
| 445 | then |
| 446 | head_name=$branch_name |
| 447 | branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` |
| 448 | else |
| 449 | head_name="detached HEAD" |
| 450 | branch_name=HEAD ;# detached |
| 451 | fi |
| 452 | branch=$(git rev-parse --verify "${branch_name}^0") || exit |
| 453 | ;; |
Junio C Hamano | 7f59dbb | 2005-11-14 00:41:53 -0800 | [diff] [blame] | 454 | esac |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 455 | orig_head=$branch |
Junio C Hamano | 99a92f9 | 2005-08-17 15:19:57 -0700 | [diff] [blame] | 456 | |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 457 | # Now we are rebasing commits $upstream..$branch (or with --root, |
| 458 | # everything leading up to $branch) on top of $onto |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 459 | |
Johannes Sixt | 1308c17 | 2007-07-04 22:09:10 +0200 | [diff] [blame] | 460 | # Check if we are already based on $onto with linear history, |
| 461 | # but this should be done only when upstream and onto are the same. |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 462 | mb=$(git merge-base "$onto" "$branch") |
Johannes Sixt | 1308c17 | 2007-07-04 22:09:10 +0200 | [diff] [blame] | 463 | if test "$upstream" = "$onto" && test "$mb" = "$onto" && |
| 464 | # linear history? |
Jeff King | bbf0812 | 2008-05-14 00:01:22 -0400 | [diff] [blame] | 465 | ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null |
Junio C Hamano | 7f4bd5d | 2005-11-28 13:00:31 -0800 | [diff] [blame] | 466 | then |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 467 | if test -z "$force_rebase" |
| 468 | then |
| 469 | # Lazily switch to the target branch if needed... |
| 470 | test -z "$switch_to" || git checkout "$switch_to" |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 471 | say "Current branch $branch_name is up to date." |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 472 | exit 0 |
| 473 | else |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 474 | say "Current branch $branch_name is up to date, rebase forced." |
Sverre Rabbelier | b2f82e0 | 2009-02-13 23:48:01 +0100 | [diff] [blame] | 475 | fi |
Junio C Hamano | 7f4bd5d | 2005-11-28 13:00:31 -0800 | [diff] [blame] | 476 | fi |
| 477 | |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 478 | # Detach HEAD and reset the tree |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 479 | say "First, rewinding head to replay your work on top of it..." |
Junio C Hamano | 324c2c3 | 2008-07-14 14:05:35 -0700 | [diff] [blame] | 480 | git checkout -q "$onto^0" || die "could not detach HEAD" |
Junio C Hamano | 22e4079 | 2008-07-07 00:16:38 -0700 | [diff] [blame] | 481 | git update-ref ORIG_HEAD $branch |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 482 | |
Tor Arne Vestbø | a9c3821 | 2009-03-01 23:11:38 +0100 | [diff] [blame] | 483 | if test -n "$diffstat" |
| 484 | then |
| 485 | if test -n "$verbose" |
| 486 | then |
| 487 | echo "Changes from $mb to $onto:" |
| 488 | fi |
| 489 | # We want color (if set), but no pager |
| 490 | GIT_PAGER='' git diff --stat --summary "$mb" "$onto" |
| 491 | fi |
| 492 | |
Junio C Hamano | e646c9c | 2006-02-14 14:42:05 -0800 | [diff] [blame] | 493 | # If the $onto is a proper descendant of the tip of the branch, then |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 494 | # we just fast forwarded. |
Robert Shearman | 83c3161 | 2006-07-27 10:32:25 +0100 | [diff] [blame] | 495 | if test "$mb" = "$branch" |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 496 | then |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 497 | say "Fast-forwarded $branch_name to $onto_name." |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 498 | move_to_original_branch |
Lukas Sandström | 32d9954 | 2005-12-15 00:36:35 +0100 | [diff] [blame] | 499 | exit 0 |
| 500 | fi |
| 501 | |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 502 | if test -n "$rebase_root" |
| 503 | then |
| 504 | revisions="$onto..$orig_head" |
| 505 | else |
| 506 | revisions="$upstream..$orig_head" |
| 507 | fi |
| 508 | |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 509 | if test -z "$do_merge" |
| 510 | then |
Junio C Hamano | 0cb0664 | 2008-03-15 13:17:42 -0700 | [diff] [blame] | 511 | git format-patch -k --stdout --full-index --ignore-if-in-upstream \ |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 512 | $root_flag "$revisions" | |
Junio C Hamano | 3041c32 | 2008-03-04 00:25:06 -0800 | [diff] [blame] | 513 | git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" && |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 514 | move_to_original_branch |
| 515 | ret=$? |
Johannes Schindelin | 51ef1da | 2008-07-21 12:51:02 +0200 | [diff] [blame] | 516 | test 0 != $ret -a -d "$GIT_DIR"/rebase-apply && |
| 517 | echo $head_name > "$GIT_DIR"/rebase-apply/head-name && |
| 518 | echo $onto > "$GIT_DIR"/rebase-apply/onto && |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 519 | echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head && |
| 520 | echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 521 | exit $ret |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 522 | fi |
Sean | cc12005 | 2006-05-13 23:34:08 -0400 | [diff] [blame] | 523 | |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 524 | # start doing a rebase with git-merge |
| 525 | # this is rename-aware if the recursive (default) strategy is used |
| 526 | |
| 527 | mkdir -p "$dotest" |
| 528 | echo "$onto" > "$dotest/onto" |
Shawn O. Pearce | 0bb733c | 2006-12-28 02:34:56 -0500 | [diff] [blame] | 529 | echo "$onto_name" > "$dotest/onto_name" |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 530 | prev_head=$orig_head |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 531 | echo "$prev_head" > "$dotest/prev_head" |
Johannes Schindelin | 6fd2f5e | 2007-11-08 18:19:08 +0000 | [diff] [blame] | 532 | echo "$orig_head" > "$dotest/orig-head" |
| 533 | echo "$head_name" > "$dotest/head-name" |
Stephen Boyd | 0e987a1 | 2009-06-16 15:33:01 -0700 | [diff] [blame] | 534 | echo "$GIT_QUIET" > "$dotest/quiet" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 535 | |
| 536 | msgnum=0 |
Thomas Rast | 190f532 | 2009-01-05 18:35:16 +0100 | [diff] [blame] | 537 | for cmt in `git rev-list --reverse --no-merges "$revisions"` |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 538 | do |
| 539 | msgnum=$(($msgnum + 1)) |
Junio C Hamano | 5887ac8 | 2006-06-22 01:44:54 -0700 | [diff] [blame] | 540 | echo "$cmt" > "$dotest/cmt.$msgnum" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 541 | done |
| 542 | |
Junio C Hamano | 5887ac8 | 2006-06-22 01:44:54 -0700 | [diff] [blame] | 543 | echo 1 >"$dotest/msgnum" |
| 544 | echo $msgnum >"$dotest/end" |
Eric Wong | 58634db | 2006-06-21 03:04:41 -0700 | [diff] [blame] | 545 | |
| 546 | end=$msgnum |
| 547 | msgnum=1 |
| 548 | |
| 549 | while test "$msgnum" -le "$end" |
| 550 | do |
| 551 | call_merge "$msgnum" |
| 552 | continue_merge |
| 553 | done |
| 554 | |
| 555 | finish_rb_merge |