rebase-interactive: suppress whitespace preceding item count
authorEric Sunshine <sunshine@sunshineco.com>
Wed, 4 Mar 2015 07:53:04 +0000 (02:53 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Mar 2015 20:11:27 +0000 (12:11 -0800)
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
t/t3404-rebase-interactive.sh
index c6a4629cbc2b69d3e6dfabe5e124384fe7fe611c..07512e45637c9b77cebc9a1474d7bde31d0d7205 100644 (file)
@@ -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
 
index 8197ed29a9ecedb43679200f1485a7b50984fdff..5dc2caf3c58d195c239f6bf3627d3d4f469bb81b 100755 (executable)
@@ -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