git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* couple questions about git "logical variables" and "git var"
@ 2017-10-05  9:11 rpjday
  2017-10-05  9:56 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: rpjday @ 2017-10-05  9:11 UTC (permalink / raw)
  To: git

   i just ran across "git var" for the first time, and it seems a bit weird.
it refers to the (apparently) four git "logical variables":

  - GIT_AUTHOR_IDENT
  - GIT_COMMITTER_IDENT
  - GIT_EDITOR
  - GIT_PAGER

first question -- what is it about precisely those four variables that makes
them "logical" variables in git parlance? just those four? no others?

   also, the man page "man git-var" seems wrong:

"OPTIONS
   -l
     Cause the logical variables to be listed. In addition, all the variables
     of the Git configuration file .git/config are listed as well."

no, if i run "git var -l", i see not only the logical variables, but i
see *all* of the available config settings (system and global), not just
those in .git/config (unless i'm misreading what that is supposed to mean).

   thoughts?

rday

p.s. yes, i realize this command is deprecated in favour of "git config -l",
but as long as it's available, it should work as described in the man page.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: couple questions about git "logical variables" and "git var"
  2017-10-05  9:11 couple questions about git "logical variables" and "git var" rpjday
@ 2017-10-05  9:56 ` Jeff King
  2017-10-06  2:35   ` Jonathan Nieder
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-10-05  9:56 UTC (permalink / raw)
  To: rpjday; +Cc: git

On Thu, Oct 05, 2017 at 05:11:04AM -0400, rpjday@crashcourse.ca wrote:

>   i just ran across "git var" for the first time, and it seems a bit weird.
> it refers to the (apparently) four git "logical variables":

It's definitely weird.

>  - GIT_AUTHOR_IDENT
>  - GIT_COMMITTER_IDENT
>  - GIT_EDITOR
>  - GIT_PAGER
> 
> first question -- what is it about precisely those four variables that makes
> them "logical" variables in git parlance? just those four? no others?

It was introduced in the very early days as a way for scripts to get
access to "standard" values that would be computed the same way as the C
portions of Git.  But it hasn't generally been kept up to date with new
possible variables.

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. We'd probably have done better to introduce a "git editor"
command which can be run from any language.

But as most of Git is written in C these days, it seems that nobody had
enough interest to smooth out these kinds of rough edges.

>   also, the man page "man git-var" seems wrong:
> 
> "OPTIONS
>   -l
>     Cause the logical variables to be listed. In addition, all the variables
>     of the Git configuration file .git/config are listed as well."
> 
> no, if i run "git var -l", i see not only the logical variables, but i
> see *all* of the available config settings (system and global), not just
> those in .git/config (unless i'm misreading what that is supposed to mean).

Yes, I agree the description there is wrong. I'd have to dig in the
history to be sure, but I'm pretty sure it has _always_ been wrong.

> p.s. yes, i realize this command is deprecated in favour of "git config -l",
> but as long as it's available, it should work as described in the man page.

Yes, though I think fixing the manpage is the right way to make them
consistent.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: couple questions about git "logical variables" and "git var"
  2017-10-05  9:56 ` Jeff King
@ 2017-10-06  2:35   ` Jonathan Nieder
  2017-10-06  4:33     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2017-10-06  2:35 UTC (permalink / raw)
  To: Jeff King; +Cc: rpjday, git

Jeff King wrote:
> On Thu, Oct 05, 2017 at 05:11:04AM -0400, rpjday@crashcourse.ca wrote:

>>  - GIT_AUTHOR_IDENT
>>  - GIT_COMMITTER_IDENT
>>  - GIT_EDITOR
>>  - GIT_PAGER
>>
>> first question -- what is it about precisely those four variables that makes
>> them "logical" variables in git parlance? just those four? no others?
>
> It was introduced in the very early days as a way for scripts to get
> access to "standard" values that would be computed the same way as the C
> portions of Git.  But it hasn't generally been kept up to date with new
> possible variables.
>
> 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?

>               We'd probably have done better to introduce a "git editor"
> command which can be run from any language.

I remember that we discussed this at the time but don't remember why
it didn't happen.  It seems like a good idea.

[...]
>> p.s. yes, i realize this command is deprecated in favour of "git config -l",
>> but as long as it's available, it should work as described in the man page.
>
> Yes, though I think fixing the manpage is the right way to make them
> consistent.

Agreed as well.  rday, care to take a stab at wording?

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: couple questions about git "logical variables" and "git var"
  2017-10-06  2:35   ` Jonathan Nieder
@ 2017-10-06  4:33     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2017-10-06  4:33 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: rpjday, git

On Thu, Oct 05, 2017 at 07:35:30PM -0700, Jonathan Nieder wrote:

> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-06  4:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05  9:11 couple questions about git "logical variables" and "git var" rpjday
2017-10-05  9:56 ` Jeff King
2017-10-06  2:35   ` Jonathan Nieder
2017-10-06  4:33     ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).