From: Junio C Hamano Date: Wed, 1 May 2013 22:23:56 +0000 (-0700) Subject: Merge branch 'zk/prompt-rebase-step' X-Git-Tag: v1.8.3-rc1~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b9347eb224d7b38f29893e75b6ca16a61647a4f2?ds=inline;hp=-c Merge branch 'zk/prompt-rebase-step' * zk/prompt-rebase-step: bash-prompt.sh: show where rebase is at when stopped --- b9347eb224d7b38f29893e75b6ca16a61647a4f2 diff --combined contrib/completion/git-prompt.sh index 054c52e90a,eea3568e92..eaf5c369aa --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@@ -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 @@@ -308,6 -315,10 +315,10 @@@ } fi + if [ -n "$step" ] && [ -n "$total" ]; then + r="$r $step/$total" + fi + local w="" local i="" local s="" @@@ -340,7 -351,7 +351,7 @@@ [ "$(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 e147a8d277,c67bbc6be7..083b319ed1 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@@ -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" && ( @@@ -126,7 -130,7 +130,7 @@@ ' 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" && ( @@@ -137,7 -141,7 +141,7 @@@ ' 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 && @@@ -260,7 -266,7 +266,7 @@@ ' 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 && @@@ -270,7 -276,7 +276,7 @@@ ' 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 &&