git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Show number of commits being rebased interactively

From
Onno Kortmann <onno@gmx.net>
Date
Dec 10, 2014, 18:16 UTC
Message-ID
<54888E0C.4050402@gmx.net>
In-Reply-To
<xmqqbnncmys1.fsf@gitster.dls.corp.google.com>
Hi,
Show 9 quoted lines
>> 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'.

Show 5 quoted lines
>> 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
Previous: Junio C Hamano
Message 5 of 5 in “Show number of commits being rebased interactively”
  1. Show number of commits being rebased interactivelyOnno Kortmann, Nov 10, 2014
  2. Junio C HamanoDec 5, 2014
  3. Onno KortmannDec 7, 2014
  4. Junio C HamanoDec 9, 2014
  5. Onno KortmannDec 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.