Reduce value duplication in t9300-fast-import.
[gitweb.git] / git-rebase.sh
index 5c7c4a69019ec866fc2dd4e38b9523aa7e4f20df..98f9558145f269e05e121006a5853368f0572abf 100755 (executable)
@@ -29,6 +29,7 @@ Example:       git-rebase master~1 topic
 '
 . git-sh-setup
 set_reflog_action rebase
+require_work_tree
 
 RESOLVEMSG="
 When you have resolved this problem run \"git rebase --continue\".
@@ -81,10 +82,18 @@ continue_merge () {
 call_merge () {
        cmt="$(cat $dotest/cmt.$1)"
        echo "$cmt" > "$dotest/current"
-       git-merge-$strategy "$cmt^" -- HEAD "$cmt"
+       hd=$(git-rev-parse --verify HEAD)
+       cmt_name=$(git-symbolic-ref HEAD)
+       msgnum=$(cat $dotest/msgnum)
+       end=$(cat $dotest/end)
+       eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
+       eval GITHEAD_$hd='"$(cat $dotest/onto_name)"'
+       export GITHEAD_$cmt GITHEAD_$hd
+       git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
        rv=$?
        case "$rv" in
        0)
+               unset GITHEAD_$cmt GITHEAD_$hd
                return
                ;;
        1)
@@ -314,6 +323,7 @@ fi
 
 mkdir -p "$dotest"
 echo "$onto" > "$dotest/onto"
+echo "$onto_name" > "$dotest/onto_name"
 prev_head=`git-rev-parse HEAD^0`
 echo "$prev_head" > "$dotest/prev_head"