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

[PATCH 1/2] rebase-interactive: suppress whitespace preceding item count

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 4, 2015, 07:53 UTC
Message-ID
<1425455585-30186-1-git-send-email-sunshine@sunshineco.com>

97f05f43 (Show number of TODO items for interactive rebase, 2014-12-10) taught rebase-interactive to compute an item count with 'wc -l' and display it in the instruction list comments:

    # Rebase 46640c6..5568fd5 onto 46640c6 (4 TODO item(s))
On Mac OS X, however, it renders as:
    # Rebase 46640c6..5568fd5 onto 46640c6 (       4 TODO item(s))
since 'wc -l' indents its output with leading spaces. Fix this.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

Consistent with existing tests in t3404, the new test uses plain 'grep' rather than 'test_i18ngrep'.

 git-rebase--interactive.sh    | 1 +
 t/t3404-rebase-interactive.sh | 9 +++++++++
 2 files changed, 10 insertions(+)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c96b984..ab98b13 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1030,6 +1030,7 @@ test -n "$autosquash" && rearrange_squash "$todo"
 test -n "$cmd" && add_exec_commands "$todo"
 
 todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
+todocount=${todocount##* }
 
 cat >>"$todo" <<EOF
 
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index a31f7e0..034eb35 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1046,4 +1046,13 @@ test_expect_success 'respect core.abbrev' '
 	test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
 '
 
+test_expect_success 'todo count' '
+	write_script dump-raw.sh <<-\EOF &&
+		cat "$1"
+	EOF
+	test_set_editor "$(pwd)/dump-raw.sh" &&
+	git rebase -i HEAD~4 >actual &&
+	grep "^# Rebase ..* onto ..* ([0-9]" actual
+'
+
 test_done
-- 
2.3.1.340.gf490742
Next: Eric Sunshine
Message 1 of 2 in “rebase-interactive: suppress whitespace preceding item count”
  1. 1/2 rebase-interactive: suppress whitespace preceding item countEric Sunshine, Mar 4, 2015
  2. 2/2 rebase-interactive: re-word "item count" commentEric Sunshine, Mar 4, 2015

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.