From: Danny Lin <danny0838@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git develop <git@vger.kernel.org>,
Eric Sunshine <sunshine@sunshineco.com>,
Danny Lin <danny0838@gmail.com>
Subject: [PATCH] contrib/subtree: portability fix for string printing
Date: Fri, 8 May 2015 08:56:59 +0800 [thread overview]
Message-ID: <1431046619-2340-1-git-send-email-danny0838@gmail.com> (raw)
In-Reply-To: <xmqqmw1gp7aa.fsf@gitster.dls.corp.google.com>
Replace echo using printf in debug() and say() for
better portability.
Also re-wrap previous 'say -n "$str<CR>"' using a new
function progress() to prevent CR chars included in the
source code, which could be mal-processed 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.
Signed-off-by: Danny Lin <danny0838@gmail.com>
---
contrib/subtree/git-subtree.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index fa1a583..d4dae7a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -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
--
2.3.7.windows.1
Previous patch had a flaw, revised.
next prev parent reply other threads:[~2015-05-08 0:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 3:39 [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split() Danny Lin
2015-05-07 3:43 ` Danny Lin
2015-05-07 5:10 ` Danny Lin
2015-05-07 18:33 ` Junio C Hamano
2015-05-08 0:51 ` [PATCH] contrib/subtree: portability fix for string printing Danny Lin
2015-05-08 0:56 ` Danny Lin [this message]
2015-05-08 17:49 ` Junio C Hamano
2015-05-08 17:56 ` Eric Sunshine
2015-05-08 18:44 ` Junio C Hamano
2015-05-08 18:55 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431046619-2340-1-git-send-email-danny0838@gmail.com \
--to=danny0838@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).