bash prompt: print unique detached HEAD abbreviated object name
[gitweb.git] / git-rebase--interactive.sh
index 048a140a6f6dd565a0d0d98b3b41439298626a96..f953d8d22499b9e41d3c0ed86183655e39d807af 100644 (file)
@@ -57,6 +57,9 @@ rewritten="$state_dir"/rewritten
 
 dropped="$state_dir"/dropped
 
+end="$state_dir"/end
+msgnum="$state_dir"/msgnum
+
 # A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
 # GIT_AUTHOR_DATE that will be used for the commit that is currently
 # being rebased.
@@ -109,7 +112,9 @@ mark_action_done () {
        sed -e 1d < "$todo" >> "$todo".new
        mv -f "$todo".new "$todo"
        new_count=$(git stripspace --strip-comments <"$done" | wc -l)
+       echo $new_count >"$msgnum"
        total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l)))
+       echo $total >"$end"
        if test "$last_count" != "$new_count"
        then
                last_count=$new_count
@@ -623,17 +628,16 @@ do_next () {
                "$GIT_DIR"/hooks/post-rewrite rebase < "$rewritten_list"
                true # we don't care if this hook failed
        fi &&
-       rm -rf "$state_dir" &&
-       git gc --auto &&
        warn "Successfully rebased and updated $head_name."
 
-       exit
+       return 1 # not failure; just to break the do_rest loop
 }
 
+# can only return 0, when the infinite loop breaks
 do_rest () {
        while :
        do
-               do_next
+               do_next || break
        done
 }
 
@@ -800,11 +804,13 @@ first and then run 'git rebase --continue' again."
 
        require_clean_work_tree "rebase"
        do_rest
+       return 0
        ;;
 skip)
        git rerere clear
 
        do_rest
+       return 0
        ;;
 edit-todo)
        git stripspace --strip-comments <"$todo" >"$todo".new
@@ -837,7 +843,7 @@ then
 fi
 
 orig_head=$(git rev-parse --verify HEAD) || die "No HEAD?"
-mkdir "$state_dir" || die "Could not create temporary $state_dir"
+mkdir -p "$state_dir" || die "Could not create temporary $state_dir"
 
 : > "$state_dir"/interactive || die "Could not mark as interactive"
 write_basic_state