{"thread":{"id":"34489","subject":"[RFC] Delete current branch","startedAt":"2013-07-19T10:35:04Z","lastAt":"2013-07-19T22:52:19Z","messageCount":10,"participants":["Ramkumar Ramachandra","Andreas Schwab","Junio C Hamano","Taylor Hedberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"223744","messageId":"CALkWK0=8q4J2yi2to_+41kJSA5E59CBwkG69Hj7MmTPgUnSh5Q@mail.gmail.com","threadId":"34489","inReplyTo":null,"subject":"[RFC] Delete current branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T10:35:04Z","receivedAt":"2013-07-19T10:35:04Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nMany of my ideas turn out to be really stupid, and I need to throw\naway my feature branch.  So, I find myself doing this often:\n\n  # on branch menuconfig-jk\n  $ git checkout master\n  $ git branch -D<BACKSAPCE>\n  # er, what was the branch name again?\n  $ git checkout -\n  # Ah\n  $ git checkout master\n  $ git branch -D menuconfig-jk\n\nSo, I scripted it for myself.  Perhaps we should get the functionality\nin core as `git branch -Dc` (c for \"current\"; or something)?\n\nAlso, perhaps a `git describe -` corresponding to `git checkout -`?\nThen I can use it with --contains --all to get the name of the\nprevious branch.\n\nThanks.\n"},{"id":"223762","messageId":"87y592y67f.fsf@igel.home","threadId":"34489","inReplyTo":"CALkWK0=8q4J2yi2to_+41kJSA5E59CBwkG69Hj7MmTPgUnSh5Q@mail.gmail.com","subject":"Re: [RFC] Delete current branch","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2013-07-19T14:28:36Z","receivedAt":"2013-07-19T14:28:36Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n>   # er, what was the branch name again?\n>   $ git checkout -\n\nYou could take a look in the reflog.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"223763","messageId":"CALkWK0kGF+d8Jk-TVfb6iwk6LuOcD-Uuuj6DHf-4YeVAFLSvuw@mail.gmail.com","threadId":"34489","inReplyTo":"87y592y67f.fsf@igel.home","subject":"Re: [RFC] Delete current branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T14:35:29Z","receivedAt":"2013-07-19T14:35:29Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Andreas Schwab wrote:\n> Ramkumar Ramachandra <artagnon@gmail.com> writes:\n>\n>>   # er, what was the branch name again?\n>>   $ git checkout -\n>\n> You could take a look in the reflog.\n\nYeah, or use the @{-N} revision to do that for me.  My scripted\nversion is essentially:\n\n  test \"true\" = \"$(git rev-parse --is-inside-work-tree 2>/dev/null)\" || exit 1\n  git checkout master\n  git branch -D @{-1}\n\nThe main problem is the hard-coding of \"master\": I suppose I could\nreplace that with @{-1} too.\n\nNot a big deal: I was just wondering if others use it often enough for\nit to become `branch -Dc` in core; @{-N} is quite obscure.\n"},{"id":"223770","messageId":"7vr4euy4c6.fsf@alter.siamese.dyndns.org","threadId":"34489","inReplyTo":"CALkWK0=8q4J2yi2to_+41kJSA5E59CBwkG69Hj7MmTPgUnSh5Q@mail.gmail.com","subject":"Re: [RFC] Delete current branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-19T15:08:57Z","receivedAt":"2013-07-19T15:08:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Many of my ideas turn out to be really stupid, and I need to throw\n> away my feature branch.  So, I find myself doing this often:\n>\n>   # on branch menuconfig-jk\n>   $ git checkout master\n>   $ git branch -D<BACKSAPCE>\n>   # er, what was the branch name again?\n>   $ git checkout -\n>   # Ah\n>   $ git checkout master\n>   $ git branch -D menuconfig-jk\n>\n> So, I scripted it for myself.  Perhaps we should get the functionality\n> in core as `git branch -Dc` (c for \"current\"; or something)?\n\nWhat branch will I be on after doing that?  Detached at that branch?\n\n> Also, perhaps a `git describe -` corresponding to `git checkout -`\n\nDid you know that the general way to spell the branch previously you\nwere on is \"@{-1}\" and \"checkout -\" is an ugly special case that is\npossible only because \"checkout\" does not happen to take a \"-\" as a\nvalid argument that means something else (like the more usual \"read\nfrom standard input\")?\n\nPerhaps \n\n\t$ git branch -D @{-1}\n\nwould have worked without <BACKSPACE> and everything that follows.\n"},{"id":"223772","messageId":"CALkWK0m-q=Aoof62zhXnUYsJ7PQZwTLbQ50BUEmufVO4gtWNUA@mail.gmail.com","threadId":"34489","inReplyTo":"7vr4euy4c6.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC] Delete current branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T15:42:02Z","receivedAt":"2013-07-19T15:42:02Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n> Did you know that the general way to spell the branch previously you\n> were on is \"@{-1}\" and \"checkout -\" is an ugly special case that is\n> possible only because \"checkout\" does not happen to take a \"-\" as a\n> valid argument that means something else (like the more usual \"read\n> from standard input\")?\n\nI disagree that it is ugly: it's a very commonly used shortcut that I\nlike.  I love it so much that I have the following in my ~/.zshrc:\n\nfunction - () {\n\tif test \"true\" = \"$(g rp --is-inside-work-tree 2>/dev/null)\"; then\n\t\tg co -\n\telse\n\t\tcd - >/dev/null\n\tfi\n}\n\nSo, I just\n\n  $ -\n\nto switch back and forth :)\n"},{"id":"223783","messageId":"7vppuewl6h.fsf@alter.siamese.dyndns.org","threadId":"34489","inReplyTo":"CALkWK0m-q=Aoof62zhXnUYsJ7PQZwTLbQ50BUEmufVO4gtWNUA@mail.gmail.com","subject":"Re: [RFC] Delete current branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-19T16:48:06Z","receivedAt":"2013-07-19T16:48:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> Did you know that the general way to spell the branch previously you\n>> were on is \"@{-1}\" and \"checkout -\" is an ugly special case that is\n>> possible only because \"checkout\" does not happen to take a \"-\" as a\n>> valid argument that means something else (like the more usual \"read\n>> from standard input\")?\n>\n> I disagree that it is ugly: it's a very commonly used shortcut that I\n> like.\n\nIt does not matter if you like it or not ;-).\n\nI do agree that \"checkout -\" is 100% more pleasing to the eye than\n\"checkout @{-1}\" from visual \"prettyness\" point of view.\n\nBut there is a very commonly accepted long tradition for \"-\" to mean\n\"read from the standard input\", so we cannot reuse it to mean \"the\nbranch I was previously on\" for every command without first making\nsure the command will never want to use \"-\" for the other common\npurpose.\n\nThat limits the context we could use \"-\" and we cannot consistently\nuse it everywhere. I find _that_ ugly from the \"design cleanliness\"\npoint of view.\n"},{"id":"223784","messageId":"CALkWK0kdCFn6YevL5nZXwYQ2u+2RdvQqEXEiVfyeXhrq_QG7AQ@mail.gmail.com","threadId":"34489","inReplyTo":"7vppuewl6h.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC] Delete current branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-19T16:50:01Z","receivedAt":"2013-07-19T16:50:01Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n> That limits the context we could use \"-\" and we cannot consistently\n> use it everywhere. I find _that_ ugly from the \"design cleanliness\"\n> point of view.\n\nRight, noted.\n"},{"id":"223786","messageId":"20130719170830.GD5999@euporie","threadId":"34489","inReplyTo":"7vppuewl6h.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC] Delete current branch","fromName":"Taylor Hedberg","fromEmail":"tmhedberg@gmail.com","sentAt":"2013-07-19T17:08:30Z","receivedAt":"2013-07-19T17:08:30Z","isPatch":false,"sender":{"key":"tmhedberg@gmail.com","avatar":"https://gravatar.com/avatar/d046da5ea94a7957169aef0fe122771a1f8d9387d39bc68fcfb1332978e11a6c?d=mp&s=160"},"body":"Junio C Hamano, Fri 2013-07-19 @ 09:48:06-0700:\n> But there is a very commonly accepted long tradition for \"-\" to mean\n> \"read from the standard input\", so we cannot reuse it to mean \"the\n> branch I was previously on\" for every command without first making\n> sure the command will never want to use \"-\" for the other common\n> purpose.\n\nIt may be worth noting that Bash (and probably other shells as well)\nallow you to type `cd -` to switch back to the previous working\ndirectory. I always (apparently mistakenly) assumed that\n`git checkout -` was deliberately designed to mirror that shortcut. I\nthink the symmetry gives it some credibility, in any case. This\nalternative meaning for - is not totally without precedent.\n\nWhat would it mean to check out the standard input, anyway? I cannot see\nhow that could ever make sense, unless `git checkout` gains some\nadditional capaabilities that are unrelated to its current purpose.\nMaybe I am just being myopic, though.\n"},{"id":"223795","messageId":"7vy592uzsz.fsf@alter.siamese.dyndns.org","threadId":"34489","inReplyTo":"20130719170830.GD5999@euporie","subject":"Re: [RFC] Delete current branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-19T19:15:08Z","receivedAt":"2013-07-19T19:15:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Hedberg <tmhedberg@gmail.com> writes:\n\n> Junio C Hamano, Fri 2013-07-19 @ 09:48:06-0700:\n>> But there is a very commonly accepted long tradition for \"-\" to mean\n>> \"read from the standard input\", so we cannot reuse it to mean \"the\n>> branch I was previously on\" for every command without first making\n>> sure the command will never want to use \"-\" for the other common\n>> purpose.\n> ...\n> What would it mean to check out the standard input, anyway?\n\nThat is my point exactly, isn't it?\n\nYou have to ask that question \"What would it mean to do X on the\nstandard input?\" for every operation X you might want to use the\nshort-cut \"-\" for.\n"},{"id":"223809","messageId":"7vmwpitb6k.fsf@alter.siamese.dyndns.org","threadId":"34489","inReplyTo":"7vppuewl6h.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC] Delete current branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-07-19T22:52:19Z","receivedAt":"2013-07-19T22:52:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ramkumar Ramachandra <artagnon@gmail.com> writes:\n>\n>> Junio C Hamano wrote:\n>>> Did you know that the general way to spell the branch previously you\n>>> were on is \"@{-1}\" and \"checkout -\" is an ugly special case that is\n>>> possible only because \"checkout\" does not happen to take a \"-\" as a\n>>> valid argument that means something else (like the more usual \"read\n>>> from standard input\")?\n>>\n>> I disagree that it is ugly: it's a very commonly used shortcut that I\n>> like.\n>\n> It does not matter if you like it or not ;-).\n>\n> I do agree that \"checkout -\" is 100% more pleasing to the eye than\n> \"checkout @{-1}\" from visual \"prettyness\" point of view.\n>\n> But there is a very commonly accepted long tradition for \"-\" to mean\n> \"read from the standard input\", so we cannot reuse it to mean \"the\n> branch I was previously on\" for every command without first making\n> sure the command will never want to use \"-\" for the other common\n> purpose.\n>\n> That limits the context we could use \"-\" and we cannot consistently\n> use it everywhere. I find _that_ ugly from the \"design cleanliness\"\n> point of view.\n\nHaving said all that.\n\nd18ba221 (sha1_name: support @{-N} syntax in get_sha1(), 2009-01-17)\nwas primarily for the follow-up patch 696acf45 (checkout: implement\n\"-\" abbreviation, add docs and tests, 2009-01-17).  Two years after\nthem, we finally did 4e8115ff (merge: allow \"-\" as a short-hand for\n\"previous branch\", 2011-04-07).\n\nThere is no reason we cannot continue.\n\nAs long as the addition is carefully prepared so that we know it\nwill not conflict (or be confused by users) with possible other uses\nof \"-\", I do not think we would mind \"git branch -D -\" and other\ncommands to learn \"-\" as a synonym for @{-1}.\n"}]}