Hi, this is my first mail to this list (and I'm not a native English speaker), 
so let me apologise from the start for any slips in following message.

Ok, so I think I've found a bug in git.
It concerns orphan checkouts breaking (gapping in non-traversable way) the HEAD 
reflog display.

% git --version
git version 2.0.1


# Repro commands; output omitted.

% mkdir /tmp/git-orphan-checkout-reflog-bug
% cd /tmp/git-orphan-checkout-reflog-bug
% git init
% echo a  > foo; git add foo; git commit -m 'newly created master; rev. a'
% echo b >> foo; git add foo; git commit -m 'master; rev. b'
% echo c >> foo; git add foo; git commit -m 'master; rev. c'
% git checkout --orphan some_orphan_branch
% echo 1  > bar; git add bar; git commit -m 'newly created orphan branch; rev. 
1'
% echo 2 >> bar; git add bar; git commit -m 'orphan branch; rev. 2'
% echo 3 >> bar; git add bar; git commit -m 'orphan branch; rev. 3'


# Actual (IMHO buggy) output

% git reflog HEAD
1af4e3c HEAD@{0}: commit: orphan branch; rev. 3
6d200b4 HEAD@{1}: commit: orphan branch; rev. 2
ed4ad67 HEAD@{2}: commit (initial): newly created orphan branch; rev. 1

% git reflog HEAD@{3}
warning: Log .git/logs/HEAD has gap after Mon, 14 Jul 2014 20:55:05 +0200.
0cada62 HEAD@{3}: commit: master; rev. c
42d7cc3 HEAD@{4}: commit: master; rev. b
222a0b3 HEAD@{5}: commit (initial): newly created master; rev. a


# Expected output:

% git reflog HEAD
1af4e3c HEAD@{0}: commit: orphan branch; rev. 3
6d200b4 HEAD@{1}: commit: orphan branch; rev. 2
ed4ad67 HEAD@{2}: commit (initial): newly created orphan branch; rev. 1
warning: Log .git/logs/HEAD has gap after Mon, 14 Jul 2014 20:55:05 +0200.
0cada62 HEAD@{3}: commit: master; rev. c
42d7cc3 HEAD@{4}: commit: master; rev. b
222a0b3 HEAD@{5}: commit (initial): newly created master; rev. a

Well, actually git doesn't seem to show warning messages when traversing 
reflogs with other gaps, but only when started from point where a gap is.
Whether those warnings should be displayed while traversing the reflog, not 
only when starting from gapped entries is another matter, but I think it could 
be useful.


# Raw reflog file (shortened to fit in 80 columns).
# Omissions marked with ##. Full contents in attachment.
# (does sending attachments to mailing list even work? Sorry, if it doesn't.)

% cat .git/logs/HEAD
00000## 222a0## ## commit (initial): newly created master; rev. a
222a0## 42d7c## ## commit: master; rev. b
42d7c## 0cada## ## commit: master; rev. c
00000## ed4ad## ## commit (initial): newly created orphan branch; rev. 1
ed4ad## 6d200## ## commit: orphan branch; rev. 2
6d200## 1af4e## ## commit: orphan branch; rev. 3

So the problem seems to be that git stops traversing the reflog after finding 
first initial commit (all-0s hash) and completely ignores rest of log.
The problem is that this commit is initial only to the orphaned branch, not to 
the whole repo.

0000000000000000000000000000000000000000 
222a0b38654d2c8cf3026db5913d21857a5a17e7 Aleksander Nitecki <ixe...@itogi.re> 
1405364070 +0200 commit (initial): newly created master; rev. a
222a0b38654d2c8cf3026db5913d21857a5a17e7 
42d7cc39cb4e89e02e8b0868d4bd32d18c0fcd84 Aleksander Nitecki <ixe...@itogi.re> 
1405364086 +0200 commit: master; rev. b
42d7cc39cb4e89e02e8b0868d4bd32d18c0fcd84 
0cada62df007aa9ec1ee00816adb1b1d9ce3f593 Aleksander Nitecki <ixe...@itogi.re> 
1405364105 +0200 commit: master; rev. c
0000000000000000000000000000000000000000 
ed4ad679d3c6903b3bbad477f8e61a85afa882a5 Aleksander Nitecki <ixe...@itogi.re> 
1405364324 +0200 commit (initial): newly created orphan branch; rev. 1
ed4ad679d3c6903b3bbad477f8e61a85afa882a5 
6d200b41f230762585e0c25b9b33336e0cf69ba9 Aleksander Nitecki <ixe...@itogi.re> 
1405364371 +0200 commit: orphan branch; rev. 2
6d200b41f230762585e0c25b9b33336e0cf69ba9 
1af4e3cf1576d05fa5c579c8090e2961ebafd4e9 Aleksander Nitecki <ixe...@itogi.re> 
1405364421 +0200 commit: orphan branch; rev. 3

Reply via email to