{"thread":{"id":"29458","subject":"BUG 1.7.9: git branch fails to create new branch when --edit-description is used","startedAt":"2012-01-27T21:52:45Z","lastAt":"2012-01-29T21:49:33Z","messageCount":9,"participants":["Mark Jason Dominus","Junio C Hamano","Michael Haggerty","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"183207","messageId":"2443.1327701165@plover.com","threadId":"29458","inReplyTo":null,"subject":"BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Mark Jason Dominus","fromEmail":"mjd@plover.com","sentAt":"2012-01-27T21:52:45Z","receivedAt":"2012-01-27T21:52:45Z","isPatch":false,"sender":{"key":"mjd@plover.com","avatar":"https://gravatar.com/avatar/a874d23a21a54fc9c5e9d91614219a150bd89c90c1cb0ef970e689f5b88c098b?d=mp&s=160"},"body":"\nThis should work, but doesn't:\n\n        % git branch\n        * master\n        % git branch  --edit-description  blarf\n        [Edit description and exit editor normally]\n        % cat .git/BRANCH_DESCRIPTION \n        I like blarf\n        # Please edit the description for the branch\n        #   blarf\n        # Lines starting with '#' will be stripped.\n        % git branch -a\n        * master\n\nWhere is branch blarf?\n\nCreating the branch and editing the description afterwards works correctly:\n\n        % git branch blarf\n        % git branch  --edit-description  blarf\n        % git branch -a\n          blarf\n        * master\n        % cat .git/config \n        [core]\n                repositoryformatversion = 0\n                filemode = true\n                bare = false\n                logallrefupdates = true\n        [branch \"master\"]\n                description = I like pie\\n\n        [branch \"blarf\"]\n                description = I like blarf\\n\n\n\nMark Jason Dominus \t  \t\t\t                 mjd@plover.com\n"},{"id":"183210","messageId":"7vr4ykybnl.fsf@alter.siamese.dyndns.org","threadId":"29458","inReplyTo":"2443.1327701165@plover.com","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-27T23:21:34Z","receivedAt":"2012-01-27T23:21:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mark Jason Dominus <mjd@plover.com> writes:\n\n> This should work, but doesn't:\n>\n>         % git branch\n>         * master\n>         % git branch  --edit-description  blarf\n>         [Edit description and exit editor normally]\n>         % cat .git/BRANCH_DESCRIPTION \n>         I like blarf\n>         # Please edit the description for the branch\n>         #   blarf\n>         # Lines starting with '#' will be stripped.\n>         % git branch -a\n>         * master\n>\n> Where is branch blarf?\n\nYou haven't created one in that sequence yet.\n\nThis is more of a documentation bug. \n\nAs the SYNOPSIS section makes it clear, the '--edit-description' is a\nseparate mode from showing (the first group), creating or repointing (the\nsecond), or renaming (the third).\n\nAfter that you should be able to say \"git branch blarf\" and view its\ndescription.\n"},{"id":"183217","messageId":"4F2399B6.8020507@alum.mit.edu","threadId":"29458","inReplyTo":"7vr4ykybnl.fsf@alter.siamese.dyndns.org","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-01-28T06:46:14Z","receivedAt":"2012-01-28T06:46:14Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 01/28/2012 12:21 AM, Junio C Hamano wrote:\n> Mark Jason Dominus <mjd@plover.com> writes:\n> \n>> This should work, but doesn't:\n>>\n>>         % git branch\n>>         * master\n>>         % git branch  --edit-description  blarf\n>>         [Edit description and exit editor normally]\n>>         % cat .git/BRANCH_DESCRIPTION \n>>         I like blarf\n>>         # Please edit the description for the branch\n>>         #   blarf\n>>         # Lines starting with '#' will be stripped.\n>>         % git branch -a\n>>         * master\n>>\n>> Where is branch blarf?\n> \n> You haven't created one in that sequence yet.\n> \n> This is more of a documentation bug. \n> \n> As the SYNOPSIS section makes it clear, the '--edit-description' is a\n> separate mode from showing (the first group), creating or repointing (the\n> second), or renaming (the third).\n> \n> After that you should be able to say \"git branch blarf\" and view its\n> description.\n\nGiven this design, shouldn't \"git branch --edit-description\" fail if the\nbranch doesn't already exist?\n\nShouldn't it also resolve ambiguous reference names?\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"183218","messageId":"7vbopoxp5q.fsf@alter.siamese.dyndns.org","threadId":"29458","inReplyTo":"4F2399B6.8020507@alum.mit.edu","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-28T07:27:29Z","receivedAt":"2012-01-28T07:27:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n>>> Where is branch blarf?\n>> \n>> You haven't created one in that sequence yet.\n>> \n>> This is more of a documentation bug. \n>> \n>> As the SYNOPSIS section makes it clear, the '--edit-description' is a\n>> separate mode from showing (the first group), creating or repointing (the\n>> second), or renaming (the third).\n>> \n>> After that you should be able to say \"git branch blarf\" and view its\n>> description.\n>\n> Given this design, shouldn't \"git branch --edit-description\" fail if the\n> branch doesn't already exist?\n\n\nThe only use scenario in the original design was to have a way to store\nthe description given a branch name, and giving a description to a branch\nthat does not yet exist is outside the scope of the design. So it all\nboils down to what is the most convenient and the simplest to explain.\n\nWe could error it out (i.e. you cannot name a thing that does not yet\nexist), or we could consider it is a convenience feature that you can\nprepare a description even before you create one, or we could even tweak\nit more like \"-t $name\" that tries to work both on existing one (without\nchanging any base) or non-existing one, creating it while at it. The last\napproach historically is the most error prone (we had numerous bugs in the\ncreate_branch() helper after it started allowing an existing branch when\nupdating the \"track\" information) and I would rather not go that route if\nwe can avoid it.\n\nHonestly speaking, I haven't formed an opinion.\n\n> Shouldn't it also resolve ambiguous reference names?\n\nAs this mode, just like other modes of \"git branch\" _always_ takes a\nbranch name, I do not think there is any \"ambiguous reference name\".\n\nYou give $name to it, and it should always mean refs/heads/$name, and\nthere shouldn't be any DWIMming to something like refs/heads/mh/$name\n\nOr do you have other kinds of ambiguity in mind?\n"},{"id":"183242","messageId":"20120129031843.GA1347@sigill.intra.peff.net","threadId":"29458","inReplyTo":"7vbopoxp5q.fsf@alter.siamese.dyndns.org","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-01-29T03:18:44Z","receivedAt":"2012-01-29T03:18:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 27, 2012 at 11:27:29PM -0800, Junio C Hamano wrote:\n\n> > Given this design, shouldn't \"git branch --edit-description\" fail if the\n> > branch doesn't already exist?\n> \n> The only use scenario in the original design was to have a way to store\n> the description given a branch name, and giving a description to a branch\n> that does not yet exist is outside the scope of the design. So it all\n> boils down to what is the most convenient and the simplest to explain.\n\nHow do we define \"branch exists\"? That the ref exists? What about a HEAD\nthat points to a branch-to-be-born?\n\nSpecifically, I am wondering whether this:\n\n  $ git init\n  $ git branch --edit-description\n\nshould work. Right now it edits the description for \"master\", even\nthough you haven't yet committed to it.\n\n-Peff\n"},{"id":"183245","messageId":"4F24E78A.7060502@alum.mit.edu","threadId":"29458","inReplyTo":"7vbopoxp5q.fsf@alter.siamese.dyndns.org","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-01-29T06:30:34Z","receivedAt":"2012-01-29T06:30:34Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 01/28/2012 08:27 AM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>>>> Where is branch blarf?\n>>>\n>>> You haven't created one in that sequence yet.\n>>>\n>>> This is more of a documentation bug. \n>>>\n>>> As the SYNOPSIS section makes it clear, the '--edit-description' is a\n>>> separate mode from showing (the first group), creating or repointing (the\n>>> second), or renaming (the third).\n>>>\n>>> After that you should be able to say \"git branch blarf\" and view its\n>>> description.\n>>\n>> Given this design, shouldn't \"git branch --edit-description\" fail if the\n>> branch doesn't already exist?\n> \n> The only use scenario in the original design was to have a way to store\n> the description given a branch name, and giving a description to a branch\n> that does not yet exist is outside the scope of the design. So it all\n> boils down to what is the most convenient and the simplest to explain.\n> \n> We could error it out (i.e. you cannot name a thing that does not yet\n> exist), or we could consider it is a convenience feature that you can\n> prepare a description even before you create one, or we could even tweak\n> it more like \"-t $name\" that tries to work both on existing one (without\n> changing any base) or non-existing one, creating it while at it. The last\n> approach historically is the most error prone (we had numerous bugs in the\n> create_branch() helper after it started allowing an existing branch when\n> updating the \"track\" information) and I would rather not go that route if\n> we can avoid it.\n> \n> Honestly speaking, I haven't formed an opinion.\n\nI vote for an error.  Otherwise a typo in the branch name would lead to\nthe description's apparent disappearance into Nirvana.  An error would,\nfor example, have made it clear to the OP what was happening.\n\nA more useful option might be\n\n    git branch --with-description <branchname> [<start-point>]\n\ni.e., that a branch's description can be set at the same time as the\nbranch is created.\n\n>> Shouldn't it also resolve ambiguous reference names?\n> \n> As this mode, just like other modes of \"git branch\" _always_ takes a\n> branch name, I do not think there is any \"ambiguous reference name\".\n> \n> You give $name to it, and it should always mean refs/heads/$name, and\n> there shouldn't be any DWIMming to something like refs/heads/mh/$name\n> \n> Or do you have other kinds of ambiguity in mind?\n\nOK, I wasn't aware that only local branches can have descriptions\nattached to them.  Given that fact, you are correct that DWIMming\ndoesn't make sense.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"183246","messageId":"7v39azxb5l.fsf@alter.siamese.dyndns.org","threadId":"29458","inReplyTo":"4F24E78A.7060502@alum.mit.edu","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-29T06:42:14Z","receivedAt":"2012-01-29T06:42:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> On 01/28/2012 08:27 AM, Junio C Hamano wrote:\n>> \n>> We could error it out (i.e. you cannot name a thing that does not yet\n>> exist), or we could consider it is a convenience feature that you can\n>> prepare a description even before you create one, or we could even tweak\n>> it more like \"-t $name\" that tries to work both on existing one (without\n>> changing any base) or non-existing one, creating it while at it. The last\n>> approach historically is the most error prone (we had numerous bugs in the\n>> create_branch() helper after it started allowing an existing branch when\n>> updating the \"track\" information) and I would rather not go that route if\n>> we can avoid it.\n>> \n>> Honestly speaking, I haven't formed an opinion.\n>\n> I vote for an error.  Otherwise a typo in the branch name would lead to\n> the description's apparent disappearance into Nirvana.  An error would,\n> for example, have made it clear to the OP what was happening.\n>\n> A more useful option might be\n>\n>     git branch --with-description <branchname> [<start-point>]\n>\n> i.e., that a branch's description can be set at the same time as the\n> branch is created.\n\nSo you are saying either option 1 or 3 is preferrable, while I was saying\nI would rather avoid 3 if we could avoid it. Is that the short version?\n"},{"id":"183249","messageId":"4F251B50.5080602@alum.mit.edu","threadId":"29458","inReplyTo":"7v39azxb5l.fsf@alter.siamese.dyndns.org","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-01-29T10:11:28Z","receivedAt":"2012-01-29T10:11:28Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 01/29/2012 07:42 AM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>> On 01/28/2012 08:27 AM, Junio C Hamano wrote:\n>>>\n>>> We could error it out (i.e. you cannot name a thing that does not yet\n>>> exist), or we could consider it is a convenience feature that you can\n>>> prepare a description even before you create one, or we could even tweak\n>>> it more like \"-t $name\" that tries to work both on existing one (without\n>>> changing any base) or non-existing one, creating it while at it. The last\n>>> approach historically is the most error prone (we had numerous bugs in the\n>>> create_branch() helper after it started allowing an existing branch when\n>>> updating the \"track\" information) and I would rather not go that route if\n>>> we can avoid it.\n>>>\n>>> Honestly speaking, I haven't formed an opinion.\n>>\n>> I vote for an error.  Otherwise a typo in the branch name would lead to\n>> the description's apparent disappearance into Nirvana.  An error would,\n>> for example, have made it clear to the OP what was happening.\n>>\n>> A more useful option might be\n>>\n>>     git branch --with-description <branchname> [<start-point>]\n>>\n>> i.e., that a branch's description can be set at the same time as the\n>> branch is created.\n> \n> So you are saying either option 1 or 3 is preferrable, while I was saying\n> I would rather avoid 3 if we could avoid it. Is that the short version?\n\nNot quite.  I agree that \"--add-description\" should fail if the branch\nalready exists.  But I was suggesting that there be a new *different*\noption that can be used when creating a branch.  \"--with-description\" is\nprobably not a great name, but I think it is a good idea that it be\nspelled differently than \"--add-description\".  Perhaps even \"--message\",\neven though the abbreviation \"-m\" is precluded by the existing \"-m\" option.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"183261","messageId":"7vzkd6dvrm.fsf@alter.siamese.dyndns.org","threadId":"29458","inReplyTo":"4F24E78A.7060502@alum.mit.edu","subject":"Re: BUG 1.7.9: git branch fails to create new branch when --edit-description is used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-01-29T21:49:33Z","receivedAt":"2012-01-29T21:49:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> On 01/28/2012 08:27 AM, Junio C Hamano wrote:\n>> Michael Haggerty <mhagger@alum.mit.edu> writes:\n>> \n> I vote for an error.  Otherwise a typo in the branch name would lead to\n> the description's apparent disappearance into Nirvana.  An error would,\n> for example, have made it clear to the OP what was happening.\n\nI agree with this statement.\n\nUnless or until we update --edit-description to create a new branch when\ngiven a name of a branch that does not exist, the existing behaviour is\nsimply an accident waiting to happen.\n"}]}