3 # Copyright (c) 2010 Junio C Hamano.
9 onto_name
=$
(cat "$state_dir"/onto_name
) &&
10 end
=$
(cat "$state_dir"/end
) &&
11 msgnum
=$
(cat "$state_dir"/msgnum
)
15 test -d "$state_dir" || die
"$state_dir directory does not exist"
17 unmerged
=$
(git ls-files
-u)
18 if test -n "$unmerged"
20 echo "You still have unmerged paths in your index"
21 echo "did you forget to use git add?"
25 cmt
=`cat "$state_dir/current"`
26 if ! git diff-index
--quiet --ignore-submodules HEAD
--
28 if ! git commit
--no-verify -C "$cmt"
30 echo "Commit failed, please do not call \"git commit\""
31 echo "directly, but instead do one of the following: "
34 if test -z "$GIT_QUIET"
36 printf "Committed: %0${prec}d " $msgnum
38 echo "$cmt $(git rev-parse HEAD^0)" >> "$state_dir/rewritten"
40 if test -z "$GIT_QUIET"
42 printf "Already applied: %0${prec}d " $msgnum
45 test -z "$GIT_QUIET" &&
46 GIT_PAGER
='' git log
--format=%s
-1 "$cmt"
48 # onto the next patch:
49 msgnum
=$
(($msgnum + 1))
50 echo "$msgnum" >"$state_dir/msgnum"
54 cmt
="$(cat "$state_dir/cmt.
$1")"
55 echo "$cmt" > "$state_dir/current"
56 hd
=$
(git rev-parse
--verify HEAD
)
57 cmt_name
=$
(git symbolic-ref HEAD
2> /dev
/null ||
echo HEAD
)
58 msgnum
=$
(cat "$state_dir/msgnum")
59 eval GITHEAD_
$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
60 eval GITHEAD_
$hd='$onto_name'
61 export GITHEAD_
$cmt GITHEAD_
$hd
62 if test -n "$GIT_QUIET"
64 GIT_MERGE_VERBOSITY
=1 && export GIT_MERGE_VERBOSITY
66 test -z "$strategy" && strategy
=recursive
67 eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
71 unset GITHEAD_
$cmt GITHEAD_
$hd
75 git rerere
$allow_rerere_autoupdate
79 echo "Strategy: $strategy failed, try another" 1>&2
83 die
"Unknown exit code ($rv) from command:" \
84 "git-merge-$strategy $cmt^ -- HEAD $cmt"
90 move_to_original_branch
91 if test -s "$state_dir"/rewritten
93 git notes copy
--for-rewrite=rebase
<"$state_dir"/rewritten
94 if test -x "$GIT_DIR"/hooks
/post-rewrite
96 "$GIT_DIR"/hooks
/post-rewrite rebase
<"$state_dir"/rewritten
106 while test "$msgnum" -le "$end"
117 msgnum
=$
(($msgnum + 1))
118 while test "$msgnum" -le "$end"
128 mkdir
-p "$state_dir"
129 echo "$onto_name" > "$state_dir/onto_name"
133 for cmt
in `git rev-list --reverse --no-merges "$revisions"`
135 msgnum
=$
(($msgnum + 1))
136 echo "$cmt" > "$state_dir/cmt.$msgnum"
139 echo 1 >"$state_dir/msgnum"
140 echo $msgnum >"$state_dir/end"
145 while test "$msgnum" -le "$end"