git/list[1] front-page[2] threads[3] people[4] search[5] about
 

is ORIG_HEAD allowed to point to a non-existing object?

From
Christian Halstrick <christian.halstrick@gmail.com>
Date
May 10, 2016, 12:15 UTC
Message-ID
<CAENte7jNxM7J9bWUnrOkLQJZ=8JEtYzw9-uxVkq-CpvGyk9UUw@mail.gmail.com>

If I do a "git-rebase -i ..." followed by "git reflog expire ..." and "git gc ..." then I can end up with a repo which has a ref ORIG_HEAD which points to a non-existing object.

- Is this intended?
- What's the reason to keep a ref which points to a non-existing object?
- Are there any other refs which are allowed to point to non-existing objects?
Here is how I reproduced the problem:
> git init
Initialized empty Git repository in /tmp/yy/.git/
> touch a
> git add a
> git commit -m addA
[master (root-commit) ff82f68] addA
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
> echo 2 >a
> git commit -a -m modA
[master f9ae5a7] modA
 1 file changed, 1 insertion(+)
> echo 3 >a
> git commit -a -m 'fixup! modA'
[master 271012b] fixup! modA
 1 file changed, 1 insertion(+), 1 deletion(-)
> git rebase -i --autosquash HEAD~~
[detached HEAD 3eb17d4] modA
 1 file changed, 1 insertion(+)
Successfully rebased and updated refs/heads/master.
> git rev-parse --short ORIG_HEAD
271012b
> git reflog expire --expire=now --all
> git rev-parse 271012b
271012be467fcbd62a875b7187c0e9871f62ac0d
> git gc --prune=now

Counting objects: 6, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (6/6), done. Total 6 (delta 1), reused 0 (delta 0)

> git rev-parse 271012b

271012b fatal: ambiguous argument '271012b': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]'

> git rev-parse --short ORIG_HEAD
271012b
Ciao
  Chris
Next: Junio C Hamano
Message 1 of 2 in “is ORIG_HEAD allowed to point to a non-existing object?”
  1. Christian HalstrickMay 10, 2016
  2. Junio C HamanoMay 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.