{"thread":{"id":"46907","subject":"couple questions about git \"logical variables\" and \"git var\"","startedAt":"2017-10-05T09:11:10Z","lastAt":"2017-10-06T04:33:07Z","messageCount":4,"participants":["rpjday@crashcourse.ca","Jeff King","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"329731","messageId":"20171005051104.Horde.8J0J7-XC6jD4AOgtYrou3Na@crashcourse.ca","threadId":"46907","inReplyTo":null,"subject":"couple questions about git \"logical variables\" and \"git var\"","fromName":"","fromEmail":"rpjday@crashcourse.ca","sentAt":"2017-10-05T09:11:04Z","receivedAt":"2017-10-05T09:11:10Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"   i just ran across \"git var\" for the first time, and it seems a bit weird.\nit refers to the (apparently) four git \"logical variables\":\n\n  - GIT_AUTHOR_IDENT\n  - GIT_COMMITTER_IDENT\n  - GIT_EDITOR\n  - GIT_PAGER\n\nfirst question -- what is it about precisely those four variables that makes\nthem \"logical\" variables in git parlance? just those four? no others?\n\n   also, the man page \"man git-var\" seems wrong:\n\n\"OPTIONS\n   -l\n     Cause the logical variables to be listed. In addition, all the variables\n     of the Git configuration file .git/config are listed as well.\"\n\nno, if i run \"git var -l\", i see not only the logical variables, but i\nsee *all* of the available config settings (system and global), not just\nthose in .git/config (unless i'm misreading what that is supposed to mean).\n\n   thoughts?\n\nrday\n\np.s. yes, i realize this command is deprecated in favour of \"git config -l\",\nbut as long as it's available, it should work as described in the man page.\n\n\n\n\n\n"},{"id":"329741","messageId":"20171005095636.mpp2ohf7vp7mtzeb@sigill.intra.peff.net","threadId":"46907","inReplyTo":"20171005051104.Horde.8J0J7-XC6jD4AOgtYrou3Na@crashcourse.ca","subject":"Re: couple questions about git \"logical variables\" and \"git var\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-05T09:56:36Z","receivedAt":"2017-10-05T09:56:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 05, 2017 at 05:11:04AM -0400, rpjday@crashcourse.ca wrote:\n\n>   i just ran across \"git var\" for the first time, and it seems a bit weird.\n> it refers to the (apparently) four git \"logical variables\":\n\nIt's definitely weird.\n\n>  - GIT_AUTHOR_IDENT\n>  - GIT_COMMITTER_IDENT\n>  - GIT_EDITOR\n>  - GIT_PAGER\n> \n> first question -- what is it about precisely those four variables that makes\n> them \"logical\" variables in git parlance? just those four? no others?\n\nIt was introduced in the very early days as a way for scripts to get\naccess to \"standard\" values that would be computed the same way as the C\nportions of Git.  But it hasn't generally been kept up to date with new\npossible variables.\n\nIt also only tells half the story. You have to know not just what's in\n$GIT_EDITOR, but you have to know the right way to evaluate it. There's\na git_editor helper in git-sh-setup, but other scripting languages are\non their own. We'd probably have done better to introduce a \"git editor\"\ncommand which can be run from any language.\n\nBut as most of Git is written in C these days, it seems that nobody had\nenough interest to smooth out these kinds of rough edges.\n\n>   also, the man page \"man git-var\" seems wrong:\n> \n> \"OPTIONS\n>   -l\n>     Cause the logical variables to be listed. In addition, all the variables\n>     of the Git configuration file .git/config are listed as well.\"\n> \n> no, if i run \"git var -l\", i see not only the logical variables, but i\n> see *all* of the available config settings (system and global), not just\n> those in .git/config (unless i'm misreading what that is supposed to mean).\n\nYes, I agree the description there is wrong. I'd have to dig in the\nhistory to be sure, but I'm pretty sure it has _always_ been wrong.\n\n> p.s. yes, i realize this command is deprecated in favour of \"git config -l\",\n> but as long as it's available, it should work as described in the man page.\n\nYes, though I think fixing the manpage is the right way to make them\nconsistent.\n\n-Peff\n"},{"id":"329834","messageId":"20171006023530.GA134987@aiede.mtv.corp.google.com","threadId":"46907","inReplyTo":"20171005095636.mpp2ohf7vp7mtzeb@sigill.intra.peff.net","subject":"Re: couple questions about git \"logical variables\" and \"git var\"","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-10-06T02:35:30Z","receivedAt":"2017-10-06T02:36:02Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jeff King wrote:\n> On Thu, Oct 05, 2017 at 05:11:04AM -0400, rpjday@crashcourse.ca wrote:\n\n>>  - GIT_AUTHOR_IDENT\n>>  - GIT_COMMITTER_IDENT\n>>  - GIT_EDITOR\n>>  - GIT_PAGER\n>>\n>> first question -- what is it about precisely those four variables that makes\n>> them \"logical\" variables in git parlance? just those four? no others?\n>\n> It was introduced in the very early days as a way for scripts to get\n> access to \"standard\" values that would be computed the same way as the C\n> portions of Git.  But it hasn't generally been kept up to date with new\n> possible variables.\n>\n> It also only tells half the story. You have to know not just what's in\n> $GIT_EDITOR, but you have to know the right way to evaluate it. There's\n> a git_editor helper in git-sh-setup, but other scripting languages are\n> on their own.\n\nI am not sure I understand the complaint here.  git-var(1) says:\n\n\tGIT_EDITOR\n\t   Text editor for use by Git commands. The value is meant to be\n\t   interpreted by the shell when it is used. Examples: [...]\n\nAre you saying that the output of the command should quote that\nmanpage, so as to tell the rest of the story?\n\n>               We'd probably have done better to introduce a \"git editor\"\n> command which can be run from any language.\n\nI remember that we discussed this at the time but don't remember why\nit didn't happen.  It seems like a good idea.\n\n[...]\n>> p.s. yes, i realize this command is deprecated in favour of \"git config -l\",\n>> but as long as it's available, it should work as described in the man page.\n>\n> Yes, though I think fixing the manpage is the right way to make them\n> consistent.\n\nAgreed as well.  rday, care to take a stab at wording?\n\nThanks,\nJonathan\n"},{"id":"329845","messageId":"20171006043300.to2d2zv6ludbinrh@sigill.intra.peff.net","threadId":"46907","inReplyTo":"20171006023530.GA134987@aiede.mtv.corp.google.com","subject":"Re: couple questions about git \"logical variables\" and \"git var\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-06T04:33:01Z","receivedAt":"2017-10-06T04:33:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 05, 2017 at 07:35:30PM -0700, Jonathan Nieder wrote:\n\n> > It also only tells half the story. You have to know not just what's in\n> > $GIT_EDITOR, but you have to know the right way to evaluate it. There's\n> > a git_editor helper in git-sh-setup, but other scripting languages are\n> > on their own.\n> \n> I am not sure I understand the complaint here.  git-var(1) says:\n> \n> \tGIT_EDITOR\n> \t   Text editor for use by Git commands. The value is meant to be\n> \t   interpreted by the shell when it is used. Examples: [...]\n> \n> Are you saying that the output of the command should quote that\n> manpage, so as to tell the rest of the story?\n\nNo, I just meant that after reading that manpage, I'm not sure I would\nhave picked up the subtlety that shell scripts need to call:\n\n  eval \"$GIT_EDITOR\" '\"$@\"'\n\nand not:\n\n  \"$GIT_EDITOR\" \"$@\"\n\nor:\n\n  $GIT_EDITOR \"$@\"\n\n(And likewise, other languages need to make sure they run \"sh -c ...\"\nand not a straight spawn/exec of the editor command).\n\nIf the command were instead:\n\n  git editor \"$@\"\n\nthat's harder to get wrong.\n\n-Peff\n"}]}