git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] refs: allow @{n} to work with n-sized reflog
Date: Tue, 5 Jan 2021 09:52:21 +0100	[thread overview]
Message-ID: <20210105085221.GM8396@szeder.dev> (raw)
In-Reply-To: <0c6885f15f5ce0be28142d9c69724362e72481a9.1609551262.git.liu.denton@gmail.com>

On Fri, Jan 01, 2021 at 05:36:06PM -0800, Denton Liu wrote:
> 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.

Great!  I've run into this issue quite a while ago with regular 'git
gc' expiring too old reflog entries, and wondered while the @{N}
notation errored out while the information was clearly still there in
the reflog.

https://public-inbox.org/git/20130619125059.GD20052@goldbirke/T/#u

> @@ -139,6 +139,19 @@ test_expect_success 'master@{n} for various n' '
>  	test_must_fail git rev-parse --verify master@{$Np1}
>  '
>  
> +test_expect_success '@{1} works with only one reflog entry' '
> +	git checkout -B newbranch &&
> +	git reflog expire --expire=now refs/heads/newbranch &&
> +	git commit --allow-empty -mexpired &&
> +	git rev-parse --verify newbranch@{1}
> +'
> +
> +test_expect_success '@{0} works with empty reflog' '
> +	git checkout -B newbranch &&
> +	git reflog expire --expire=now refs/heads/newbranch &&
> +	git rev-parse --verify newbranch@{0}
> +'

I agree with Martin about these tests: not failing is one thing, but
we should make sure that the right value is printed.

>  test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' '
>  	ln -s does-not-exist .git/refs/heads/broken &&
>  	test_must_fail git rev-parse --verify broken
> -- 
> 2.30.0
> 

  parent reply	other threads:[~2021-01-05  8:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02  1:36 [PATCH] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-02 22:30 ` Martin Ågren
2021-01-03  1:24 ` Denton Liu
2021-01-05  8:52 ` SZEDER Gábor [this message]
2021-01-06  5:55 ` Junio C Hamano
2021-01-06  8:25   ` Denton Liu
2021-01-06 21:02     ` Junio C Hamano
2021-01-06  9:01 ` [PATCH v2 0/2] " Denton Liu
2021-01-06  9:01   ` [PATCH v2 1/2] refs: factor out set_read_ref_cutoffs() Denton Liu
2021-01-06  9:01   ` [PATCH v2 2/2] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-06  9:59     ` SZEDER Gábor
2021-01-07 10:36   ` [PATCH v3 0/2] " Denton Liu
2021-01-07 10:36     ` [PATCH v3 1/2] refs: factor out set_read_ref_cutoffs() Denton Liu
2021-01-07 10:36     ` [PATCH v3 2/2] refs: allow @{n} to work with n-sized reflog Denton Liu
2021-01-10 20:31       ` Simon Ruderich
2021-01-12  6:14         ` [PATCH v3] fixup! " Denton Liu
2021-01-12  6:18           ` Denton Liu
2021-01-12  6:27             ` Junio C Hamano
2021-01-10 14:44     ` [PATCH v3 0/2] " SZEDER Gábor
2021-01-10 20:24       ` Junio C Hamano
2021-01-07 10:43   ` [PATCH v3 3/2] fixup! " Denton Liu

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=20210105085221.GM8396@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=liu.denton@gmail.com \
    /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).