* [PATCH] Show number of commits being rebased interactively @ 2014-11-09 13:24 Onno Kortmann 0 siblings, 0 replies; 6+ messages in thread From: Onno Kortmann @ 2014-11-09 13:24 UTC (permalink / raw) To: git During 'rebase -i', a wrong edit command might inadvertently drop commits. This change shows the total number of commits in the comments below the commit list. After a rebase edit, this number can be quickly compared to the line number of the last commit in the rebase TODO list. Signed-off-by: Onno Kortmann <onno@gmx.net> --- git-rebase--interactive.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b64dd28..b266dc0 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -1031,9 +1031,11 @@ test -s "$todo" || echo noop >> "$todo" test -n "$autosquash" && rearrange_squash "$todo" test -n "$cmd" && add_exec_commands "$todo" +commitcount=$(git stripspace --strip-comments <"$todo" | wc -l) + cat >>"$todo" <<EOF -$comment_char Rebase $shortrevisions onto $shortonto +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s)) EOF append_todo_help git stripspace --comment-lines >>"$todo" <<\EOF -- 2.2.0.rc1.1.gbab0d06 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <md5:H/n6RCGs7zvP8Sp7z7ElnQ==>]
* [PATCH] Show number of commits being rebased interactively [not found] <md5:H/n6RCGs7zvP8Sp7z7ElnQ==> @ 2014-11-10 16:32 ` Onno Kortmann 2014-12-05 21:37 ` Junio C Hamano 0 siblings, 1 reply; 6+ messages in thread From: Onno Kortmann @ 2014-11-10 16:32 UTC (permalink / raw) To: git Hi again, oops, I realized that my MUA mangled the patch, even though it shouldn't. Here it is again, with a bit more description. --- During 'rebase -i', one wrong edit in a long rebase session might inadvertently drop commits. This change shows the total number of commits in the comments below the commit list. After the rebase edit, the number can be quickly compared to the line number of the last commit - by scrolling to the last entry in the rebase TODO list. This gives peace of mind that no commits have been lost in the edit. Signed-off-by: Onno Kortmann <onno@gmx.net> --- git-rebase--interactive.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b64dd28..b266dc0 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -1031,9 +1031,11 @@ test -s "$todo" || echo noop >> "$todo" test -n "$autosquash" && rearrange_squash "$todo" test -n "$cmd" && add_exec_commands "$todo" +commitcount=$(git stripspace --strip-comments <"$todo" | wc -l) + cat >>"$todo" <<EOF -$comment_char Rebase $shortrevisions onto $shortonto +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s)) EOF append_todo_help git stripspace --comment-lines >>"$todo" <<\EOF -- 2.2.0.rc1.1.gbab0d06 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Show number of commits being rebased interactively 2014-11-10 16:32 ` Onno Kortmann @ 2014-12-05 21:37 ` Junio C Hamano 2014-12-07 20:56 ` Onno Kortmann 0 siblings, 1 reply; 6+ messages in thread From: Junio C Hamano @ 2014-12-05 21:37 UTC (permalink / raw) To: git; +Cc: Onno Kortmann I see nobody commented on this, which probably fell into cracks. Even though I am personally not very interested, I obviously am not the only user of Git, and there may be others who are interested in a change like this. Onno Kortmann <onno@gmx.net> writes: > Hi again, > > oops, I realized that my MUA mangled the patch, even though it > shouldn't. Here it is again, with a bit more description. > --- These lines above "---" will become the only log message text, which is probably not what you intended. Use "-- >8 --" marker instead (that is a perforation line with a pair of scissors on it)? > During 'rebase -i', one wrong edit in a long rebase session might > inadvertently drop commits. This change shows the total number of > commits in the comments below the commit list. After the rebase > edit, the number can be quickly compared to the line number of > the last commit - by scrolling to the last entry in the rebase > TODO list. This gives peace of mind that no commits have been > lost in the edit. > > Signed-off-by: Onno Kortmann <onno@gmx.net> > --- > git-rebase--interactive.sh | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh > index b64dd28..b266dc0 100644 > --- a/git-rebase--interactive.sh > +++ b/git-rebase--interactive.sh > @@ -1031,9 +1031,11 @@ test -s "$todo" || echo noop >> "$todo" > test -n "$autosquash" && rearrange_squash "$todo" > test -n "$cmd" && add_exec_commands "$todo" > > +commitcount=$(git stripspace --strip-comments <"$todo" | wc -l) Does this count the number of commits? I suspect it at least needs to filter "x|exec" out. > cat >>"$todo" <<EOF > > -$comment_char Rebase $shortrevisions onto $shortonto > +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s)) > EOF > append_todo_help > git stripspace --comment-lines >>"$todo" <<\EOF ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Show number of commits being rebased interactively 2014-12-05 21:37 ` Junio C Hamano @ 2014-12-07 20:56 ` Onno Kortmann 2014-12-09 19:03 ` Junio C Hamano 0 siblings, 1 reply; 6+ messages in thread From: Onno Kortmann @ 2014-12-07 20:56 UTC (permalink / raw) To: Junio C Hamano, git Hi, > These lines above "---" will become the only log message text, which > is probably not what you intended. Use "-- >8 --" marker instead > (that is a perforation line with a pair of scissors on it)? Thanks, hopefully fixed below. >> +commitcount=$(git stripspace --strip-comments <"$todo" | wc -l) > > Does this count the number of commits? I suspect it at least needs > to filter "x|exec" out. Very true - after reading this, I learned about the '-x' option to git-rebase -i :-) I changed the patch so it now properly looks for '^pick ' patterns. I hope this should do the trick under all circumstances? In the case of having 'exec' lines interspersed, the $commitcount becomes a lot less useful (no comparison to editor line numbers), though. Cheers, Onno 8< 8< 8< 8< 8< 8< 8< 8< 8< Subject: [PATCH] Show number of commits being rebased interactively During 'rebase -i', one wrong edit in a long rebase session might inadvertently drop commits. This change shows the total number of commits in the comments below the commit list. After the rebase edit, the number can be quickly compared to the line number of the last commit - by scrolling to the last entry in the rebase TODO list. This gives peace of mind that no commits have been lost in the edit. Signed-off-by: Onno Kortmann <onno@gmx.net> --- git-rebase--interactive.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b64dd28..b26e5e6 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -1031,9 +1031,13 @@ test -s "$todo" || echo noop >> "$todo" test -n "$autosquash" && rearrange_squash "$todo" test -n "$cmd" && add_exec_commands "$todo" +commitcount=$(git stripspace --strip-comments <"$todo" | \ + sane_grep "^pick " | \ + wc -l) + cat >>"$todo" <<EOF -$comment_char Rebase $shortrevisions onto $shortonto +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s)) EOF append_todo_help git stripspace --comment-lines >>"$todo" <<\EOF -- 2.2.0.rc0.18.g1c09766 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Show number of commits being rebased interactively 2014-12-07 20:56 ` Onno Kortmann @ 2014-12-09 19:03 ` Junio C Hamano 2014-12-10 18:16 ` Onno Kortmann 0 siblings, 1 reply; 6+ messages in thread From: Junio C Hamano @ 2014-12-09 19:03 UTC (permalink / raw) To: Onno Kortmann; +Cc: git Onno Kortmann <onno@gmx.net> writes: > Hi, > >> These lines above "---" will become the only log message text, which >> is probably not what you intended. Use "-- >8 --" marker instead >> (that is a perforation line with a pair of scissors on it)? > Thanks, hopefully fixed below. > >>> +commitcount=$(git stripspace --strip-comments <"$todo" | wc -l) >> >> Does this count the number of commits? I suspect it at least needs >> to filter "x|exec" out. > Very true - after reading this, I learned about the '-x' option > to git-rebase -i :-) > I changed the patch so it now properly looks for '^pick ' patterns. I Hmm, is looking only for pick the right thing? Stepping back a bit, I have to wonder what we want to count. The number of commits after the rebase is done, or the number of commits in the input of the rebase operation? The generation loop that reads from rev-list may add only "pick", but then rearrange_squash will munge some into squash and fixup. We may even have some more automated editing of the insn sheet in the future, just like add_exec_commands were added, so I think it is more prudent to go from the full list of possible insn sheet commands (that is, pick, reword, edit, squash, fixup and exec) and count them, not just relying on "we know the rev-list loop happens to add only pick commands". > In the case of having 'exec' lines interspersed, the $commitcount > becomes a lot less useful (no comparison to editor line numbers), > though. Hmph, interesting. Then perhaps not filtering at all and instead labelling this new piece of information not "commit(s)" a better solution? You are counting the number of instructions in the insn sheet, so perhaps something like "($count todo items(s))" or something? > Onno > 8< 8< 8< 8< 8< 8< 8< 8< 8< That is not a scissors line, I suspect. I didn't try running "git am" on this message, though. Did you? > Subject: [PATCH] Show number of commits being rebased interactively > > During 'rebase -i', one wrong edit in a long rebase session might > inadvertently drop commits. This change shows the total number of > commits in the comments below the commit list. After the rebase > edit, the number can be quickly compared to the line number of > the last commit - by scrolling to the last entry in the rebase > TODO list. This gives peace of mind that no commits have been > lost in the edit. > > Signed-off-by: Onno Kortmann <onno@gmx.net> > --- > git-rebase--interactive.sh | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh > index b64dd28..b26e5e6 100644 > --- a/git-rebase--interactive.sh > +++ b/git-rebase--interactive.sh > @@ -1031,9 +1031,13 @@ test -s "$todo" || echo noop >> "$todo" > test -n "$autosquash" && rearrange_squash "$todo" > test -n "$cmd" && add_exec_commands "$todo" > > +commitcount=$(git stripspace --strip-comments <"$todo" | \ > + sane_grep "^pick " | \ > + wc -l) Just a scripting tip. When a line ends with a vertical bar (pipe), the shell parser knows that you haven't finished speaking, so there is no need to have "\" there. > cat >>"$todo" <<EOF > > -$comment_char Rebase $shortrevisions onto $shortonto > +$comment_char Rebase $shortrevisions onto $shortonto ($commitcount commit(s)) > EOF > append_todo_help > git stripspace --comment-lines >>"$todo" <<\EOF ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Show number of commits being rebased interactively 2014-12-09 19:03 ` Junio C Hamano @ 2014-12-10 18:16 ` Onno Kortmann 0 siblings, 0 replies; 6+ messages in thread From: Onno Kortmann @ 2014-12-10 18:16 UTC (permalink / raw) To: Junio C Hamano; +Cc: git Hi, >> In the case of having 'exec' lines interspersed, the $commitcount >> becomes a lot less useful (no comparison to editor line numbers), >> though. > > Hmph, interesting. Then perhaps not filtering at all and instead > labelling this new piece of information not "commit(s)" a better > solution? You are counting the number of instructions in the insn > sheet, so perhaps something like "($count todo items(s))" or > something? Yes that sounds good. Though I lack the experience to say what would be the typical workflow for someone who uses rebase-i a lot with execs interspersed(?) In all cases, simply counting and noting '#todo item(s)' would always be a correct labelling and simple to understand, albeit not necessarily a very helpful value. But at least for pure picks/edit/squash lists, it will allow a quick sanity check. Also, I noted that filtering for ^pick will not be good in case one uses '--autosquash'. >> 8< 8< 8< 8< 8< 8< 8< 8< 8< > > That is not a scissors line, I suspect. > > I didn't try running "git am" on this message, though. Did you? Yes, I RTFMed on git-mailinfo and to be sure I tested this before sending the last mail out :) Below is the patch, changed to say 'TODO items', and with updated commit message. Cheers, Onno 8< 8< 8< 8< 8< 8< 8< 8< 8< Subject: [PATCH] Show number of TODO items for interactive rebase During 'rebase -i', one wrong edit in a long rebase session might inadvertently drop commits/items. This change shows the total number of TODO items in the comments after the list. After performing the rebase edit, total item counts can be compared to make sure that no changes have been lost in the edit. Signed-off-by: Onno Kortmann <onno@gmx.net> --- git-rebase--interactive.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index b64dd28..c6a4629 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -1031,9 +1031,11 @@ test -s "$todo" || echo noop >> "$todo" test -n "$autosquash" && rearrange_squash "$todo" test -n "$cmd" && add_exec_commands "$todo" +todocount=$(git stripspace --strip-comments <"$todo" | wc -l) + cat >>"$todo" <<EOF -$comment_char Rebase $shortrevisions onto $shortonto +$comment_char Rebase $shortrevisions onto $shortonto ($todocount TODO item(s)) EOF append_todo_help git stripspace --comment-lines >>"$todo" <<\EOF -- 2.2.0.34.gb8f29bf ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-12-10 18:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-09 13:24 [PATCH] Show number of commits being rebased interactively Onno Kortmann [not found] <md5:H/n6RCGs7zvP8Sp7z7ElnQ==> 2014-11-10 16:32 ` Onno Kortmann 2014-12-05 21:37 ` Junio C Hamano 2014-12-07 20:56 ` Onno Kortmann 2014-12-09 19:03 ` Junio C Hamano 2014-12-10 18:16 ` Onno Kortmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).