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

Re: [PATCH] contrib/subtree: unwrap tag refs

From
Jeff King <peff@peff.net>
Date
Nov 13, 2015, 05:01 UTC
Message-ID
<20151113050123.GA29708@sigill.intra.peff.net>
In-Reply-To
<87h9kqwm67.fsf@waller.obbligato.org>
On Thu, Nov 12, 2015 at 10:36:16PM -0600, David A. Greene wrote:
Show 7 quoted lines
> > +				sub="$(git rev-parse "$b^0")" || die "could not rev-parse split hash $b from commit $sq"
> 
> This seems like odd quoting.  Would not this do the same?
> 
> 				sub="$(git rev-parse $b^0)" || die "could not rev-parse split hash $b from commit $sq"
> 
> Perhaps I am missing something.

The former is quoting "$b" against whitespace splitting in the sub-command. Given that the value just came from a "read" call, I think by definition it cannot contains IFS. Still, quoting here is a good habit.

It is actually the _outer_ quotes that are unnecessary, as variable assignment does not do extra splitting. So:

  foo=$(echo one two)

will put the full "one two" into $foo. But the quotes do not hurt anything, and it is a reasonable style to use them to avoid this discussion. :)

It also matches style-wise with nearby assignments, like:
  main="$b"
-Peff
Previous: David A. GreeneNext: David A. Greene
Message 3 of 5 in “contrib/subtree: unwrap tag refs”
  1. contrib/subtree: unwrap tag refsRob Mayoff, Nov 13, 2015
  2. David A. GreeneNov 13, 2015
  3. Jeff KingNov 13, 2015
  4. David A. GreeneJan 13, 2016
  5. Junio C HamanoJan 13, 2016

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.