Merge branch 'zk/prompt-rebase-step'

* zk/prompt-rebase-step:
  bash-prompt.sh: show where rebase is at when stopped
This commit is contained in:
Junio C Hamano 2013-05-01 15:23:56 -07:00
commit b9347eb224
3 changed files with 31 additions and 9 deletions

View file

@ -263,14 +263,21 @@ __git_ps1 ()
else else
local r="" local r=""
local b="" local b=""
if [ -f "$g/rebase-merge/interactive" ]; then local step=""
r="|REBASE-i" local total=""
b="$(cat "$g/rebase-merge/head-name")" if [ -d "$g/rebase-merge" ]; then
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")" b="$(cat "$g/rebase-merge/head-name")"
step=$(cat "$g/rebase-merge/msgnum")
total=$(cat "$g/rebase-merge/end")
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
else
r="|REBASE-m"
fi
else else
if [ -d "$g/rebase-apply" ]; then if [ -d "$g/rebase-apply" ]; then
step=$(cat "$g/rebase-apply/next")
total=$(cat "$g/rebase-apply/last")
if [ -f "$g/rebase-apply/rebasing" ]; then if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE" r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then elif [ -f "$g/rebase-apply/applying" ]; then
@ -308,6 +315,10 @@ __git_ps1 ()
} }
fi fi
if [ -n "$step" ] && [ -n "$total" ]; then
r="$r $step/$total"
fi
local w="" local w=""
local i="" local i=""
local s="" local s=""

View file

@ -57,6 +57,9 @@ rewritten="$state_dir"/rewritten
dropped="$state_dir"/dropped dropped="$state_dir"/dropped
end="$state_dir"/end
msgnum="$state_dir"/msgnum
# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and # 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 # GIT_AUTHOR_DATE that will be used for the commit that is currently
# being rebased. # being rebased.
@ -109,7 +112,9 @@ mark_action_done () {
sed -e 1d < "$todo" >> "$todo".new sed -e 1d < "$todo" >> "$todo".new
mv -f "$todo".new "$todo" mv -f "$todo".new "$todo"
new_count=$(git stripspace --strip-comments <"$done" | wc -l) new_count=$(git stripspace --strip-comments <"$done" | wc -l)
echo $new_count >"$msgnum"
total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l))) total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l)))
echo $total >"$end"
if test "$last_count" != "$new_count" if test "$last_count" != "$new_count"
then then
last_count=$new_count last_count=$new_count

View file

@ -28,6 +28,10 @@ test_expect_success 'setup for prompt tests' '
git checkout -b b2 master && git checkout -b b2 master &&
echo 0 > file && echo 0 > file &&
git commit -m "second b2" file && git commit -m "second b2" file &&
echo 00 > file &&
git commit -m "another b2" file &&
echo 000 > file &&
git commit -m "yet another b2" file &&
git checkout master git checkout master
' '
@ -243,10 +247,12 @@ test_expect_success 'prompt - inside bare repository' '
' '
test_expect_success 'prompt - interactive rebase' ' test_expect_success 'prompt - interactive rebase' '
printf " (b1|REBASE-i)" > expected printf " (b1|REBASE-i 2/3)" > expected
echo "#!$SHELL_PATH" >fake_editor.sh && echo "#!$SHELL_PATH" >fake_editor.sh &&
cat >>fake_editor.sh <<\EOF && cat >>fake_editor.sh <<\EOF &&
echo "edit $(git log -1 --format="%h")" > "$1" echo "exec echo" > "$1"
echo "edit $(git log -1 --format="%h")" >> "$1"
echo "exec echo" >> "$1"
EOF EOF
test_when_finished "rm -f fake_editor.sh" && test_when_finished "rm -f fake_editor.sh" &&
chmod a+x fake_editor.sh && chmod a+x fake_editor.sh &&
@ -260,7 +266,7 @@ EOF
' '
test_expect_success 'prompt - rebase merge' ' test_expect_success 'prompt - rebase merge' '
printf " (b2|REBASE-m)" > expected && printf " (b2|REBASE-m 1/3)" > expected &&
git checkout b2 && git checkout b2 &&
test_when_finished "git checkout master" && test_when_finished "git checkout master" &&
test_must_fail git rebase --merge b1 b2 && test_must_fail git rebase --merge b1 b2 &&
@ -270,7 +276,7 @@ test_expect_success 'prompt - rebase merge' '
' '
test_expect_success 'prompt - rebase' ' test_expect_success 'prompt - rebase' '
printf " ((t2)|REBASE)" > expected && printf " ((t2)|REBASE 1/3)" > expected &&
git checkout b2 && git checkout b2 &&
test_when_finished "git checkout master" && test_when_finished "git checkout master" &&
test_must_fail git rebase b1 b2 && test_must_fail git rebase b1 b2 &&