{"thread":{"id":"61985","subject":"builtin/config: --name-only doesn't imply --show-names in \"git config get\"","startedAt":"2024-08-21T08:10:45Z","lastAt":"2024-08-22T14:54:45Z","messageCount":6,"participants":["Yukai Chou","Junio C Hamano","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"501408","messageId":"CAEg0tHTWzgD5bw3oK7-Rtv9oTymqyhvZz3bcJ7yNRhF8wXMLGA@mail.gmail.com","threadId":"61985","inReplyTo":null,"subject":"builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Yukai Chou","fromEmail":"muzimuzhi@gmail.com","sentAt":"2024-08-21T08:10:33Z","receivedAt":"2024-08-21T08:10:45Z","isPatch":false,"sender":{"key":"muzimuzhi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6376638?v=4"},"body":"The v2.46.0 doc of git-config(1) says\n\n> --name-only\n> Output only the names of config variables for `list` or `get`.\nhttps://git-scm.com/docs/git-config#Documentation/git-config.txt---name-only\n\nBut the behavior of --name-only is more like \"disable non-name outputs\nand leave the output state of names as-is\". Thus using --name-only\nalone, one gets totally empty lines (which might be weird); only using\n--name-only and --show-names together, can one get output of just\nnames.\n\n# get empty line(s)\ngit config get --all --name-only remote.origin.fetch\n# get lines of name(s)\ngit config get --all --show-names --name-only remote.origin.fetch\n\nEither the doc or the behavior of --name-only needs some adjustment.\n\nYukai Chou\n"},{"id":"501440","messageId":"xmqqttfd2734.fsf@gitster.g","threadId":"61985","inReplyTo":"CAEg0tHTWzgD5bw3oK7-Rtv9oTymqyhvZz3bcJ7yNRhF8wXMLGA@mail.gmail.com","subject":"Re: builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-21T16:06:55Z","receivedAt":"2024-08-21T16:07:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yukai Chou <muzimuzhi@gmail.com> writes:\n\n> The v2.46.0 doc of git-config(1) says\n>\n>> --name-only\n>> Output only the names of config variables for `list` or `get`.\n> https://git-scm.com/docs/git-config#Documentation/git-config.txt---name-only\n>\n> But the behavior of --name-only is more like \"disable non-name outputs\n> and leave the output state of names as-is\". Thus using --name-only\n> alone, one gets totally empty lines (which might be weird); only using\n> --name-only and --show-names together, can one get output of just\n> names.\n>\n> # get empty line(s)\n> git config get --all --name-only remote.origin.fetch\n> # get lines of name(s)\n> git config get --all --show-names --name-only remote.origin.fetch\n>\n> Either the doc or the behavior of --name-only needs some adjustment.\n\nThis argues for making \"all\" imply we need to show the name of the\nconfiguration variable, and introducing an option \"--hide-name\" to\nomit the name.  That way, you'd need to give clearly contradicting\n\"--hide-name\" and \"--name-only\" together to get a nonsense output.\n"},{"id":"501461","messageId":"CAEg0tHQVK9hgcHTzn-ZPdwoFbbYFB2joeT0jLQgtD6yEH+1GiA@mail.gmail.com","threadId":"61985","inReplyTo":"xmqqttfd2734.fsf@gitster.g","subject":"Re: builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Yukai Chou","fromEmail":"muzimuzhi@gmail.com","sentAt":"2024-08-21T20:28:34Z","receivedAt":"2024-08-21T20:28:46Z","isPatch":false,"sender":{"key":"muzimuzhi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6376638?v=4"},"body":"Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道：\n>\n> Yukai Chou <muzimuzhi@gmail.com> writes:\n>\n> > # get empty line(s)\n> > git config get --all --name-only remote.origin.fetch\n> > # get lines of name(s)\n> > git config get --all --show-names --name-only remote.origin.fetch\n> >\n> > Either the doc or the behavior of --name-only needs some adjustment.\n>\n> This argues for making \"all\" imply we need to show the name of the\n> configuration variable,\n\nSorry can you elaborate on what that \"all\" meant? A new option \"--show-all\"?\n\n> and introducing an option \"--hide-name\" to\n> omit the name.  That way, you'd need to give clearly contradicting\n> \"--hide-name\" and \"--name-only\" together to get a nonsense output.\n\nI have a feeling that finally a collection of options shared by \"git\nconfig list\" and \"git config get\" will be introduced to fully control\nwhat they output, and even make the form of output given by one of\n\"git config list\" and \"git config get\" look exactly like the other.\n\nAn ideal design:\n\n--show-all\n--[no-]show-scope\n--[no-]show-origin\n--[no-]show-name\n--[no-]show-value\n--hide-all\n--separator=<sep> # fuzzy name?\n\nInitial options\n- git config list: --hide-all --show-name --show-value --separator=\"=\"\n- git config get: --hide-all --show-value --separator=\" \"\n\nThe drawback is, quite some combinations of such options are nonsense.\n\nYukai\n"},{"id":"501462","messageId":"xmqqttfdwq0w.fsf@gitster.g","threadId":"61985","inReplyTo":"CAEg0tHQVK9hgcHTzn-ZPdwoFbbYFB2joeT0jLQgtD6yEH+1GiA@mail.gmail.com","subject":"Re: builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-21T20:59:43Z","receivedAt":"2024-08-21T20:59:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yukai Chou <muzimuzhi@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道：\n>>\n>> Yukai Chou <muzimuzhi@gmail.com> writes:\n>>\n>> > # get empty line(s)\n>> > git config get --all --name-only remote.origin.fetch\n>> > # get lines of name(s)\n>> > git config get --all --show-names --name-only remote.origin.fetch\n>> >\n>> > Either the doc or the behavior of --name-only needs some adjustment.\n>>\n>> This argues for making \"all\" imply we need to show the name of the\n>> configuration variable,\n>\n> Sorry can you elaborate on what that \"all\" meant? A new option \"--show-all\"?\n\nSorry, but \"--all\" is probably a red herring.\n\nWhat I wanted to say was that we can \n\n (1) get rid of \"--show-name\",\n\n (2) have the combination of options that can emit values for more\n    than one key to automatically show both name and value, and\n\n (3) add \"--hide-name\" so that such command can still show only the\n     value.\n\nwhere I mixed up (2) and \"all\".  In fact, \"--all\" is not something\nthat gives values for more than one key (it is things like regexp\nand urlmatch).\n\nFor example:\n\n $ git config --get-regexp 'sendemail\\..*'\n\nwould show values for more than one variable, and depending on the \nvariable, it may show the values for one variable more than once.\nAccording to the documentation, this was replaced with\n\n    --get-regexp <name-regexp>::\n            Replaced by `git config get --all --show-names --regexp <name-regexp>`.\n\nbut it could have been\n\n    git config get --all --regexp <name-regexp>\n\nas it is clear --regexp could give results for more than one key.\n\nThis points at a bug in the documentation, by the way.  \"git config --get-all\"\nis described like so:\n\n    --get-all <name> [<value-pattern>]::\n            Replaced by `git config get [--value=<pattern>] --all --show-names <name>`.\n\nbut this gives values for only one key, and the command does not\nshow key names.  It is replaced by\n\n\tgit config get [--value=<pattern>] --all <name>\n\nwithout \"--show-names\".\n\n"},{"id":"501469","messageId":"ZsbTPeFIPcqnEd-n@tanuki","threadId":"61985","inReplyTo":"xmqqttfdwq0w.fsf@gitster.g","subject":"Re: builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-08-22T05:57:22Z","receivedAt":"2024-08-22T05:57:27Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Aug 21, 2024 at 01:59:43PM -0700, Junio C Hamano wrote:\n> Yukai Chou <muzimuzhi@gmail.com> writes:\n> \n> > Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道：\n> >>\n> >> Yukai Chou <muzimuzhi@gmail.com> writes:\n> >>\n> >> > # get empty line(s)\n> >> > git config get --all --name-only remote.origin.fetch\n> >> > # get lines of name(s)\n> >> > git config get --all --show-names --name-only remote.origin.fetch\n> >> >\n> >> > Either the doc or the behavior of --name-only needs some adjustment.\n> >>\n> >> This argues for making \"all\" imply we need to show the name of the\n> >> configuration variable,\n> >\n> > Sorry can you elaborate on what that \"all\" meant? A new option \"--show-all\"?\n> \n> Sorry, but \"--all\" is probably a red herring.\n> \n> What I wanted to say was that we can \n> \n>  (1) get rid of \"--show-name\",\n> \n>  (2) have the combination of options that can emit values for more\n>     than one key to automatically show both name and value, and\n> \n>  (3) add \"--hide-name\" so that such command can still show only the\n>      value.\n> \n> where I mixed up (2) and \"all\".  In fact, \"--all\" is not something\n> that gives values for more than one key (it is things like regexp\n> and urlmatch).\n\nI wouldn't get rid of `--show-name`, as it also implicitly brings along\n`--no-show-name`, basically checking the box for (3).\n\nIn any case, I agree that it probably makes sense to do (2). Unless I'm\nmistaken, the only case we need to care about is `--regexp`, because\nwithout all the emitted names would be the same anyway.\n\nPatrick\n"},{"id":"501537","messageId":"xmqqa5h4wqts.fsf@gitster.g","threadId":"61985","inReplyTo":"ZsbTPeFIPcqnEd-n@tanuki","subject":"Re: builtin/config: --name-only doesn't imply --show-names in \"git config get\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-22T14:54:39Z","receivedAt":"2024-08-22T14:54:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> In any case, I agree that it probably makes sense to do (2). Unless I'm\n> mistaken, the only case we need to care about is `--regexp`, because\n> without all the emitted names would be the same anyway.\n\nOK.  And we need to fix the \"config --get-all\" description, which\ndoes not need --show-names there, I think.\n\nThanks.\n"}]}