Merge branch 'zk/prompt-rebase-step'
authorJunio C Hamano <gitster@pobox.com>
Wed, 1 May 2013 22:23:56 +0000 (15:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 May 2013 22:23:57 +0000 (15:23 -0700)
* zk/prompt-rebase-step:
bash-prompt.sh: show where rebase is at when stopped

1  2 
contrib/completion/git-prompt.sh
t/t9903-bash-prompt.sh
index 054c52e90aeabb9a9ab5d4f9ee38b0799126b338,eea3568e925a2fce7cc8c65148e4cf771317b532..eaf5c369aacde207cbad4c9df9574e7b26634bb7
@@@ -263,14 -263,21 +263,21 @@@ __git_ps1 (
        else
                local r=""
                local b=""
-               if [ -f "$g/rebase-merge/interactive" ]; then
-                       r="|REBASE-i"
-                       b="$(cat "$g/rebase-merge/head-name")"
-               elif [ -d "$g/rebase-merge" ]; then
-                       r="|REBASE-m"
+               local step=""
+               local total=""
+               if [ -d "$g/rebase-merge" ]; then
                        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
                        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
                                        r="|REBASE"
                                elif [ -f "$g/rebase-apply/applying" ]; then
                        }
                fi
  
+               if [ -n "$step" ] && [ -n "$total" ]; then
+                       r="$r $step/$total"
+               fi
                local w=""
                local i=""
                local s=""
                           [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
                           [ -n "$(git ls-files --others --exclude-standard)" ]
                        then
 -                              u="%"
 +                              u="%${ZSH_VERSION+%}"
                        fi
  
                        if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
diff --combined t/t9903-bash-prompt.sh
index e147a8d277af7948cf165ea93899e9020a961d7a,c67bbc6be774445f9922481a319b73219a57c01e..083b319ed11132ae03c1f653f1ba13149f5a1ebe
@@@ -28,6 -28,10 +28,10 @@@ test_expect_success 'setup for prompt t
        git checkout -b b2 master &&
        echo 0 > 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
  '
  
@@@ -59,7 -63,7 +63,7 @@@ test_expect_success 'gitdir - .git dire
  '
  
  test_expect_success 'gitdir - .git directory in parent' '
 -      echo "$TRASH_DIRECTORY/.git" > expected &&
 +      echo "$(pwd -P)/.git" > expected &&
        (
                cd subdir/subsubdir &&
                __gitdir > "$actual"
@@@ -77,7 -81,7 +81,7 @@@ test_expect_success 'gitdir - cwd is a 
  '
  
  test_expect_success 'gitdir - parent is a .git directory' '
 -      echo "$TRASH_DIRECTORY/.git" > expected &&
 +      echo "$(pwd -P)/.git" > expected &&
        (
                cd .git/refs/heads &&
                __gitdir > "$actual"
@@@ -115,7 -119,7 +119,7 @@@ test_expect_success 'gitdir - non-exist
  '
  
  test_expect_success 'gitdir - gitfile in cwd' '
 -      echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
 +      echo "$(pwd -P)/otherrepo/.git" > expected &&
        echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
        test_when_finished "rm -f subdir/.git" &&
        (
  '
  
  test_expect_success 'gitdir - gitfile in parent' '
 -      echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
 +      echo "$(pwd -P)/otherrepo/.git" > expected &&
        echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
        test_when_finished "rm -f subdir/.git" &&
        (
  '
  
  test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '
 -      echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
 +      echo "$(pwd -P)/otherrepo/.git" > expected &&
        mkdir otherrepo/dir &&
        test_when_finished "rm -rf otherrepo/dir" &&
        ln -s otherrepo/dir link &&
@@@ -243,10 -247,12 +247,12 @@@ test_expect_success 'prompt - inside ba
  '
  
  test_expect_success 'prompt - interactive rebase' '
-       printf " (b1|REBASE-i)" > expected
+       printf " (b1|REBASE-i 2/3)" > expected
        echo "#!$SHELL_PATH" >fake_editor.sh &&
        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
        test_when_finished "rm -f fake_editor.sh" &&
        chmod a+x fake_editor.sh &&
  '
  
  test_expect_success 'prompt - rebase merge' '
-       printf " (b2|REBASE-m)" > expected &&
+       printf " (b2|REBASE-m 1/3)" > expected &&
        git checkout b2 &&
        test_when_finished "git checkout master" &&
        test_must_fail git rebase --merge b1 b2 &&
  '
  
  test_expect_success 'prompt - rebase' '
-       printf " ((t2)|REBASE)" > expected &&
+       printf " ((t2)|REBASE 1/3)" > expected &&
        git checkout b2 &&
        test_when_finished "git checkout master" &&
        test_must_fail git rebase b1 b2 &&