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

Re: [PATCH] contrib/subtree: remove contradicting use options on echo wrapper

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 15, 2013, 22:39 UTC
Message-ID
<7vtxpdfbhx.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALeLG_=p9k2B6AmTG0iKf9GpGB=_6kcECmCdDV1nmruJ4bdGcw@mail.gmail.com>
Paul Campbell <pcampbell@kemitix.net> writes:
Show 7 quoted lines
> Remove redundant -n option and raw ^M in call to echo.
>
> Call to 'say' function, a wrapper of 'echo', passed the parameter -n, then
> included a raw ^M newline in the end of the last parameter. Yet the -n option
> is meant to suppress the addition of new line by echo.
>
> Signed-off-by: Paul Campbell <pcampbell@kemitix.net>

I generally do not comment on comment on contrib/ material, and I am not familiar with subtree myself, but

	for count in $(seq 0 $total)
        do
		echo -n "$count/$total^M"
                ... do heavy lifting ...
	done
        echo "Done                  "

is an idiomatic way to implement a progress meter without scrolling more important message you gave earlier to the user before entering the loop away. The message appears, carrige-return moves the cursor to the beginning of the line without going to the next line, and the next iteration overwrites the previous count. Finally, the progress meter is overwritten with the "Done" message. Alternatively you can wrap it up with

	echo
        echo Done
if you want to leave the final progress "100/100" before saying "Done."
Isn't that what this piece of code trying to do?
Show 18 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 8a23f58..51146bd 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -592,7 +592,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
Previous: Paul CampbellNext: Paul Campbell
Message 2 of 3 in “contrib/subtree: remove contradicting use options on echo wrapper”
  1. contrib/subtree: remove contradicting use options on echo wrapperPaul Campbell, Feb 15, 2013
  2. Junio C HamanoFeb 15, 2013
  3. Paul CampbellFeb 15, 2013

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.