{"thread":{"id":"37926","subject":"[PATCH] Show number of commits being rebased interactively","startedAt":"2014-11-10T16:32:19Z","lastAt":"2014-12-10T18:16:44Z","messageCount":5,"participants":["Onno Kortmann","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"251680","messageId":"5460E893.7080003@gmx.net","threadId":"37926","inReplyTo":"md5:H/n6RCGs7zvP8Sp7z7ElnQ==","subject":"[PATCH] Show number of commits being rebased interactively","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2014-11-10T16:32:19Z","receivedAt":"2014-11-10T16:32:19Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Hi again,\n\noops, I realized that my MUA mangled the patch, even though it\nshouldn't. Here it is again, with a bit more description.\n---\n\nDuring 'rebase -i', one wrong edit in a long rebase session might\ninadvertently drop commits. This change shows the total number of\ncommits in the comments below the commit list. After the rebase\nedit, the number can be quickly compared to the line number of\nthe last commit - by scrolling to the last entry in the rebase\nTODO list. This gives peace of mind that no commits have been\nlost in the edit.\n\nSigned-off-by: Onno Kortmann <onno@gmx.net>\n---\n git-rebase--interactive.sh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex b64dd28..b266dc0 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -1031,9 +1031,11 @@ test -s \"$todo\" || echo noop >> \"$todo\"\n test -n \"$autosquash\" && rearrange_squash \"$todo\"\n test -n \"$cmd\" && add_exec_commands \"$todo\"\n\n+commitcount=$(git stripspace --strip-comments <\"$todo\"  | wc -l)\n+\n cat >>\"$todo\" <<EOF\n\n-$comment_char Rebase $shortrevisions onto $shortonto\n+$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s))\n EOF\n append_todo_help\n git stripspace --comment-lines >>\"$todo\" <<\\EOF\n-- \n2.2.0.rc1.1.gbab0d06\n"},{"id":"253189","messageId":"xmqq388tpyls.fsf@gitster.dls.corp.google.com","threadId":"37926","inReplyTo":"5460E893.7080003@gmx.net","subject":"Re: [PATCH] Show number of commits being rebased interactively","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-05T21:37:19Z","receivedAt":"2014-12-05T21:37:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I see nobody commented on this, which probably fell into cracks.\nEven though I am personally not very interested, I obviously am not\nthe only user of Git, and there may be others who are interested in\na change like this.\n\nOnno Kortmann <onno@gmx.net> writes:\n\n> Hi again,\n>\n> oops, I realized that my MUA mangled the patch, even though it\n> shouldn't. Here it is again, with a bit more description.\n> ---\n\nThese lines above \"---\" will become the only log message text, which\nis probably not what you intended.  Use \"-- >8 --\" marker instead\n(that is a perforation line with a pair of scissors on it)?\n\n> During 'rebase -i', one wrong edit in a long rebase session might\n> inadvertently drop commits. This change shows the total number of\n> commits in the comments below the commit list. After the rebase\n> edit, the number can be quickly compared to the line number of\n> the last commit - by scrolling to the last entry in the rebase\n> TODO list. This gives peace of mind that no commits have been\n> lost in the edit.\n>\n> Signed-off-by: Onno Kortmann <onno@gmx.net>\n> ---\n>  git-rebase--interactive.sh | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index b64dd28..b266dc0 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -1031,9 +1031,11 @@ test -s \"$todo\" || echo noop >> \"$todo\"\n>  test -n \"$autosquash\" && rearrange_squash \"$todo\"\n>  test -n \"$cmd\" && add_exec_commands \"$todo\"\n>\n> +commitcount=$(git stripspace --strip-comments <\"$todo\"  | wc -l)\n\nDoes this count the number of commits?  I suspect it at least needs\nto filter \"x|exec\" out.\n\n>  cat >>\"$todo\" <<EOF\n>\n> -$comment_char Rebase $shortrevisions onto $shortonto\n> +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s))\n>  EOF\n>  append_todo_help\n>  git stripspace --comment-lines >>\"$todo\" <<\\EOF\n"},{"id":"253289","messageId":"5484BEFD.7060906@gmx.net","threadId":"37926","inReplyTo":"xmqq388tpyls.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] Show number of commits being rebased interactively","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2014-12-07T20:56:29Z","receivedAt":"2014-12-07T20:56:29Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Hi,\n\n> These lines above \"---\" will become the only log message text, which\n> is probably not what you intended.  Use \"-- >8 --\" marker instead\n> (that is a perforation line with a pair of scissors on it)?\nThanks, hopefully fixed below.\n\n>> +commitcount=$(git stripspace --strip-comments <\"$todo\"  | wc -l)\n>\n> Does this count the number of commits?  I suspect it at least needs\n> to filter \"x|exec\" out.\nVery true - after reading this, I learned about the '-x' option\nto git-rebase -i :-)\nI changed the patch so it now properly looks for '^pick ' patterns. I\nhope this should do the trick under all circumstances? In the case\nof having 'exec' lines interspersed, the $commitcount becomes a lot\nless useful (no comparison to editor line numbers), though.\n\nCheers,\n\nOnno\n8< 8< 8< 8< 8< 8< 8< 8< 8<\nSubject: [PATCH] Show number of commits being rebased interactively\n\nDuring 'rebase -i', one wrong edit in a long rebase session might\ninadvertently drop commits. This change shows the total number of\ncommits in the comments below the commit list. After the rebase\nedit, the number can be quickly compared to the line number of\nthe last commit - by scrolling to the last entry in the rebase\nTODO list. This gives peace of mind that no commits have been\nlost in the edit.\n\nSigned-off-by: Onno Kortmann <onno@gmx.net>\n---\n git-rebase--interactive.sh | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex b64dd28..b26e5e6 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -1031,9 +1031,13 @@ test -s \"$todo\" || echo noop >> \"$todo\"\n test -n \"$autosquash\" && rearrange_squash \"$todo\"\n test -n \"$cmd\" && add_exec_commands \"$todo\"\n\n+commitcount=$(git stripspace --strip-comments <\"$todo\"  | \\\n+\t      sane_grep \"^pick \" | \\\n+\t      wc -l)\n+\n cat >>\"$todo\" <<EOF\n\n-$comment_char Rebase $shortrevisions onto $shortonto\n+$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s))\n EOF\n append_todo_help\n git stripspace --comment-lines >>\"$todo\" <<\\EOF\n-- \n2.2.0.rc0.18.g1c09766\n"},{"id":"253431","messageId":"xmqqbnncmys1.fsf@gitster.dls.corp.google.com","threadId":"37926","inReplyTo":"5484BEFD.7060906@gmx.net","subject":"Re: [PATCH] Show number of commits being rebased interactively","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-09T19:03:10Z","receivedAt":"2014-12-09T19:03:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Onno Kortmann <onno@gmx.net> writes:\n\n> Hi,\n>\n>> These lines above \"---\" will become the only log message text, which\n>> is probably not what you intended.  Use \"-- >8 --\" marker instead\n>> (that is a perforation line with a pair of scissors on it)?\n> Thanks, hopefully fixed below.\n>\n>>> +commitcount=$(git stripspace --strip-comments <\"$todo\"  | wc -l)\n>>\n>> Does this count the number of commits?  I suspect it at least needs\n>> to filter \"x|exec\" out.\n> Very true - after reading this, I learned about the '-x' option\n> to git-rebase -i :-)\n> I changed the patch so it now properly looks for '^pick ' patterns. I\n\nHmm, is looking only for pick the right thing?\n\nStepping back a bit, I have to wonder what we want to count.  The\nnumber of commits after the rebase is done, or the number of commits\nin the input of the rebase operation?\n\nThe generation loop that reads from rev-list may add only \"pick\",\nbut then rearrange_squash will munge some into squash and fixup.  We\nmay even have some more automated editing of the insn sheet in the\nfuture, just like add_exec_commands were added, so I think it is\nmore prudent to go from the full list of possible insn sheet\ncommands (that is, pick, reword, edit, squash, fixup and exec) and\ncount them, not just relying on \"we know the rev-list loop happens\nto add only pick commands\".\n\n> In the case of having 'exec' lines interspersed, the $commitcount\n> becomes a lot less useful (no comparison to editor line numbers),\n> though.\n\nHmph, interesting.  Then perhaps not filtering at all and instead\nlabelling this new piece of information not \"commit(s)\" a better\nsolution?  You are counting the number of instructions in the insn\nsheet, so perhaps something like \"($count todo items(s))\" or\nsomething?\n\n> Onno\n> 8< 8< 8< 8< 8< 8< 8< 8< 8<\n\nThat is not a scissors line, I suspect.\n\nI didn't try running \"git am\" on this message, though.  Did you?\n\n> Subject: [PATCH] Show number of commits being rebased interactively\n>\n> During 'rebase -i', one wrong edit in a long rebase session might\n> inadvertently drop commits. This change shows the total number of\n> commits in the comments below the commit list. After the rebase\n> edit, the number can be quickly compared to the line number of\n> the last commit - by scrolling to the last entry in the rebase\n> TODO list. This gives peace of mind that no commits have been\n> lost in the edit.\n>\n> Signed-off-by: Onno Kortmann <onno@gmx.net>\n> ---\n>  git-rebase--interactive.sh | 6 +++++-\n>  1 file changed, 5 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index b64dd28..b26e5e6 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -1031,9 +1031,13 @@ test -s \"$todo\" || echo noop >> \"$todo\"\n>  test -n \"$autosquash\" && rearrange_squash \"$todo\"\n>  test -n \"$cmd\" && add_exec_commands \"$todo\"\n>\n> +commitcount=$(git stripspace --strip-comments <\"$todo\"  | \\\n> +\t      sane_grep \"^pick \" | \\\n> +\t      wc -l)\n\nJust a scripting tip.  When a line ends with a vertical bar (pipe),\nthe shell parser knows that you haven't finished speaking, so there\nis no need to have \"\\\" there.\n\n>  cat >>\"$todo\" <<EOF\n>\n> -$comment_char Rebase $shortrevisions onto $shortonto\n> +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s))\n>  EOF\n>  append_todo_help\n>  git stripspace --comment-lines >>\"$todo\" <<\\EOF\n"},{"id":"253522","messageId":"54888E0C.4050402@gmx.net","threadId":"37926","inReplyTo":"xmqqbnncmys1.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] Show number of commits being rebased interactively","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2014-12-10T18:16:44Z","receivedAt":"2014-12-10T18:16:44Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Hi,\n\n>> In the case of having 'exec' lines interspersed, the $commitcount\n>> becomes a lot less useful (no comparison to editor line numbers),\n>> though.\n>\n> Hmph, interesting.  Then perhaps not filtering at all and instead\n> labelling this new piece of information not \"commit(s)\" a better\n> solution?  You are counting the number of instructions in the insn\n> sheet, so perhaps something like \"($count todo items(s))\" or\n> something?\nYes that sounds good. Though I lack the experience to say what would\nbe the typical workflow for someone who uses rebase-i a lot with execs\ninterspersed(?)\n\nIn all cases, simply counting and noting '#todo item(s)' would always be\na correct labelling and simple to understand, albeit not necessarily a\nvery helpful value. But at least for pure picks/edit/squash lists,\nit will allow a quick sanity check.\n\nAlso, I noted that filtering for ^pick will not be good\nin case one uses '--autosquash'.\n\n>> 8< 8< 8< 8< 8< 8< 8< 8< 8<\n>\n> That is not a scissors line, I suspect.\n>\n> I didn't try running \"git am\" on this message, though.  Did you?\nYes, I RTFMed on git-mailinfo and to be sure I tested this before sending\nthe last mail out :)\n\nBelow is the patch, changed to say 'TODO items', and with updated commit\nmessage.\n\nCheers,\n\nOnno\n\n8< 8< 8< 8< 8< 8< 8< 8< 8<\nSubject: [PATCH] Show number of TODO items for interactive rebase\n\nDuring 'rebase -i', one wrong edit in a long rebase session\nmight inadvertently drop commits/items. This change shows\nthe total number of TODO items in the comments after the\nlist. After performing the rebase edit, total item counts\ncan be compared to make sure that no changes have been lost\nin the edit.\n\nSigned-off-by: Onno Kortmann <onno@gmx.net>\n---\n git-rebase--interactive.sh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex b64dd28..c6a4629 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -1031,9 +1031,11 @@ test -s \"$todo\" || echo noop >> \"$todo\"\n test -n \"$autosquash\" && rearrange_squash \"$todo\"\n test -n \"$cmd\" && add_exec_commands \"$todo\"\n\n+todocount=$(git stripspace --strip-comments <\"$todo\" | wc -l)\n+\n cat >>\"$todo\" <<EOF\n\n-$comment_char Rebase $shortrevisions onto $shortonto\n+$comment_char Rebase $shortrevisions onto $shortonto ($todocount TODO item(s))\n EOF\n append_todo_help\n git stripspace --comment-lines >>\"$todo\" <<\\EOF\n--\n2.2.0.34.gb8f29bf\n"}]}