public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Danny Lin <danny0838@gmail•com>
Cc: git develop <git@vger•kernel.org>
Subject: Re: [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split()
Date: Wed, 06 May 2015 12:49:11 -0700	[thread overview]
Message-ID: <xmqqfv79trk8.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAMbsUu4bix6pJA4OOoMSwYu0M6nO1+aZ7RLXU5sSOdOevN_Wzw@mail.gmail.com> (Danny Lin's message of "Thu, 7 May 2015 02:58:21 +0800")

Danny Lin <danny0838@gmail•com> writes:

> cmd_split() prints a CR char by assigning a variable
> with a literal CR in the source code, which could be
> trimmed or mis-processed in some terminals. Replace
> with $(printf '\r') to fix it.
>
> Signed-off-by: Danny Lin <danny0838@gmail•com>
> ---
>  contrib/subtree/git-subtree.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index fa1a583..3a581fc 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -596,10 +596,11 @@ cmd_split()
>      revmax=$(eval "$grl" | wc -l)
>      revcount=0
>      createcount=0
> +    CR=$(printf '\r')
>      eval "$grl" |
>      while read rev parents; do
>          revcount=$(($revcount + 1))
> -        say -n "$revcount/$revmax ($createcount)
> "
> +        say -n "$revcount/$revmax ($createcount)$CR"

Interesting.  I would have expected, especially this is a portability-fix
change, that the change would be a single liner

-	say -n ...
+	printf "%s\r" "$revcount/$revmax ($createcount)"

that does not touch any other line.

>          debug "Processing commit: $rev"
>          exists=$(cache_get $rev)
>          if [ -n "$exists" ]; then

  reply	other threads:[~2015-05-06 19:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-05 17:20 [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split() Danny Lin
2015-05-05 19:11 ` Junio C Hamano
2015-05-06  9:57   ` Danny Lin
2015-05-06 17:16     ` Junio C Hamano
2015-05-06 18:58       ` Danny Lin
2015-05-06 19:49         ` Junio C Hamano [this message]
2015-05-06 19:58           ` Eric Sunshine
  -- strict thread matches above, loose matches on Subject: below --
2015-05-07  3:39 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-04  6:13 Danny Lin
2015-05-04 21:14 ` Junio C Hamano

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=xmqqfv79trk8.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=danny0838@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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