{"thread":{"id":"33969","subject":"[PATCH] prompt: fix for simple rebase","startedAt":"2013-05-29T06:21:28Z","lastAt":"2013-05-29T18:26:48Z","messageCount":2,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"218764","messageId":"1369808488-16977-1-git-send-email-felipe.contreras@gmail.com","threadId":"33969","inReplyTo":null,"subject":"[PATCH] prompt: fix for simple rebase","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-05-29T06:21:28Z","receivedAt":"2013-05-29T06:21:28Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"When we are rebasing without options ('am' mode), the head rebased lives\nin '$g/rebase-apply/head-name', so lets use that information so it's\nreported the same way as if we were doing other rebases (-i or -m).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-prompt.sh | 2 ++\n t/t9903-bash-prompt.sh           | 2 +-\n 2 files changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex eaf5c36..bbf7657 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -279,6 +279,7 @@ __git_ps1 ()\n \t\t\t\tstep=$(cat \"$g/rebase-apply/next\")\n \t\t\t\ttotal=$(cat \"$g/rebase-apply/last\")\n \t\t\t\tif [ -f \"$g/rebase-apply/rebasing\" ]; then\n+\t\t\t\t\tb=\"$(cat \"$g/rebase-apply/head-name\")\"\n \t\t\t\t\tr=\"|REBASE\"\n \t\t\t\telif [ -f \"$g/rebase-apply/applying\" ]; then\n \t\t\t\t\tr=\"|AM\"\n@@ -295,6 +296,7 @@ __git_ps1 ()\n \t\t\t\tr=\"|BISECTING\"\n \t\t\tfi\n \n+\t\t\ttest -n \"$b\" ||\n \t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\" || {\n \t\t\t\tdetached=yes\n \t\t\t\tb=\"$(\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex 083b319..15521cc 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -276,7 +276,7 @@ test_expect_success 'prompt - rebase merge' '\n '\n \n test_expect_success 'prompt - rebase' '\n-\tprintf \" ((t2)|REBASE 1/3)\" > expected &&\n+\tprintf \" (b2|REBASE 1/3)\" > expected &&\n \tgit checkout b2 &&\n \ttest_when_finished \"git checkout master\" &&\n \ttest_must_fail git rebase b1 b2 &&\n-- \n1.8.3.rc3.312.g47657de\n"},{"id":"218871","messageId":"7vehcptzfb.fsf@alter.siamese.dyndns.org","threadId":"33969","inReplyTo":"1369808488-16977-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] prompt: fix for simple rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-29T18:26:48Z","receivedAt":"2013-05-29T18:26:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> When we are rebasing without options ('am' mode), the head rebased lives\n> in '$g/rebase-apply/head-name', so lets use that information so it's\n> reported the same way as if we were doing other rebases (-i or -m).\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  contrib/completion/git-prompt.sh | 2 ++\n>  t/t9903-bash-prompt.sh           | 2 +-\n>  2 files changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\n> index eaf5c36..bbf7657 100644\n> --- a/contrib/completion/git-prompt.sh\n> +++ b/contrib/completion/git-prompt.sh\n> @@ -279,6 +279,7 @@ __git_ps1 ()\n>  \t\t\t\tstep=$(cat \"$g/rebase-apply/next\")\n>  \t\t\t\ttotal=$(cat \"$g/rebase-apply/last\")\n>  \t\t\t\tif [ -f \"$g/rebase-apply/rebasing\" ]; then\n> +\t\t\t\t\tb=\"$(cat \"$g/rebase-apply/head-name\")\"\n>  \t\t\t\t\tr=\"|REBASE\"\n>  \t\t\t\telif [ -f \"$g/rebase-apply/applying\" ]; then\n>  \t\t\t\t\tr=\"|AM\"\n\nLooks correct to me, and the resulting behaviour is better\n\nI wonder if the overall structure can be improved on top of this\nchange, though.\n\n\tif [ -d rebase-merge ]; then\n        \tset b, step, total and r to show REBASE-kind stuff\n\telse\n        \tif [ -d rebase-apply]; then\n                \tset step, total and r to show AM,\n                        but if rebasing is there, show REBASE\n\t\telif ...\n                \thandle all the other non rebase state\n\t\telif ...\n\t\t\tin many different elif-then pieces\n\t\tfi\n\n\t\tif $b is not set; then\n\t\t\tset b to show the current branch\n\t\tfi\n\tfi\n\nIt looks somewhat strange that this has to be nested, not a straight\ncascade of if/elif/.../fi.\n\n> @@ -295,6 +296,7 @@ __git_ps1 ()\n>  \t\t\t\tr=\"|BISECTING\"\n>  \t\t\tfi\n>  \n> +\t\t\ttest -n \"$b\" ||\n>  \t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\" || {\n>  \t\t\t\tdetached=yes\n>  \t\t\t\tb=\"$(\n> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\n> index 083b319..15521cc 100755\n> --- a/t/t9903-bash-prompt.sh\n> +++ b/t/t9903-bash-prompt.sh\n> @@ -276,7 +276,7 @@ test_expect_success 'prompt - rebase merge' '\n>  '\n>  \n>  test_expect_success 'prompt - rebase' '\n> -\tprintf \" ((t2)|REBASE 1/3)\" > expected &&\n> +\tprintf \" (b2|REBASE 1/3)\" > expected &&\n>  \tgit checkout b2 &&\n>  \ttest_when_finished \"git checkout master\" &&\n>  \ttest_must_fail git rebase b1 b2 &&\n"}]}