Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2016-07-28 20:47:23 +0300
committerJunio C Hamano <gitster@pobox.com>2016-07-28 23:22:46 +0300
commitd94975185947bd8594a4a8564ec6040e8c242b70 (patch)
treef7e5fe7d2313a2120ae00e246989077c4d509b52 /git-rebase--interactive.sh
parent9588c52b75c6ec9cc75b045cdec4fe237038615b (diff)
rebase-interactive: trim leading whitespace from progress count
Interactive rebase uses 'wc -l' to write the current patch number in a progress report. Some implementations of 'wc -l' produce spaces before the number, leading to ugly output such as Rebasing ( 3/8) Remove the spaces using a trivial arithmetic evaluation. Before 9588c52 (i18n: rebase-interactive: mark strings for translation) this was not a problem because printf was used to generate the text. Since that commit, the count is interpolated directly from a shell variable into the text, where the spaces remain. The total number of patches does not have this problem even though it is interpolated from a shell variable in the same manner, because the variable is set by an arithmetic evaluation. Later in the script, there is a virtually identical case where leading spaces are trimmed, but it uses a pattern substitution: todocount=$(git stripspace --strip-comments <"$todo" | wc -l) todocount=${todocount##* } I did not choose this idiom because it adds a line of code, and there is already an arithmetic evaluation in the vicinity of the line that is changed here. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rw-r--r--git-rebase--interactive.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 078ca5b2d56..44ba3d30e27 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -121,7 +121,7 @@ mark_action_done () {
sed -e 1q < "$todo" >> "$done"
sed -e 1d < "$todo" >> "$todo".new
mv -f "$todo".new "$todo"
- new_count=$(git stripspace --strip-comments <"$done" | wc -l)
+ new_count=$(( $(git stripspace --strip-comments <"$done" | wc -l) ))
echo $new_count >"$msgnum"
total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l)))
echo $total >"$end"