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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Christian Halstrick
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Junio C Hamano
Christian Halstrick <[hidden email]> writes:

> 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?

Yes.

HEAD is a ref, but other things like MERGE_HEAD, ORIG_HEAD,
FETCH_HEAD are not considered as refs and they are intended to be
temporary.  This does mean that they will become invalid if you
prune objects that are only reachable from them, but your "reflog
expire && gc" falls into "if it hurts, don't do it".
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html