All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksander Nitecki <ixendr@itogi.re>
To: git@vger.kernel.org
Subject: [BUG] checkout --orphan breaks HEAD reflog
Date: Mon, 14 Jul 2014 21:44:25 +0200	[thread overview]
Message-ID: <53C43319.7000208@itogi.re> (raw)

[-- Attachment #1: Type: text/plain, Size: 2898 bytes --]

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.


[-- Attachment #2: gitdir_logs_HEAD.txt --]
[-- Type: text/plain, Size: 1023 bytes --]

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

                 reply	other threads:[~2014-07-14 20:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53C43319.7000208@itogi.re \
    --to=ixendr@itogi.re \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.