Documentation: indent-with-non-tab uses "equivalent tabs" not 8
[git.git] / git-rebase--interactive.sh
index 45addba1b0ddd1ab0521e6034bcc2497951d66fe..a09e8423ddb1d05c581ef72101c3f5201ce2eeb9 100644 (file)
@@ -9,9 +9,7 @@
 #
 # The original idea comes from Eric W. Biederman, in
 # http://article.gmane.org/gmane.comp.version-control.git/22407
-
-. git-sh-setup
-
+#
 # The file containing rebase commands, comments, and empty lines.
 # This file is created by "git rebase -i" then edited by the user.  As
 # the lines are processed, they are removed from the front of this
@@ -571,11 +569,10 @@ do_next () {
        test -s "$todo" && return
 
        comment_for_reflog finish &&
-       shortonto=$(git rev-parse --short $onto) &&
        newhead=$(git rev-parse HEAD) &&
        case $head_name in
        refs/*)
-               message="$GIT_REFLOG_ACTION: $head_name onto $shortonto" &&
+               message="$GIT_REFLOG_ACTION: $head_name onto $onto" &&
                git update-ref -m "$message" $head_name $newhead $orig_head &&
                git symbolic-ref \
                  -m "$GIT_REFLOG_ACTION: returning to $head_name" \
@@ -707,6 +704,27 @@ rearrange_squash () {
        rm -f "$1.sq" "$1.rearranged"
 }
 
+# Add commands after a pick or after a squash/fixup serie
+# in the todo list.
+add_exec_commands () {
+       {
+               first=t
+               while read -r insn rest
+               do
+                       case $insn in
+                       pick)
+                               test -n "$first" ||
+                               printf "%s" "$cmd"
+                               ;;
+                       esac
+                       printf "%s %s\n" "$insn" "$rest"
+                       first=
+               done
+               printf "%s" "$cmd"
+       } <"$1" >"$1.new" &&
+       mv "$1.new" "$1"
+}
+
 case "$action" in
 continue)
        # do we have anything to commit?
@@ -878,6 +896,8 @@ fi
 
 test -s "$todo" || echo noop >> "$todo"
 test -n "$autosquash" && rearrange_squash "$todo"
+test -n "$cmd" && add_exec_commands "$todo"
+
 cat >> "$todo" << EOF
 
 # Rebase $shortrevisions onto $shortonto