Make git tag a builtin.
[gitweb.git] / git-rebase--interactive.sh
index 1a064af381acac60df01c89953a9a1fc727ea2ca..a2d4d09f5d3c5e87dfad639ed7502933d065b323 100755 (executable)
@@ -23,6 +23,9 @@ REWRITTEN="$DOTEST"/rewritten
 PRESERVE_MERGES=
 STRATEGY=
 VERBOSE=
+test -d "$REWRITTEN" && PRESERVE_MERGES=t
+test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
+test -f "$DOTEST"/verbose && VERBOSE=t
 
 warn () {
        echo "$*" >&2
@@ -81,6 +84,7 @@ pick_one () {
        current_sha1=$(git rev-parse --verify HEAD)
        if [ $current_sha1 = $parent_sha1 ]; then
                git reset --hard $sha1
+               test "a$1" = a-n && git reset --soft $current_sha1
                sha1=$(git rev-parse --short $sha1)
                warn Fast forward to $sha1
        else
@@ -190,14 +194,14 @@ do_next () {
                        die "Cannot 'squash' without a previous commit"
 
                mark_action_done
-               failed=f
-               pick_one -n $sha1 || failed=t
                MSG="$DOTEST"/message
                echo "# This is a combination of two commits." > "$MSG"
                echo "# The first commit's message is:" >> "$MSG"
                echo >> "$MSG"
                git cat-file commit HEAD | sed -e '1,/^$/d' >> "$MSG"
                echo >> "$MSG"
+               failed=f
+               pick_one -n $sha1 || failed=t
                echo "# And this is the 2nd commit message:" >> "$MSG"
                echo >> "$MSG"
                git cat-file commit $sha1 | sed -e '1,/^$/d' >> "$MSG"
@@ -366,6 +370,7 @@ do
                echo $HEAD > "$DOTEST"/head
                echo $UPSTREAM > "$DOTEST"/upstream
                echo $ONTO > "$DOTEST"/onto
+               test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
                test t = "$VERBOSE" && : > "$DOTEST"/verbose
                if [ t = "$PRESERVE_MERGES" ]
                then
@@ -397,6 +402,9 @@ do
 #  pick = use commit
 #  edit = use commit, but stop for amending
 #  squash = use commit, but meld into previous commit
+#
+# If you remove a line here THAT COMMIT WILL BE LOST.
+#
 EOF
                git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
                        --abbrev=7 --reverse $UPSTREAM..$HEAD | \
@@ -406,7 +414,7 @@ EOF
                        die_abort "Nothing to do"
 
                cp "$TODO" "$TODO".backup
-               ${VISUAL:-${EDITOR:-vi}} "$TODO" ||
+               git_editor "$TODO" ||
                        die "Could not execute editor"
 
                test -z "$(grep -ve '^$' -e '^#' < $TODO)" &&