]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-rebase.sh
gitweb: correct month in date display for atom feeds
[git.git] / git-rebase.sh
index c5906611794adadfbd37463481412abae6f11a8f..b0c8ac1c8de8f72ad4ba341777513cf5dab7a935 100755 (executable)
@@ -59,20 +59,20 @@ continue_merge () {
                die "$RESOLVEMSG"
        fi
 
+       cmt=`cat "$dotest/current"`
        if ! git diff-index --quiet HEAD
        then
-               if ! git-commit -C "`cat $dotest/current`"
+               if ! git-commit -C "$cmt"
                then
                        echo "Commit failed, please do not call \"git commit\""
                        echo "directly, but instead do one of the following: "
                        die "$RESOLVEMSG"
                fi
-               printf "Committed: %0${prec}d" $msgnum
+               printf "Committed: %0${prec}d " $msgnum
        else
-               printf "Already applied: %0${prec}d" $msgnum
+               printf "Already applied: %0${prec}d " $msgnum
        fi
-       echo ' '`git rev-list --pretty=oneline -1 HEAD | \
-                               sed 's/^[a-f0-9]\+ //'`
+       git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
 
        prev_head=`git rev-parse HEAD^0`
        # save the resulting commit so we can read-tree on it later
@@ -84,14 +84,14 @@ continue_merge () {
 }
 
 call_merge () {
-       cmt="$(cat $dotest/cmt.$1)"
+       cmt="$(cat "$dotest/cmt.$1")"
        echo "$cmt" > "$dotest/current"
        hd=$(git rev-parse --verify HEAD)
        cmt_name=$(git symbolic-ref HEAD)
-       msgnum=$(cat $dotest/msgnum)
-       end=$(cat $dotest/end)
+       msgnum=$(cat "$dotest/msgnum")
+       end=$(cat "$dotest/end")
        eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
-       eval GITHEAD_$hd='"$(cat $dotest/onto_name)"'
+       eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
        export GITHEAD_$cmt GITHEAD_$hd
        git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
        rv=$?
@@ -101,7 +101,7 @@ call_merge () {
                return
                ;;
        1)
-               test -d "$GIT_DIR/rr-cache" && git rerere
+               git rerere
                die "$RESOLVEMSG"
                ;;
        2)
@@ -122,15 +122,14 @@ finish_rb_merge () {
 
 is_interactive () {
        test -f "$dotest"/interactive ||
-       while case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
-       do
+       while :; do case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac
                shift
        done && test -n "$1"
 }
 
 is_interactive "$@" && exec git-rebase--interactive "$@"
 
-while case "$#" in 0) break ;; esac
+while test $# != 0
 do
        case "$1" in
        --continue)
@@ -141,10 +140,10 @@ do
                }
                if test -d "$dotest"
                then
-                       prev_head="`cat $dotest/prev_head`"
-                       end="`cat $dotest/end`"
-                       msgnum="`cat $dotest/msgnum`"
-                       onto="`cat $dotest/onto`"
+                       prev_head=$(cat "$dotest/prev_head")
+                       end=$(cat "$dotest/end")
+                       msgnum=$(cat "$dotest/msgnum")
+                       onto=$(cat "$dotest/onto")
                        continue_merge
                        while test "$msgnum" -le "$end"
                        do
@@ -160,15 +159,12 @@ do
        --skip)
                if test -d "$dotest"
                then
-                       if test -d "$GIT_DIR/rr-cache"
-                       then
-                               git rerere clear
-                       fi
-                       prev_head="`cat $dotest/prev_head`"
-                       end="`cat $dotest/end`"
-                       msgnum="`cat $dotest/msgnum`"
+                       git rerere clear
+                       prev_head=$(cat "$dotest/prev_head")
+                       end=$(cat "$dotest/end")
+                       msgnum=$(cat "$dotest/msgnum")
                        msgnum=$(($msgnum + 1))
-                       onto="`cat $dotest/onto`"
+                       onto=$(cat "$dotest/onto")
                        while test "$msgnum" -le "$end"
                        do
                                call_merge "$msgnum"
@@ -181,10 +177,7 @@ do
                exit
                ;;
        --abort)
-               if test -d "$GIT_DIR/rr-cache"
-               then
-                       git rerere clear
-               fi
+               git rerere clear
                if test -d "$dotest"
                then
                        rm -r "$dotest"
@@ -305,10 +298,12 @@ branch=$(git rev-parse --verify "${branch_name}^0") || exit
 
 # Now we are rebasing commits $upstream..$branch on top of $onto
 
-# Check if we are already based on $onto, but this should be
-# done only when upstream and onto are the same.
+# Check if we are already based on $onto with linear history,
+# but this should be done only when upstream and onto are the same.
 mb=$(git merge-base "$onto" "$branch")
-if test "$upstream" = "$onto" && test "$mb" = "$onto"
+if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
+       # linear history?
+       ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null
 then
        echo >&2 "Current branch $branch_name is up to date."
        exit 0