From 28c8cfc3635368f06f6deaedb5e90da328df27d2 Mon Sep 17 00:00:00 2001
From: Eric Sunshine <sunshine@sunshineco.com>
Date: Wed, 4 Mar 2015 02:53:04 -0500
Subject: [PATCH 1/2] rebase-interactive: suppress whitespace preceding item
 count

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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 c6a4629cb..07512e456 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1032,6 +1032,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 8197ed29a..5dc2caf3c 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1039,4 +1039,13 @@ test_expect_success 'short SHA-1 collide' '
 	)
 '
 
+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

From 2185d3b7ad2ccdfe220d5c4139ff671a66fe7d80 Mon Sep 17 00:00:00 2001
From: Eric Sunshine <sunshine@sunshineco.com>
Date: Wed, 4 Mar 2015 02:53:05 -0500
Subject: [PATCH 2/2] rebase-interactive: re-word "item count" comment

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

    # Rebase 46640c6..5568fd5 onto 46640c6 (4 TODO item(s))
    #
    # Commands:
    # p, pick = use commit
    # ...

However, with the exception of the --edit-todo option, "TODO" is a
one-off term, never presented to the user by rebase-interactive in
any other context. The item count is in fact the number of commands
("pick", "edit", etc.) remaining on the instruction sheet, and the
comment immediately following it talks about "Commands". Consequently,
replace "(# TODO item(s))" with the more accurate and meaningful
"(# command(s))".

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-rebase--interactive.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 07512e456..c5e117a17 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1036,7 +1036,7 @@ todocount=${todocount##* }
 
 cat >>"$todo" <<EOF
 
-$comment_char Rebase $shortrevisions onto $shortonto ($todocount TODO item(s))
+$comment_char Rebase $shortrevisions onto $shortonto ($todocount command(s))
 EOF
 append_todo_help
 git stripspace --comment-lines >>"$todo" <<\EOF