{"thread":{"id":"14466","subject":"git config oddity","startedAt":"2008-07-15T14:44:51Z","lastAt":"2008-07-15T15:35:19Z","messageCount":5,"participants":["Sverre Rabbelier","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"83396","messageId":"bd6139dc0807150744l78eb8d54ld167d3a9a5a600f@mail.gmail.com","threadId":"14466","inReplyTo":null,"subject":"git config oddity","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-07-15T14:44:51Z","receivedAt":"2008-07-15T14:44:51Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"Heya,\n\nI noticed today that when unsetting the last value in a group git\nconfig leaves the empty group header. I was somewhat surprised here,\nbut I am guessing it has a purpose? Anyway, I also noticed (and this\nthrew my manual config parser off) that when later on an option is set\nto that empty group, a new group is created with the same name. Is\nthis something I have to deal with in my parser (e.g., should I keep\nscanning the file for occurrences of my header and allow for empty\ngroups, or is this a bug in git config? Either is fine with me, was\njust wondering :).\n\n-----------------\nsverre@Laptop-Sverre:~/code$ mkdir config-oddity\nsverre@Laptop-Sverre:~/code$ cd config-oddity/\nsverre@Laptop-Sverre:~/code/config-oddity$ git init\nInitialized empty Git repository in /home/sverre/code/config-oddity/.git/\nsverre@Laptop-Sverre:~/code/config-oddity$ cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\nsverre@Laptop-Sverre:~/code/config-oddity$ git config foo.bar spam\nsverre@Laptop-Sverre:~/code/config-oddity$ cat .git/config # as expected\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[foo]\n\tbar = spam\nsverre@Laptop-Sverre:~/code/config-oddity$ git config --unset foo.bar\nsverre@Laptop-Sverre:~/code/config-oddity$ cat .git/config # dubious,\nbut acceptable\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[foo]\nsverre@Laptop-Sverre:~/code/config-oddity$ git config foo.bar eggs\nsverre@Laptop-Sverre:~/code/config-oddity$ cat .git/config # errr? two\n[foo] headers?\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[foo]\n[foo]\n\tbar = eggs\nsverre@Laptop-Sverre:~/code/config-oddity$\n-----------------\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"83399","messageId":"alpine.DEB.1.00.0807151600170.8950@racer","threadId":"14466","inReplyTo":"bd6139dc0807150744l78eb8d54ld167d3a9a5a600f@mail.gmail.com","subject":"Re: git config oddity","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-15T15:02:16Z","receivedAt":"2008-07-15T15:02:16Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 15 Jul 2008, Sverre Rabbelier wrote:\n\n> I noticed today that when unsetting the last value in a group git\n> config leaves the empty group header.\n\nThat is on purpose.  As .git/config was always meant as a user-editable \nfile, you can put comments into that section.  Or comment out some values.\n\nSo \"git config\" does not remove the section, even if no variable is there \nat the moment.\n\nIt is somewhat unfortunate that setting a variable does not find the \nsection; the reason is that it sees sections only when a variable is set \n(to avoid having to do the parsing itself).\n\nHth,\nDscho\n"},{"id":"83405","messageId":"bd6139dc0807150829n2b3c88d7p18c203e93cd4e0c1@mail.gmail.com","threadId":"14466","inReplyTo":"alpine.DEB.1.00.0807151600170.8950@racer","subject":"Re: git config oddity","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-07-15T15:29:15Z","receivedAt":"2008-07-15T15:29:15Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Tue, Jul 15, 2008 at 5:02 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>> I noticed today that when unsetting the last value in a group git\n>> config leaves the empty group header.\n>\n> That is on purpose.  As .git/config was always meant as a user-editable\n> file, you can put comments into that section.  Or comment out some values.\n\nOk, this makes sense :). I agree that I would be unhappily surprised\nif I found that git removed a section that I had put some comments in\nwhen I unset a variable.\n\n> It is somewhat unfortunate that setting a variable does not find the\n> section; the reason is that it sees sections only when a variable is set\n> (to avoid having to do the parsing itself).\n\nAh, unfortunate indeed. I'm not sure I understand why it does not see\nthe existing header? I had a look at config.c but I couldn't really\nmake out why it doesn't. Would it be difficult to add that?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"83406","messageId":"alpine.DEB.1.00.0807151631520.8950@racer","threadId":"14466","inReplyTo":"bd6139dc0807150829n2b3c88d7p18c203e93cd4e0c1@mail.gmail.com","subject":"Re: git config oddity","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-15T15:33:23Z","receivedAt":"2008-07-15T15:33:23Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 15 Jul 2008, Sverre Rabbelier wrote:\n\n> On Tue, Jul 15, 2008 at 5:02 PM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> \n> > It is somewhat unfortunate that setting a variable does not find the \n> > section; the reason is that it sees sections only when a variable is \n> > set (to avoid having to do the parsing itself).\n> \n> Ah, unfortunate indeed. I'm not sure I understand why it does not see \n> the existing header? I had a look at config.c but I couldn't really make \n> out why it doesn't.\n\nThe config writing uses the config parser to determine where the locations \nof the config variables (and therefore, sections) are by using the parser, \nand remembering the position in the file.\n\n> Would it be difficult to add that?\n\nYes.\n\nCiao,\nDscho\n"},{"id":"83407","messageId":"bd6139dc0807150835p1da70becj7fe28f6fa7d79ed5@mail.gmail.com","threadId":"14466","inReplyTo":"alpine.DEB.1.00.0807151631520.8950@racer","subject":"Re: git config oddity","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-07-15T15:35:19Z","receivedAt":"2008-07-15T15:35:19Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Tue, Jul 15, 2008 at 5:33 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> The config writing uses the config parser to determine where the locations\n> of the config variables (and therefore, sections) are by using the parser,\n> and remembering the position in the file.\n\nOk, thanks for the explanation, I'll add a workaround in my code.\n\n-- \nCheers,\n\nSverre Rabbelier\n"}]}