{"thread":{"id":"35630","subject":"[BUG] git symbolic-ref does not recognize @ as the shortcut for HEAD","startedAt":"2014-01-09T15:05:22Z","lastAt":"2014-01-15T11:26:07Z","messageCount":6,"participants":["Mathieu Lemoine","Andreas Krey","John Keeping","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"232951","messageId":"CAOBEgJjmoXEDVa4L5LbAGMYR7_+NCf2tDSveieZxtU4bfWyzDw@mail.gmail.com","threadId":"35630","inReplyTo":null,"subject":"[BUG] git symbolic-ref does not recognize @ as the shortcut for HEAD","fromName":"Mathieu Lemoine","fromEmail":"mathieu@mlemoine.name","sentAt":"2014-01-09T15:05:22Z","receivedAt":"2014-01-09T15:05:22Z","isPatch":false,"sender":{"key":"mathieu@mlemoine.name","avatar":null},"body":"Hello,\n\nIn https://raw.github.com/git/git/master/Documentation/RelNotes/1.8.5.txt\nis mentioned:\n\n * Instead of typing four capital letters \"HEAD\", you can say \"@\" now,\ne.g. \"git log @\".\n\nHowever, `git symbolic-ref @`  gives \"fatal: No such ref: @\", while\n`git symbolic-ref @`  gives \"refs/heads/master\".\n\nI looked around in the archive and #git, but nobody seemed to be aware\nof the behaviour.\n\nI wonder if it's on purpose given the low level of symbolic-ref or if\nit's a bug.\n\nMathieu Lemoine.\n"},{"id":"232952","messageId":"20140109153618.GA18975@inner.h.apk.li","threadId":"35630","inReplyTo":"CAOBEgJjmoXEDVa4L5LbAGMYR7_+NCf2tDSveieZxtU4bfWyzDw@mail.gmail.com","subject":"[BUG] \"git rebase\": fatal: Not a valid object name: ''","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2014-01-09T15:36:18Z","receivedAt":"2014-01-09T15:36:18Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"Hi, everyone,\n\nsince ad8261d (rebase: use reflog to find common base with upstream)\na rebase without arguments says \"fatal: Not a valid object name: ''\",\ncaused by trying to determine the fork point with an empty $switch_to.\n\nI don't really see what the appropriate fix would be. :-(\n\nAndreas\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"},{"id":"232953","messageId":"20140109155620.GH7608@serenity.lan","threadId":"35630","inReplyTo":"20140109153618.GA18975@inner.h.apk.li","subject":"Re: [BUG] \"git rebase\": fatal: Not a valid object name: ''","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-01-09T15:56:21Z","receivedAt":"2014-01-09T15:56:21Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Thu, Jan 09, 2014 at 04:36:18PM +0100, Andreas Krey wrote:\n> since ad8261d (rebase: use reflog to find common base with upstream)\n> a rebase without arguments says \"fatal: Not a valid object name: ''\",\n> caused by trying to determine the fork point with an empty $switch_to.\n> \n> I don't really see what the appropriate fix would be. :-(\n\nI think the correct fix is to change the \"$switch_to\" in the call to\n\"git merge-base --fork-point\" to \"${switch_to:-HEAD}\", but I'm not at a\nmachine where I can test that or work up a patch at the moment...\n"},{"id":"232954","messageId":"20140109160603.GR7102@inner.h.apk.li","threadId":"35630","inReplyTo":"20140109155620.GH7608@serenity.lan","subject":"Re: [BUG] \"git rebase\": fatal: Not a valid object name: ''","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2014-01-09T16:06:03Z","receivedAt":"2014-01-09T16:06:03Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"On Thu, 09 Jan 2014 15:56:21 +0000, John Keeping wrote:\n...\n> I think the correct fix is to change the \"$switch_to\" in the call to\n> \"git merge-base --fork-point\" to \"${switch_to:-HEAD}\", but I'm not at a\n> machine where I can test that or work up a patch at the moment...\n\nThanks, looks plausible and works. Need to catch train myself now.\n\nAndreas\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"},{"id":"232962","messageId":"65fed28c9346aa98a0d9edcbb0c2b483abc0189f.1389296828.git.john@keeping.me.uk","threadId":"35630","inReplyTo":"20140109160603.GR7102@inner.h.apk.li","subject":"[PATCH] rebase: fix fork-point with zero arguments","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2014-01-09T19:47:34Z","receivedAt":"2014-01-09T19:47:34Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"When no arguments are specified, $switch_to is empty so we end up\npassing the empty string to \"git merge-base --fork-point\", which causes\nan error.  git-rebase carries on at this point, but in fact we have\nfailed to apply the fork-point operation.\n\nIt turns out that the test in t3400 that was meant to test this didn't\nactually need the fork-point behaviour, so enhance it to make sure that\nthe fork-point is applied correctly.  The modified test fails without\nthe change to git-rebase.sh in this patch.\n\nReported-by: Andreas Krey <a.krey@gmx.de>\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\n git-rebase.sh     |  3 ++-\n t/t3400-rebase.sh | 12 ++++++++++--\n 2 files changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 7185dc8..8a3efa2 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -534,7 +534,8 @@ esac\n \n if test \"$fork_point\" = t\n then\n-\tnew_upstream=$(git merge-base --fork-point \"$upstream_name\" \"$switch_to\")\n+\tnew_upstream=$(git merge-base --fork-point \"$upstream_name\" \\\n+\t\t\t\"${switch_to:-HEAD}\")\n \tif test -n \"$new_upstream\"\n \tthen\n \t\tupstream=$new_upstream\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex 998503d..6d94b1f 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -135,11 +135,19 @@ test_expect_success 'fail when upstream arg is missing and not configured' '\n '\n \n test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' '\n+\tgit checkout -b default-base master &&\n \tgit checkout -b default topic &&\n \tgit config branch.default.remote . &&\n-\tgit config branch.default.merge refs/heads/master &&\n+\tgit config branch.default.merge refs/heads/default-base &&\n \tgit rebase &&\n-\tgit rev-parse --verify master >expect &&\n+\tgit rev-parse --verify default-base >expect &&\n+\tgit rev-parse default~1 >actual &&\n+\ttest_cmp expect actual &&\n+\tgit checkout default-base &&\n+\tgit reset --hard HEAD^ &&\n+\tgit checkout default &&\n+\tgit rebase &&\n+\tgit rev-parse --verify default-base >expect &&\n \tgit rev-parse default~1 >actual &&\n \ttest_cmp expect actual\n '\n-- \n1.8.5.226.g0d60d77\n"},{"id":"233150","messageId":"CACsJy8Dy5xgF5m6BOo1cfdzg5dOx58sZo0aa_YKdnyAvJ6g4=Q@mail.gmail.com","threadId":"35630","inReplyTo":"CAOBEgJjmoXEDVa4L5LbAGMYR7_+NCf2tDSveieZxtU4bfWyzDw@mail.gmail.com","subject":"Re: [BUG] git symbolic-ref does not recognize @ as the shortcut for HEAD","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-01-15T11:26:07Z","receivedAt":"2014-01-15T11:26:07Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Jan 9, 2014 at 10:05 PM, Mathieu Lemoine <mathieu@mlemoine.name> wrote:\n> Hello,\n>\n> In https://raw.github.com/git/git/master/Documentation/RelNotes/1.8.5.txt\n> is mentioned:\n>\n>  * Instead of typing four capital letters \"HEAD\", you can say \"@\" now,\n> e.g. \"git log @\".\n>\n> However, `git symbolic-ref @`  gives \"fatal: No such ref: @\", while\n> `git symbolic-ref @`  gives \"refs/heads/master\".\n\nyou meant \"while `git symbolic-ref _HEAD_` gives refs/heads/master\"?\n\n> I looked around in the archive and #git, but nobody seemed to be aware\n> of the behaviour.\n>\n> I wonder if it's on purpose given the low level of symbolic-ref or if\n> it's a bug.\n\nI think this is because symbolic-ref (and show-ref) takes plain refs,\neither in full or short form, but nothing else fancier. I'm not sure\nif we should add support for @ (and maybe @{u} as it's in the same\nboat) to these commands. If it's confusing and hard to explain in\ndocuments then maybe we should.\n-- \nDuy\n"}]}