1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-08 06:36:10 +02:00

contrib/subtree: portability fix for string printing

'echo -n' is not portable, but this script used it as a way to give
a string followed by a carriage return for progress messages.
Introduce a new helper shell function "progress" and use printf as a
more portable way to do this.  As a side effect, this makes it
unnecessary to have a raw CR in our source, which can be munged in
some shells.  For example, MsysGit trims CR before executing a shell
script file in order to make it work right on Windows even if it
uses CRLF as linefeeds.

While at it, replace "echo" using printf in debug() and say() to
eliminate the temptation of reintroducing the same bug.

Signed-off-by: Danny Lin <danny0838@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Danny Lin 2015-05-08 08:56:59 +08:00 committed by Junio C Hamano
parent 16018ae5fb
commit 2ded109b51

View File

@ -51,14 +51,21 @@ prefix=
debug()
{
if [ -n "$debug" ]; then
echo "$@" >&2
printf "%s\n" "$*" >&2
fi
}
say()
{
if [ -z "$quiet" ]; then
echo "$@" >&2
printf "%s\n" "$*" >&2
fi
}
progress()
{
if [ -z "$quiet" ]; then
printf "%s\r" "$*" >&2
fi
}
@ -599,7 +606,7 @@ cmd_split()
eval "$grl" |
while read rev parents; do
revcount=$(($revcount + 1))
say -n "$revcount/$revmax ($createcount) "
progress "$revcount/$revmax ($createcount)"
debug "Processing commit: $rev"
exists=$(cache_get $rev)
if [ -n "$exists" ]; then