From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Annoyance wrt ref@{1} and reflog expiry
Date: Fri, 19 Jun 2020 11:03:54 -0700 [thread overview]
Message-ID: <xmqqzh8zgcfp.fsf@gitster.c.googlers.com> (raw)
I have been disturbed by this for a long time, but not strongly
enough to do anything to it.
This sequence works
$ git checkout -b newbranch
$ git commit --allow-empty -m one
$ git show -s newbranch@{1}
and shows the state that was immediately after the newbranch was
created.
But then if you do
$ git reflog expire --expire=now refs/heads/newbranch
$ git commit --allow=empty -m two
$ git show -s newbranch@{1}
you'd be scolded with
fatal: log for 'newbranch' only has 1 entries
While it is true that it has only 1 entry, we have enough
information in that single entry that records the transition between
the state in which the tip of the branch was pointing at commit
'one' to the new commit 'two' built on it, so we should be able to
answer "what object newbranch was pointing at?". But we refuse to
do so.
And it is unintuitive. It is understandable to the users that all
the ref history before "reflog expire" is lost---it was what the end
user asked Git to do. But after creating one commit on the state
(or do anything else that moves the ref) and finding it regrettable,
"git reset --hard @{1}" should be a viable way to recover from the
mistake made _after_ the reflog entries were expired.
Opinions?
next reply other threads:[~2020-06-19 18:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 18:03 Junio C Hamano [this message]
2020-06-19 18:14 ` Annoyance wrt ref@{1} and reflog expiry Sergey Organov
2020-06-19 20:31 ` Junio C Hamano
2020-06-19 20:36 ` Mike Hommey
2020-06-19 21:49 ` Junio C Hamano
2020-06-19 20:44 ` Junio C Hamano
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=xmqqzh8zgcfp.fsf@gitster.c.googlers.com \
--to=gitster@pobox.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.
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).