{"thread":{"id":"44826","subject":"git branch --editdescription fatal error","startedAt":"2017-01-06T17:25:50Z","lastAt":"2017-01-06T20:10:12Z","messageCount":6,"participants":["Jake Lambert","Stefan Beller","Ralf Thielow","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"308882","messageId":"MWHPR19MB11357994E6C43DBCC0931CD7BC630@MWHPR19MB1135.namprd19.prod.outlook.com","threadId":"44826","inReplyTo":null,"subject":"git branch --editdescription fatal error","fromName":"Jake Lambert","fromEmail":"jake@onahill.co","sentAt":"2017-01-06T17:25:39Z","receivedAt":"2017-01-06T17:25:50Z","isPatch":false,"sender":{"key":"jake@onahill.co","avatar":null},"body":"Hello,\n\nWhen executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place. I am not too familiar with the inner workings of git, but if you accept pull requests, I'm happy to give it a shot if you can give me directions as to how to submit one to you.\n\nWhile I have you, I would also like to make a feature request for branch descriptions to (optionally) be included in the output of git branch <noargs> (or something like git branch --descriptions). This is particularly helpful where branch names match JIRA tickets numbers or are simply so old I don't remember what they are but don't want to delete them just in case.\n\nThank you for maintaining this absolutely wonderful program, and have a happy New Year!\n\nBest,\nJake\n     \n Jake Lambert\n Full Stack Developer\n \n \n The Company On A Hill\n www.onahill.co\n    "},{"id":"308883","messageId":"CAGZ79kaz_hS9P7vqV9EhZazM_g0OUdRfMtFPJ7gFu-h-ku=NKw@mail.gmail.com","threadId":"44826","inReplyTo":"MWHPR19MB11357994E6C43DBCC0931CD7BC630@MWHPR19MB1135.namprd19.prod.outlook.com","subject":"Re: git branch --editdescription fatal error","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-01-06T17:55:03Z","receivedAt":"2017-01-06T17:55:20Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Jan 6, 2017 at 9:25 AM, Jake Lambert <jake@onahill.co> wrote:\n> Hello,\n>\n> When executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place.\n\nThat seems strange. Is it possible that your config is not writable?\n(.git/config, ~/gitconfig, you'd need to find out where the <branch>\nis configured already via git config --global/--system/--local --list)\n\n> I am not too familiar with the inner workings of git, but if you accept pull requests, I'm happy to give it a shot if you can give me directions as to how to submit one to you.\n\nWe rather do email based workflow, see\nhttps://github.com/git/git/blob/master/Documentation/SubmittingPatches\n(We use github only as a host, you could also obtain it from one of\nhttps://git-blame.blogspot.com/p/git-public-repositories.html)\n\n>\n> While I have you, I would also like to make a feature request for branch descriptions to (optionally) be included in the output of git branch <noargs> (or something like git branch --descriptions). This is particularly helpful where branch names match JIRA tickets numbers or are simply so old I don't remember what they are but don't want to delete them just in case.\n\nApparently the branch descriptions are only used for the request-pull\nsubcommand,\nhttps://github.com/git/git/commit/c0168147831fce00975949213eef3471b7a2b76b\nand the merge message\nhttps://github.com/git/git/commit/898eacd8ada2d012f977948350ed60845e238037\n\n\nIf you want to work on both of these issues, have a look at\nedit_branch_description\nas well as print_ref_list in builtin/branch.c\n\n> Thank you for maintaining this absolutely wonderful program, and have a happy New Year!\n\nHappy new year!\nStefan\n"},{"id":"308885","messageId":"CAN0XMO+zzYOXF2gwr=0Tu-7T5BH7f_L+FhfD8RUenDeq3xFHjA@mail.gmail.com","threadId":"44826","inReplyTo":"CAGZ79kaz_hS9P7vqV9EhZazM_g0OUdRfMtFPJ7gFu-h-ku=NKw@mail.gmail.com","subject":"Re: git branch --editdescription fatal error","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2017-01-06T19:31:44Z","receivedAt":"2017-01-06T19:31:53Z","isPatch":false,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"2017-01-06 18:55 GMT+01:00 Stefan Beller <sbeller@google.com>:\n> On Fri, Jan 6, 2017 at 9:25 AM, Jake Lambert <jake@onahill.co> wrote:\n>> Hello,\n>>\n>> When executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place.\n>\n> That seems strange. Is it possible that your config is not writable?\n> (.git/config, ~/gitconfig, you'd need to find out where the <branch>\n> is configured already via git config --global/--system/--local --list)\n>\n\nHave you actually tried to reproduce this issue? I'm on current next\nand can reproduce the problem.\n\nIt seems Git is not happy with unsetting non-existent configs. And at\nleast the following piece of code\nseems to be there since 10bea152a (Add functions git_config_set() and\ngit_config_set_multivar(), 2005-11-17).\n\nconfig.c:2212\n/* if nothing to unset, or too many matches, error out */\nif ((store.seen == 0 && value == NULL) ||\n\nI wonder why it's an error to remove something that doesn't exist\nexcept the case we 'know' it\nexists because of further actions. I don't think this is a thing, though.\nJust for the record: `git config --unset branch.$branch.description`\ndoes return with code \"5\" here as well.\n\nI think removing things that don't exist should behave the same like\nremoving things that do exist, with\na success.\n\nRalf\n"},{"id":"308887","messageId":"CAGZ79kZOfHWP_pQGN1QcmR71Ft6ib0aPwNKX80YMT7KcK0_Stg@mail.gmail.com","threadId":"44826","inReplyTo":"CAN0XMO+zzYOXF2gwr=0Tu-7T5BH7f_L+FhfD8RUenDeq3xFHjA@mail.gmail.com","subject":"Re: git branch --editdescription fatal error","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-01-06T19:43:52Z","receivedAt":"2017-01-06T19:43:58Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Jan 6, 2017 at 11:31 AM, Ralf Thielow <ralf.thielow@gmail.com> wrote:\n> 2017-01-06 18:55 GMT+01:00 Stefan Beller <sbeller@google.com>:\n>> On Fri, Jan 6, 2017 at 9:25 AM, Jake Lambert <jake@onahill.co> wrote:\n>>> Hello,\n>>>\n>>> When executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place.\n>>\n>> That seems strange. Is it possible that your config is not writable?\n>> (.git/config, ~/gitconfig, you'd need to find out where the <branch>\n>> is configured already via git config --global/--system/--local --list)\n>>\n>\n> Have you actually tried to reproduce this issue? I'm on current next\n> and can reproduce the problem.\n\neh, I was on $random_version that I currently have installed\n(with messed up submodule code, but otherwise close to master).\n\nthis gives hope that a bisect between master..next will give us a culprit?\n\n>\n> I think removing things that don't exist should behave the same like\n> removing things that do exist, with\n> a success.\n\nI am not sure. Consider the tool \"rm\"\n\n    $ rm no_exist\n    rm: cannot remove ‘no_exist’: No such file or directory\n    $ echo $?\n    1\n\nYou have to use the --force.\n\nFor this specific use case I agree we should then set the force flag\nto let the the removal of the config option succeed no matter if it\nexisted before.\n\nStefan\n"},{"id":"308889","messageId":"CAN0XMOKzd-nuFaJdOYndexCNWFVWDJKKinc7-Ox19K4sgXF7YQ@mail.gmail.com","threadId":"44826","inReplyTo":"CAGZ79kZOfHWP_pQGN1QcmR71Ft6ib0aPwNKX80YMT7KcK0_Stg@mail.gmail.com","subject":"Re: git branch --editdescription fatal error","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2017-01-06T20:05:24Z","receivedAt":"2017-01-06T20:05:30Z","isPatch":false,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"2017-01-06 20:43 GMT+01:00 Stefan Beller <sbeller@google.com>:\n> On Fri, Jan 6, 2017 at 11:31 AM, Ralf Thielow <ralf.thielow@gmail.com> wrote:\n>> 2017-01-06 18:55 GMT+01:00 Stefan Beller <sbeller@google.com>:\n>>> On Fri, Jan 6, 2017 at 9:25 AM, Jake Lambert <jake@onahill.co> wrote:\n>>>> Hello,\n>>>>\n>>>> When executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place.\n>>>\n>>> That seems strange. Is it possible that your config is not writable?\n>>> (.git/config, ~/gitconfig, you'd need to find out where the <branch>\n>>> is configured already via git config --global/--system/--local --list)\n>>>\n>>\n>> Have you actually tried to reproduce this issue? I'm on current next\n>> and can reproduce the problem.\n>\n> eh, I was on $random_version that I currently have installed\n> (with messed up submodule code, but otherwise close to master).\n>\n> this gives hope that a bisect between master..next will give us a culprit?\n>\n\nHm.\nI can confirm it appears on current master (e05806da9).\n\n>>\n>> I think removing things that don't exist should behave the same like\n>> removing things that do exist, with\n>> a success.\n>\n> I am not sure. Consider the tool \"rm\"\n>\n>     $ rm no_exist\n>     rm: cannot remove ‘no_exist’: No such file or directory\n>     $ echo $?\n>     1\n>\n> You have to use the --force.\n>\n> For this specific use case I agree we should then set the force flag\n> to let the the removal of the config option succeed no matter if it\n> existed before.\n>\n> Stefan\n\nCan you think of a case where this flag should be set to false?\n\nRalf\n"},{"id":"308890","messageId":"20170106201001.pgxo4rl3d36veezs@sigill.intra.peff.net","threadId":"44826","inReplyTo":"CAGZ79kZOfHWP_pQGN1QcmR71Ft6ib0aPwNKX80YMT7KcK0_Stg@mail.gmail.com","subject":"Re: git branch --editdescription fatal error","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-01-06T20:10:01Z","receivedAt":"2017-01-06T20:10:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 06, 2017 at 11:43:52AM -0800, Stefan Beller wrote:\n\n> >>> When executing \"git branch <branch> --edit-description\" on a branch with no description set, I get \"fatal: could not unset 'branch.<branch>.description\". It would seem that the unsetting piece should occur only after checking if it was set in the first place.\n> >>\n> >> That seems strange. Is it possible that your config is not writable?\n> >> (.git/config, ~/gitconfig, you'd need to find out where the <branch>\n> >> is configured already via git config --global/--system/--local --list)\n> >>\n> >\n> > Have you actually tried to reproduce this issue? I'm on current next\n> > and can reproduce the problem.\n> \n> eh, I was on $random_version that I currently have installed\n> (with messed up submodule code, but otherwise close to master).\n\nHmm. I can reproduce, but only in one situation: when the new\ndescription is empty. In which case we try to delete the variable. In\nother words:\n\n  [this breaks; the file remains empty and we try to delete the\n   nonexistent config]\n  $ EDITOR=true git branch --edit-description master\n  fatal: could not unset 'branch.master.description'\n\n  [this works; we actually set the variable]\n  $ EDITOR='echo foo >' git branch --edit-description master\n  $ git config branch.master.description\n  foo\n\n  [and now the unsetting works; note we have to truncate here, since\n   the file will be prepopulated with \"foo\" from the existing desc]\n  $ EDITOR='>' git branch --edit-description master\n  $ git config branch.master.description\n  [no output]\n\nThe history of this behavior is a bit funny.\n\nIn old versions of git, we would return a failing exit code of \"1\" from\ngit-branch, with no message.\n\nThen in bd25f89014 (branch: die on config error when editing branch\ndescription, 2016-02-22), we actually started returning \"0\"! This was\nbecause the config code did not propagate errors from its helper\nfunctions in all cases.\n\nThat was fixed by 9c14bb08a4 (git_config_set_multivar_in_file: all\nnon-zero returns are errors, 2016-04-09), giving the behavior we see\ntoday.\n\nSo between v2.7.3 and v2.8.3, we did return 0, but I think that was a\nbug (we also returned 0 for a lot of other bogus cases, too).\n\nI could see either behavior as reasonable, but I think the right\nsolution would be for the branch code from bd25f89014 to use the\n\"gently\" function set the variable, and then decide which cases should\nbe silently ignored, and which propagated as errors.\n\n-Peff\n"}]}