git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Chris Jerdonek <chris.jerdonek@gmail.com>
To: git@vger.kernel.org
Subject: ambiguous git-reflog output for symbolic refs
Date: Fri, 28 Feb 2020 20:49:43 -0800	[thread overview]
Message-ID: <CAOTb1wfXp+gXSwbG-CVgVE8E_5yzxQKwNKh_=3ECqTMvZFw7dQ@mail.gmail.com> (raw)

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

                 reply	other threads:[~2020-02-29  4:49 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CAOTb1wfXp+gXSwbG-CVgVE8E_5yzxQKwNKh_=3ECqTMvZFw7dQ@mail.gmail.com' \
    --to=chris.jerdonek@gmail.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).