git checkout --orphan skips reflogging
- From
Dmitry Ivankov <divanorama@gmail.com>
- Date
- Sep 13, 2011, 18:28 UTC
- Message-ID
- <CA+gfSn-tVgj=FYiVGK7kmH4gpnXF3HUbs+f=DfRey6GrpadVYg@mail.gmail.com>
In short, git checkout --orphan doesn't write HEAD_sha1 -> 00000 entry to logs/HEAD, while git-comit will write 00000 -> new_orphan_HEAD_sha1 entry. And then reflog backward walk will stop on 000 -> entry and won't see earlier history.
How to reproduce: $ git init test && cd test $ git commit -m A --allow-empty $ git checkout --orphan topic $ git commit -m B --allow-empty $ git log -g --oneline HEAD some_sha1 HEAD@{0}: commit (initial): B # oops, where are my old HEADs? $ cat .git/logs/HEAD 000.. another_sha1 ... commit (initial): A 000.. some_sha1 ... commit (initial): B # phew, at least I can find them by hand
Isn't it also a bug in reflog walking that we rely on each old_sha1 being new_sha1 of a previous entry?