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

Re: couple questions about git "logical variables" and "git var"

From
Jeff King <peff@peff.net>
Date
Oct 6, 2017, 04:33 UTC
Message-ID
<20171006043300.to2d2zv6ludbinrh@sigill.intra.peff.net>
In-Reply-To
<20171006023530.GA134987@aiede.mtv.corp.google.com>
On Thu, Oct 05, 2017 at 07:35:30PM -0700, Jonathan Nieder wrote:
Show 13 quoted lines
> > It also only tells half the story. You have to know not just what's in
> > $GIT_EDITOR, but you have to know the right way to evaluate it. There's
> > a git_editor helper in git-sh-setup, but other scripting languages are
> > on their own.
> 
> I am not sure I understand the complaint here.  git-var(1) says:
> 
> 	GIT_EDITOR
> 	   Text editor for use by Git commands. The value is meant to be
> 	   interpreted by the shell when it is used. Examples: [...]
> 
> Are you saying that the output of the command should quote that
> manpage, so as to tell the rest of the story?

No, I just meant that after reading that manpage, I'm not sure I would have picked up the subtlety that shell scripts need to call:

  eval "$GIT_EDITOR" '"$@"'
and not:
  "$GIT_EDITOR" "$@"
or:
  $GIT_EDITOR "$@"

(And likewise, other languages need to make sure they run "sh -c ..." and not a straight spawn/exec of the editor command).

If the command were instead:
  git editor "$@"
that's harder to get wrong.
-Peff
Previous: Jonathan Nieder
Message 4 of 4 in “couple questions about git "logical variables" and "git var"”
  1. rpjday@crashcourse.caOct 5, 2017
  2. Jeff KingOct 5, 2017
  3. Jonathan NiederOct 6, 2017
  4. Jeff KingOct 6, 2017

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.