git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split()

From
Danny Lin <danny0838@gmail.com>
Date
May 5, 2015, 17:20 UTC
Message-ID
<CAMbsUu6xZrMu_jrV=jR4XNLf1UXLApBiAWJiWJuKRb4xN90QJQ@mail.gmail.com>
2015-05-05 5:14 GMT+08:00 Junio C Hamano <gitster@pobox.com>:
Show 10 quoted lines
> Danny Lin <danny0838@gmail.com> writes:
>
>> From dc549b6b4ec36f8faf9c6f7bb1e343ef7babd14f Mon Sep 17 00:00:00 2001
>> From: Danny Lin <danny0838@gmail.com>
>> Date: Mon, 4 May 2015 14:09:38 +0800
>> Subject: [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split()
>
> Please do not use multipart/mixed attachments, but instead inline
> your patch.  When doing so, please drop all these four lines above.
>
Oops. How to drop the lines? I'm using Gmail and don't know the way to go.
Show 15 quoted lines
>>
>> cmd_split() prints the info message using "say -n", which
>> makes no sense and could cause the linefeed be trimmed in
>> some cases. This patch fixes the issue.
>
> I think this was written knowing that "say" is merely a thin wrapper
> of "echo" (which is a bad manner but happens to be correct) and
> assuming that everybody's "echo" understands "-n" (which is not a
> good assumption) to implement "progress display" that shows the "N
> out of M done" output over and over on the same physical line.
>
> So,... contrary to your "makes no sense" claim, what it tries to do
> makes perfect sense to me, even though its execution seems somewhat
> poor.
>

The original version has a CR (yes, it's CR, not LF) at the end of the "say -n" string, which is weird. If it's meant to print a linefeed, we should remove the CR and use "say". If it's meant not to print a linefeed, we still should remove the CR.

CR makes the shell behave weird, sometimes a linefeed is shown and sometimes not.

For example, in my shell (git version 2.3.7.windows.1), I frequently get a crowded message like this:

$ git subtree split -P subdir/ 1/3 (0)2/3 (1)3/3 (2)c9ad5da42e2bc00c76616207fe73978887656235

While sometimes like this: $ git subtree split -P subdir/ 1/3 (0)2/3 (1) 3/3 (2) c9ad5da42e2bc00c76616207fe73978887656235

The two behaviors happen almost randomly, at least I cannot predict.
Show 17 quoted lines
>> ---
>>  contrib/subtree/git-subtree.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index fa1a583..28a1377 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -599,7 +599,7 @@ cmd_split()
>>       eval "$grl" |
>>       while read rev parents; do
>>               revcount=$(($revcount + 1))
>> -             say -n "$revcount/$revmax ($createcount)"
>> +             say "$revcount/$revmax ($createcount)"
>>               debug "Processing commit: $rev"
>>               exists=$(cache_get $rev)
>>               if [ -n "$exists" ]; then
Next: Junio C Hamano
Message 1 of 7 in “Re: [PATCH] contrib/subtree: fix linefeeds trimming for cmd_split()”
  1. Danny LinMay 5, 2015
  2. Junio C HamanoMay 5, 2015
  3. Danny LinMay 6, 2015
  4. Junio C HamanoMay 6, 2015
  5. Danny LinMay 6, 2015
  6. Junio C HamanoMay 6, 2015
  7. Eric SunshineMay 6, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.