git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ambiguous git-reflog output for symbolic refs
@ 2020-02-29  4:49 Chris Jerdonek
  0 siblings, 0 replies; only message in thread
From: Chris Jerdonek @ 2020-02-29  4:49 UTC (permalink / raw)
  To: git

Hi,

I encountered some output that seems unexpected and ambiguous to me
when calling git-reflog on a symbolic ref.

Specifically, if the symbolic ref has no reflog of its own, then
git-reflog shows the reflog of the symbolic ref's target, but with the
symbolic ref's name in the output lines. This means you can't tell if
the reflog entries are from the symbolic ref's reflog, or from the
symbolic ref target's reflog:

To illustrate, create a symbolic ref pointing to a branch (this is
using git version 2.25.0):

$ git update-ref -m AAA refs/heads/test-branch
931dd4e7f267865e8077ae47c75888fe5d1b2755
$ git symbolic-ref refs/my-symbolic refs/heads/test-branch

Now, the git-reflog command below shows the log entries for
refs/heads/test-branch:

$ git reflog refs/my-symbolic
931dd4e (HEAD -> master, refs/my-symbolic, test-branch)
refs/my-symbolic@{0}: AAA

But if we ensure that refs/my-symbolic has its own reflog, e.g. by doing this:

$ git update-ref -m BBB --create-reflog refs/my-symbolic
931dd4e7f267865e8077ae47c75888fe5d1b2755

Then running the same git-reflog command as above now shows the
symbolic ref's reflog instead of the target's:

$ git reflog refs/my-symbolic
931dd4e (HEAD -> master, refs/my-symbolic, test-branch)
refs/my-symbolic@{0}: BBB

(The ref is still a symbolic ref pointing to "test-branch" as you can
see below.)

$ git symbolic-ref refs/my-symbolic
refs/heads/test-branch

To recap, looking at the two git-reflog outputs above, there's no way
to tell from the output which of the two cases you're in (the symbolic
ref's reflog or the target's).

So my question is: Is this behaving like it should? I was surprised
that git-reflog dereferences the symbolic ref prior to querying the
reflog, and even more surprising, replaces "refs/heads/test-branch" in
refs/heads/test-branch's reflog with "refs/my-symbolic".

And either way, is there a way to get unambiguous output? For example,
is there a way to make sure you're reading the symbolic ref's reflog
and not the reflog of its target?

Thank you,
--Chris

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-29  4:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-29  4:49 ambiguous git-reflog output for symbolic refs Chris Jerdonek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).