{"thread":{"id":"33580","subject":"[PATCH] git-prompt.sh: Show where rebase is at when interrupted by a merge conflict","startedAt":"2013-04-23T12:35:07Z","lastAt":"2013-04-24T07:14:54Z","messageCount":4,"participants":["Zoltan Klinger","Junio C Hamano","Eric Sunshine","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"215217","messageId":"1366720507-16504-1-git-send-email-zoltan.klinger@gmail.com","threadId":"33580","inReplyTo":null,"subject":"[PATCH] git-prompt.sh: Show where rebase is at when interrupted by a merge conflict","fromName":"Zoltan Klinger","fromEmail":"zoltan.klinger@gmail.com","sentAt":"2013-04-23T12:35:07Z","receivedAt":"2013-04-23T12:35:07Z","isPatch":true,"sender":{"key":"zoltan.klinger@gmail.com","avatar":"https://avatars.githubusercontent.com/u/95923?v=4"},"body":"When a rebase is interrupted by a merge conflict it could be useful to\nknow how far a rebase has progressed and how many commits in total this\nrebase will apply. Teach the __git_ps1() command to display the number\nof commits so far applied and the total number of commits to be applied.\n\nBelow is a sample output of the improved __git_ps1() command:\n  ((3ec0a6a...)|REBASE|2/5)\n\nIn the example above the rebase has stopped at the second commit due to\na merge conflict and there are a total number of five commits to be\napplied by this rebase.\n\nThis information can be alredy obtained from the following files which are\nbeing generated during the rebase:\n    GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh)\n    GIT_DIR/.git/rebase-merge/end    (git-rebase--merge.sh)\n    GIT_DIR/.git/rebase-apply/next   (git-am.sh)\n    GIT_DIR/.git/rebase-apply/last   (git-am.sh)\n\n1) Modify git-rebase--interactive.sh to also create\n      GIT_DIR/.git/rebase-merge/msgnum\n      GIT_DIR/.git/rebase-merge/end\n   files for the number of commits so far applied and the total number of\n   commits to be applied.\n2) Modify git-prompt.sh to read and display info from the above files\n3) Update test t9903-bash-prompt.sh to reflect changes introduced by\n   this patch.\n\nSigned-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>\n---\n contrib/completion/git-prompt.sh |   21 ++++++++++++++++-----\n git-rebase--interactive.sh       |    5 +++++\n t/t9903-bash-prompt.sh           |    6 +++---\n 3 files changed, 24 insertions(+), 8 deletions(-)\n\ndiff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh\nindex 756a951..49f7742 100644\n--- a/contrib/completion/git-prompt.sh\n+++ b/contrib/completion/git-prompt.sh\n@@ -263,14 +263,21 @@ __git_ps1 ()\n \telse\n \t\tlocal r=\"\"\n \t\tlocal b=\"\"\n-\t\tif [ -f \"$g/rebase-merge/interactive\" ]; then\n-\t\t\tr=\"|REBASE-i\"\n-\t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n-\t\telif [ -d \"$g/rebase-merge\" ]; then\n-\t\t\tr=\"|REBASE-m\"\n+\t\tlocal step=\"\"\n+\t\tlocal total=\"\"\n+\t\tif [ -d \"$g/rebase-merge\" ]; then\n \t\t\tb=\"$(cat \"$g/rebase-merge/head-name\")\"\n+\t\t\tstep=$(cat \"$g/rebase-merge/msgnum\")\n+\t\t\ttotal=$(cat \"$g/rebase-merge/end\")\n+\t\t\tif [ -f \"$g/rebase-merge/interactive\" ]; then\n+\t\t\t\tr=\"|REBASE-i\"\n+\t\t\telse\n+\t\t\t\tr=\"|REBASE-m\"\n+\t\t\tfi\n \t\telse\n \t\t\tif [ -d \"$g/rebase-apply\" ]; then\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\tr=\"|REBASE\"\n \t\t\t\telif [ -f \"$g/rebase-apply/applying\" ]; then\n@@ -308,6 +315,10 @@ __git_ps1 ()\n \t\t\t}\n \t\tfi\n \n+\t\tif [ -n \"$step\" ] && [ -n \"$total\" ]; then\n+\t\t\tr=\"$r|$step/$total\"\n+\t\tfi\n+\n \t\tlocal w=\"\"\n \t\tlocal i=\"\"\n \t\tlocal s=\"\"\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 048a140..f76ff8f 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -57,6 +57,9 @@ rewritten=\"$state_dir\"/rewritten\n \n dropped=\"$state_dir\"/dropped\n \n+end=\"$state_dir\"/end\n+msgnum=\"$state_dir\"/msgnum\n+\n # A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n # GIT_AUTHOR_DATE that will be used for the commit that is currently\n # being rebased.\n@@ -109,7 +112,9 @@ mark_action_done () {\n \tsed -e 1d < \"$todo\" >> \"$todo\".new\n \tmv -f \"$todo\".new \"$todo\"\n \tnew_count=$(git stripspace --strip-comments <\"$done\" | wc -l)\n+\techo $new_count > $msgnum\n \ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n+\techo $total > $end\n \tif test \"$last_count\" != \"$new_count\"\n \tthen\n \t\tlast_count=$new_count\ndiff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh\nindex e147a8d..2f8f9ab 100755\n--- a/t/t9903-bash-prompt.sh\n+++ b/t/t9903-bash-prompt.sh\n@@ -243,7 +243,7 @@ test_expect_success 'prompt - inside bare repository' '\n '\n \n test_expect_success 'prompt - interactive rebase' '\n-\tprintf \" (b1|REBASE-i)\" > expected\n+\tprintf \" (b1|REBASE-i|1/1)\" > expected\n \techo \"#!$SHELL_PATH\" >fake_editor.sh &&\n \tcat >>fake_editor.sh <<\\EOF &&\n echo \"edit $(git log -1 --format=\"%h\")\" > \"$1\"\n@@ -260,7 +260,7 @@ EOF\n '\n \n test_expect_success 'prompt - rebase merge' '\n-\tprintf \" (b2|REBASE-m)\" > expected &&\n+\tprintf \" (b2|REBASE-m|1/1)\" > expected &&\n \tgit checkout b2 &&\n \ttest_when_finished \"git checkout master\" &&\n \ttest_must_fail git rebase --merge b1 b2 &&\n@@ -270,7 +270,7 @@ test_expect_success 'prompt - rebase merge' '\n '\n \n test_expect_success 'prompt - rebase' '\n-\tprintf \" ((t2)|REBASE)\" > expected &&\n+\tprintf \" ((t2)|REBASE|1/1)\" > expected &&\n \tgit checkout b2 &&\n \ttest_when_finished \"git checkout master\" &&\n \ttest_must_fail git rebase b1 b2 &&\n-- \n1.7.9.5\n"},{"id":"215234","messageId":"7vk3ntl1x9.fsf@alter.siamese.dyndns.org","threadId":"33580","inReplyTo":"1366720507-16504-1-git-send-email-zoltan.klinger@gmail.com","subject":"Re: [PATCH] git-prompt.sh: Show where rebase is at when interrupted by a merge conflict","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-23T15:08:50Z","receivedAt":"2013-04-23T15:08:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Zoltan Klinger <zoltan.klinger@gmail.com> writes:\n\n> When a rebase is interrupted by a merge conflict it could be useful to\n> know how far a rebase has progressed and how many commits in total this\n> rebase will apply. Teach the __git_ps1() command to display the number\n> of commits so far applied and the total number of commits to be applied.\n>\n> Below is a sample output of the improved __git_ps1() command:\n>   ((3ec0a6a...)|REBASE|2/5)\n>\n> In the example above the rebase has stopped at the second commit due to\n> a merge conflict and there are a total number of five commits to be\n> applied by this rebase.\n>\n> This information can be alredy obtained from the following files which are\n> being generated during the rebase:\n>     GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh)\n>     GIT_DIR/.git/rebase-merge/end    (git-rebase--merge.sh)\n>     GIT_DIR/.git/rebase-apply/next   (git-am.sh)\n>     GIT_DIR/.git/rebase-apply/last   (git-am.sh)\n>\n> 1) Modify git-rebase--interactive.sh to also create\n>       GIT_DIR/.git/rebase-merge/msgnum\n>       GIT_DIR/.git/rebase-merge/end\n>    files for the number of commits so far applied and the total number of\n>    commits to be applied.\n> 2) Modify git-prompt.sh to read and display info from the above files\n> 3) Update test t9903-bash-prompt.sh to reflect changes introduced by\n>    this patch.\n>\n> Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>\n> ---\n\nNicely explained.  Felipe?  Szeder?  Comments?\n\n>  contrib/completion/git-prompt.sh |   21 ++++++++++++++++-----\n>  git-rebase--interactive.sh       |    5 +++++\n>  t/t9903-bash-prompt.sh           |    6 +++---\n>  3 files changed, 24 insertions(+), 8 deletions(-)\n> ...\n> -\tprintf \" (b1|REBASE-i)\" > expected\n> +\tprintf \" (b1|REBASE-i|1/1)\" > expected\n\nThis makes me wonder if \" (b1|REBASE-i 1/1)\" may be easier on the\neyes.  Also it may not be a bad idea to add a new piece to this test\nto show the state that is not \"1/1\" but something else.\n"},{"id":"215287","messageId":"CAPig+cR2rvgptVvyDNOJijUZEGN5T_=uJ6xjs_sN9E+=5+sAvQ@mail.gmail.com","threadId":"33580","inReplyTo":"1366720507-16504-1-git-send-email-zoltan.klinger@gmail.com","subject":"Re: [PATCH] git-prompt.sh: Show where rebase is at when interrupted by a merge conflict","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-04-24T07:05:03Z","receivedAt":"2013-04-24T07:05:03Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Apr 23, 2013 at 8:35 AM, Zoltan Klinger\n<zoltan.klinger@gmail.com> wrote:\n> When a rebase is interrupted by a merge conflict it could be useful to\n> know how far a rebase has progressed and how many commits in total this\n> rebase will apply. Teach the __git_ps1() command to display the number\n> of commits so far applied and the total number of commits to be applied.\n>\n> Below is a sample output of the improved __git_ps1() command:\n>   ((3ec0a6a...)|REBASE|2/5)\n>\n> In the example above the rebase has stopped at the second commit due to\n> a merge conflict and there are a total number of five commits to be\n> applied by this rebase.\n>\n> This information can be alredy obtained from the following files which are\n\ns/alredy/already/\n\n> being generated during the rebase:\n>     GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh)\n>     GIT_DIR/.git/rebase-merge/end    (git-rebase--merge.sh)\n>     GIT_DIR/.git/rebase-apply/next   (git-am.sh)\n>     GIT_DIR/.git/rebase-apply/last   (git-am.sh)\n>\n> 1) Modify git-rebase--interactive.sh to also create\n>       GIT_DIR/.git/rebase-merge/msgnum\n>       GIT_DIR/.git/rebase-merge/end\n>    files for the number of commits so far applied and the total number of\n>    commits to be applied.\n> 2) Modify git-prompt.sh to read and display info from the above files\n> 3) Update test t9903-bash-prompt.sh to reflect changes introduced by\n>    this patch.\n>\n> Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>\n"},{"id":"215288","messageId":"CAMP44s2uOkNEfAE3mcDn2CTo4c-HqzoJ_bSJNfdiGRT60sDV0w@mail.gmail.com","threadId":"33580","inReplyTo":"7vk3ntl1x9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-prompt.sh: Show where rebase is at when interrupted by a merge conflict","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-24T07:14:54Z","receivedAt":"2013-04-24T07:14:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 23, 2013 at 10:08 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Zoltan Klinger <zoltan.klinger@gmail.com> writes:\n>\n>> When a rebase is interrupted by a merge conflict it could be useful to\n>> know how far a rebase has progressed and how many commits in total this\n>> rebase will apply. Teach the __git_ps1() command to display the number\n>> of commits so far applied and the total number of commits to be applied.\n>>\n>> Below is a sample output of the improved __git_ps1() command:\n>>   ((3ec0a6a...)|REBASE|2/5)\n>>\n>> In the example above the rebase has stopped at the second commit due to\n>> a merge conflict and there are a total number of five commits to be\n>> applied by this rebase.\n>>\n>> This information can be alredy obtained from the following files which are\n>> being generated during the rebase:\n>>     GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh)\n>>     GIT_DIR/.git/rebase-merge/end    (git-rebase--merge.sh)\n>>     GIT_DIR/.git/rebase-apply/next   (git-am.sh)\n>>     GIT_DIR/.git/rebase-apply/last   (git-am.sh)\n>>\n>> 1) Modify git-rebase--interactive.sh to also create\n>>       GIT_DIR/.git/rebase-merge/msgnum\n>>       GIT_DIR/.git/rebase-merge/end\n>>    files for the number of commits so far applied and the total number of\n>>    commits to be applied.\n>> 2) Modify git-prompt.sh to read and display info from the above files\n>> 3) Update test t9903-bash-prompt.sh to reflect changes introduced by\n>>    this patch.\n>>\n>> Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>\n>> ---\n>\n> Nicely explained.  Felipe?  Szeder?  Comments?\n\nLooks good to me.\n\n-- \nFelipe Contreras\n"}]}