* [PATCH] prompt: fix for simple rebase
@ 2013-05-29 6:21 Felipe Contreras
2013-05-29 18:26 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Felipe Contreras @ 2013-05-29 6:21 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Zoltan Klinger, Simon Oosthoek, Felipe Contreras
When we are rebasing without options ('am' mode), the head rebased lives
in '$g/rebase-apply/head-name', so lets use that information so it's
reported the same way as if we were doing other rebases (-i or -m).
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-prompt.sh | 2 ++
t/t9903-bash-prompt.sh | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index eaf5c36..bbf7657 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -279,6 +279,7 @@ __git_ps1 ()
step=$(cat "$g/rebase-apply/next")
total=$(cat "$g/rebase-apply/last")
if [ -f "$g/rebase-apply/rebasing" ]; then
+ b="$(cat "$g/rebase-apply/head-name")"
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
@@ -295,6 +296,7 @@ __git_ps1 ()
r="|BISECTING"
fi
+ test -n "$b" ||
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
detached=yes
b="$(
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 083b319..15521cc 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -276,7 +276,7 @@ test_expect_success 'prompt - rebase merge' '
'
test_expect_success 'prompt - rebase' '
- printf " ((t2)|REBASE 1/3)" > expected &&
+ printf " (b2|REBASE 1/3)" > expected &&
git checkout b2 &&
test_when_finished "git checkout master" &&
test_must_fail git rebase b1 b2 &&
--
1.8.3.rc3.312.g47657de
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] prompt: fix for simple rebase
2013-05-29 6:21 [PATCH] prompt: fix for simple rebase Felipe Contreras
@ 2013-05-29 18:26 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2013-05-29 18:26 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git, Zoltan Klinger, Simon Oosthoek
Felipe Contreras <felipe.contreras@gmail.com> writes:
> When we are rebasing without options ('am' mode), the head rebased lives
> in '$g/rebase-apply/head-name', so lets use that information so it's
> reported the same way as if we were doing other rebases (-i or -m).
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> contrib/completion/git-prompt.sh | 2 ++
> t/t9903-bash-prompt.sh | 2 +-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index eaf5c36..bbf7657 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -279,6 +279,7 @@ __git_ps1 ()
> step=$(cat "$g/rebase-apply/next")
> total=$(cat "$g/rebase-apply/last")
> if [ -f "$g/rebase-apply/rebasing" ]; then
> + b="$(cat "$g/rebase-apply/head-name")"
> r="|REBASE"
> elif [ -f "$g/rebase-apply/applying" ]; then
> r="|AM"
Looks correct to me, and the resulting behaviour is better
I wonder if the overall structure can be improved on top of this
change, though.
if [ -d rebase-merge ]; then
set b, step, total and r to show REBASE-kind stuff
else
if [ -d rebase-apply]; then
set step, total and r to show AM,
but if rebasing is there, show REBASE
elif ...
handle all the other non rebase state
elif ...
in many different elif-then pieces
fi
if $b is not set; then
set b to show the current branch
fi
fi
It looks somewhat strange that this has to be nested, not a straight
cascade of if/elif/.../fi.
> @@ -295,6 +296,7 @@ __git_ps1 ()
> r="|BISECTING"
> fi
>
> + test -n "$b" ||
> b="$(git symbolic-ref HEAD 2>/dev/null)" || {
> detached=yes
> b="$(
> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> index 083b319..15521cc 100755
> --- a/t/t9903-bash-prompt.sh
> +++ b/t/t9903-bash-prompt.sh
> @@ -276,7 +276,7 @@ test_expect_success 'prompt - rebase merge' '
> '
>
> test_expect_success 'prompt - rebase' '
> - printf " ((t2)|REBASE 1/3)" > expected &&
> + printf " (b2|REBASE 1/3)" > expected &&
> git checkout b2 &&
> test_when_finished "git checkout master" &&
> test_must_fail git rebase b1 b2 &&
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-29 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-29 6:21 [PATCH] prompt: fix for simple rebase Felipe Contreras
2013-05-29 18:26 ` Junio C Hamano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.