{"thread":{"id":"36178","subject":"Using \"-\" for \"previous branch\" failing with rebase","startedAt":"2014-03-15T20:29:24Z","lastAt":"2014-03-18T18:59:42Z","messageCount":4,"participants":["Tim Chase","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"236805","messageId":"20140315152924.26c3294e@bigbox.christie.dr","threadId":"36178","inReplyTo":null,"subject":"Using \"-\" for \"previous branch\" failing with rebase","fromName":"Tim Chase","fromEmail":"git@tim.thechases.com","sentAt":"2014-03-15T20:29:24Z","receivedAt":"2014-03-15T20:29:24Z","isPatch":false,"sender":{"key":"git@tim.thechases.com","avatar":null},"body":"I recently learned that there are several places where git allows use\nof \"-\" to refer to the previous branch, e.g.\n\n  git checkout -b dev\n  # hack, hack\n  git checkout master\n  git merge -\n  git checkout -\n\nHowever, it doesn't seem to understand \"-\" in the context of a rebase:\n\n  git checkout branch_a\n  # hack\n  git commit -a\n  git checkout branch_b\n  # hack\n  git commit -a\n  git rebase -         # I'd expect to rebase onto branch_a\n\nbut I get\n\n  fatal: Needed a single revision\n  invalid upstream -\n\nIssuing\n\n  git rebase branch_a\n\ndoes exactly what I'd expect (as \"git checkout -\" puts me on\n\"branch_a\").\n\nIs this just an interface inconsistency or is there a some technical\nreason this doesn't work (or, has it been addressed/fixed, and just\nnot pulled into Debian Stable's 1.7.10.4 version of git)?\n\nThanks,\n\n-tkc\n"},{"id":"236854","messageId":"7vppll2uvp.fsf@alter.siamese.dyndns.org","threadId":"36178","inReplyTo":"20140315152924.26c3294e@bigbox.christie.dr","subject":"Re: Using \"-\" for \"previous branch\" failing with rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-17T06:37:30Z","receivedAt":"2014-03-17T06:37:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tim Chase <git@tim.thechases.com> writes:\n\n> Is this just an interface inconsistency or is there a some technical\n> reason this doesn't work (or, has it been addressed/fixed, and just\n> not pulled into Debian Stable's 1.7.10.4 version of git)?\n\nIt is merely that nobody thought \"rebase\" would benefit from such a\nshort-hand, I think.\n\n    Teach more commands that operate on branch names about \"-\"\n    shorthand for \"the branch we were previously on\", like we did\n    for \"git merge -\" sometime after we introduced \"git checkout -\"\n\nhas been sitting in my \"leftover bits\" list at\n\n    http://git-blame.blogspot.com/p/leftover-bits.html\n\nfor quite some time.  Hint, hint...\n"},{"id":"236948","messageId":"20140317204744.6ac795a0@bigbox.christie.dr","threadId":"36178","inReplyTo":"7vppll2uvp.fsf@alter.siamese.dyndns.org","subject":"Re: Using \"-\" for \"previous branch\" failing with rebase","fromName":"Tim Chase","fromEmail":"git@tim.thechases.com","sentAt":"2014-03-18T01:47:44Z","receivedAt":"2014-03-18T01:47:44Z","isPatch":false,"sender":{"key":"git@tim.thechases.com","avatar":null},"body":"On 2014-03-16 23:37, Junio C Hamano wrote:\n> Tim Chase <git@tim.thechases.com> writes:\n> \n> > Is this just an interface inconsistency or is there a some\n> > technical reason this doesn't work (or, has it been\n> > addressed/fixed, and just not pulled into Debian Stable's\n> > 1.7.10.4 version of git)?\n> \n> It is merely that nobody thought \"rebase\" would benefit from such a\n> short-hand, I think.\n> \n>     Teach more commands that operate on branch names about \"-\"\n>     shorthand for \"the branch we were previously on\", like we did\n>     for \"git merge -\" sometime after we introduced \"git checkout -\"\n> \n> has been sitting in my \"leftover bits\" list at\n> \n>     http://git-blame.blogspot.com/p/leftover-bits.html\n> \n> for quite some time.  Hint, hint...\n\nNot sure if the \"Hint, hint\" was intended for me, as I'm not exactly\na git hacker.  I did find another place where I reached for it\ninstinctively (now that I use it regularly with checkout/merge):\ngit-diff.\n\n  git checkout some_branch\n  #hack\n  git commit -m \"...\"\n  git checkout other_branch\n  # hmm...what's different between these branches?\n  git diff -\n\nwhich I would have expected to act something like\n\n  git diff some_branch..other_branch\n\nJust for the archives.\n\n-tkc\n\n\n\n\n(or possibly the reverse)\n"},{"id":"236997","messageId":"xmqqr45z8h9d.fsf@gitster.dls.corp.google.com","threadId":"36178","inReplyTo":"20140317204744.6ac795a0@bigbox.christie.dr","subject":"Re: Using \"-\" for \"previous branch\" failing with rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-18T18:59:42Z","receivedAt":"2014-03-18T18:59:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tim Chase <git@tim.thechases.com> writes:\n\n> On 2014-03-16 23:37, Junio C Hamano wrote:\n>> Tim Chase <git@tim.thechases.com> writes:\n>> \n>> > Is this just an interface inconsistency or is there a some\n>> > technical reason this doesn't work (or, has it been\n>> > addressed/fixed, and just not pulled into Debian Stable's\n>> > 1.7.10.4 version of git)?\n>> \n>> It is merely that nobody thought \"rebase\" would benefit from such a\n>> short-hand, I think.\n>> \n>>     Teach more commands that operate on branch names about \"-\"\n>>     shorthand for \"the branch we were previously on\", like we did\n>>     for \"git merge -\" sometime after we introduced \"git checkout -\"\n>> \n>> has been sitting in my \"leftover bits\" list at\n>> \n>>     http://git-blame.blogspot.com/p/leftover-bits.html\n>> \n>> for quite some time.  Hint, hint...\n>\n> Not sure if the \"Hint, hint\" was intended for me,...\n\nNo.  It is primarily a search-engine bait ;-) and is secondarily a\nhint to any aspiring Git hackers on the list.\n\nIn general, I am not very enthused to see the single letter \"-\" used\nwhere you name any commit object (like \"diff\").  It is a short-hand\nfor the @{-1} notation that names the branch name, and it is OK in\ngeneral to add support for it to the places where we expect a branch\nname and not just any commit object name (e.g. \"checkout -\"), but\nmaybe it is just me who was heavily involved in the original design.\n"}]}