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

Fwd: [PATCH] git-subtree: Avoid using echo -n even indirectly

From
Paolo Giarrusso <p.giarrusso@gmail.com>
Date
Oct 9, 2013, 10:32 UTC
Message-ID
<CAAcnjCQ+c=8wYZkqS7VzZ_bDDDkSwdQ3qdz77osrSpKDS9ON7Q@mail.gmail.com>
In-Reply-To
<CAAcnjCT1bdR+9kDW=q_326OhiSMm3_j-yOh0-ayTkObK3bZ3bQ@mail.gmail.com>
(Resending without HTML).
On Wed, Oct 9, 2013 at 12:20 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:
Show 16 quoted lines
>
> On Wed, Oct 9, 2013 at 11:57 AM, Paolo G. Giarrusso
> <p.giarrusso@gmail.com> wrote:
> > diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> > index 7d7af03..ebfb78f 100755
> > --- a/contrib/subtree/git-subtree.sh
> > +++ b/contrib/subtree/git-subtree.sh
> > @@ -592,7 +592,9 @@ cmd_split()
> >         eval "$grl" |
> >         while read rev parents; do
> >                 revcount=$(($revcount + 1))
> > -               say -n "$revcount/$revmax ($createcount)
> > "
> > +               if [ -z "$quiet" ]; then
> > +                       printf "%s" "$revcount/$revmax ($createcount)
> > " >&2

An additional note for reviewers and appliers: the original and the patched codeboth embed a literal ^M, not a new line, go to back to the beginning of the line and overwrite it, so the above is not a consequence of line-wrap.

I used git-format-patch and git-send-email, and the ^M is visible in Vim in the exported patch (that's why I didn't remark on it). Seeing the email, I wonder whether there's hope something like that can be preserved in an email, and whether the code should use some escape sequence instead.

Show 12 quoted lines
> > +               fi
>
> Reviewers might wish to know that "say" in git-subtree is defined as
>
>         say()
>         {
>                 if [ -z "$quiet" ]; then
>                         echo "$@" >&2
>                fi
>         }
>
> Hence the "if" and the redirect.

Indeed. I considered having a variant of `say` instead of inlining and customizing it, but for once I decided to keep this simple, since this variant of `say` is currently used only once. Otherwise, one could change say to use printf, but that's more invasive.

Cheers,
-- 
Paolo G. Giarrusso - Ph.D. Student, Philipps-University Marburg
http://www.informatik.uni-marburg.de/~pgiarrusso/
Previous: Tay Ray ChuanNext: Johannes Sixt
Message 3 of 9 in “git-subtree: Avoid using echo -n even indirectly”
  1. git-subtree: Avoid using echo -n even indirectlyPaolo G. Giarrusso, Oct 9, 2013
  2. Tay Ray ChuanOct 9, 2013
  3. Fwd: [PATCH] git-subtree: Avoid using echo -n even indirectlyPaolo Giarrusso, Oct 9, 2013
  4. Johannes SixtOct 9, 2013
  5. Matthieu MoyOct 9, 2013
  6. Paolo GiarrussoOct 9, 2013
  7. Jeff KingOct 9, 2013
  8. Jonathan NiederOct 9, 2013
  9. Paolo GiarrussoOct 11, 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.