{"thread":{"id":"42272","subject":"is ORIG_HEAD allowed to point to a non-existing object?","startedAt":"2016-05-10T12:15:31Z","lastAt":"2016-05-10T18:14:06Z","messageCount":2,"participants":["Christian Halstrick","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"286048","messageId":"CAENte7jNxM7J9bWUnrOkLQJZ=8JEtYzw9-uxVkq-CpvGyk9UUw@mail.gmail.com","threadId":"42272","inReplyTo":null,"subject":"is ORIG_HEAD allowed to point to a non-existing object?","fromName":"Christian Halstrick","fromEmail":"christian.halstrick@gmail.com","sentAt":"2016-05-10T12:15:31Z","receivedAt":"2016-05-10T12:15:31Z","isPatch":false,"sender":{"key":"christian.halstrick@gmail.com","avatar":"https://gravatar.com/avatar/3598bf518644c7dc32d4dcd8e0554b6a313e12103011862402c83ae2854203ce?d=mp&s=160"},"body":"If I do a \"git-rebase -i ...\" followed by \"git reflog expire ...\" and\n\"git gc ...\" then I can end up with a repo which has a ref ORIG_HEAD\nwhich points to a non-existing object.\n\n- Is this intended?\n- What's the reason to keep a ref which points to a non-existing object?\n- Are there any other refs which are allowed to point to non-existing objects?\n\nHere is how I reproduced the problem:\n\n> git init\nInitialized empty Git repository in /tmp/yy/.git/\n> touch a\n> git add a\n> git commit -m addA\n[master (root-commit) ff82f68] addA\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 a\n> echo 2 >a\n> git commit -a -m modA\n[master f9ae5a7] modA\n 1 file changed, 1 insertion(+)\n> echo 3 >a\n> git commit -a -m 'fixup! modA'\n[master 271012b] fixup! modA\n 1 file changed, 1 insertion(+), 1 deletion(-)\n> git rebase -i --autosquash HEAD~~\n[detached HEAD 3eb17d4] modA\n 1 file changed, 1 insertion(+)\nSuccessfully rebased and updated refs/heads/master.\n> git rev-parse --short ORIG_HEAD\n271012b\n> git reflog expire --expire=now --all\n> git rev-parse 271012b\n271012be467fcbd62a875b7187c0e9871f62ac0d\n> git gc --prune=now\nCounting objects: 6, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (2/2), done.\nWriting objects: 100% (6/6), done.\nTotal 6 (delta 1), reused 0 (delta 0)\n> git rev-parse 271012b\n271012b\nfatal: ambiguous argument '271012b': unknown revision or path not in\nthe working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n> git rev-parse --short ORIG_HEAD\n271012b\n\nCiao\n  Chris\n"},{"id":"286091","messageId":"xmqqinylpyq9.fsf@gitster.mtv.corp.google.com","threadId":"42272","inReplyTo":"CAENte7jNxM7J9bWUnrOkLQJZ=8JEtYzw9-uxVkq-CpvGyk9UUw@mail.gmail.com","subject":"Re: is ORIG_HEAD allowed to point to a non-existing object?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-10T18:14:06Z","receivedAt":"2016-05-10T18:14:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Halstrick <christian.halstrick@gmail.com> writes:\n\n> If I do a \"git-rebase -i ...\" followed by \"git reflog expire ...\" and\n> \"git gc ...\" then I can end up with a repo which has a ref ORIG_HEAD\n> which points to a non-existing object.\n>\n> - Is this intended?\n\nYes.\n\nHEAD is a ref, but other things like MERGE_HEAD, ORIG_HEAD,\nFETCH_HEAD are not considered as refs and they are intended to be\ntemporary.  This does mean that they will become invalid if you\nprune objects that are only reachable from them, but your \"reflog\nexpire && gc\" falls into \"if it hurts, don't do it\".\n"}]}