Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Cc: r.norouzi@proton.me,  git@vger.kernel.org,  ps@pks.im,  peff@peff.net
Subject: Re: [PATCH] reflog: fix default expiry periods
Date: Tue, 22 Sep 2026 10:27:38 -0700	[thread overview]
Message-ID: <xmqq5wzxfb79.fsf@gitster.g> (raw)
In-Reply-To: <20260922165433.591551-2-pushkarkumarsingh1970@gmail.com> (Pushkar Singh's message of "Tue, 22 Sep 2026 16:54:34 +0000")

Pushkar Singh <pushkarkumarsingh1970@gmail.com> writes:

> The default expiry periods for reflog entries are reversed in
> REFLOG_EXPIRE_OPTIONS_INIT(). This causes reachable entries to
> expire after 30 days instead of the documented 90 days.
>
> Restore the intended 90-day expiry for reachable entries and
> 30-day expiry for unreachable entries.
>
> Add a regression test for a reachable reflog entry that is
> 60 days old.

Does this breakage date back to the beginning of the reflog expire
feature, or was it working perfectly fine but was broken sometime
ago?  Do we know where the breakge happened, and why?  Those are a
lot more relevant things to describe in the first paragraph.  Once
the problem is described clearly enough in a simple case like this,
the solution to the problem is so obvious that latter two paragraphs
do not need to be said.

> Reported-by: r.norouzi <r.norouzi@proton.me>
> Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
> ---
>  reflog.h          |  4 ++--
>  t/t1410-reflog.sh | 13 +++++++++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)

> diff --git a/reflog.h b/reflog.h
> index b996712c00..3bdd1ca8a5 100644
> --- a/reflog.h
> +++ b/reflog.h
> @@ -23,8 +23,8 @@ struct reflog_expire_options {
>  	int recno;
>  };
>  #define REFLOG_EXPIRE_OPTIONS_INIT(now) { \
> -	.default_expire_total = now - 30 * 24 * 3600, \
> -	.default_expire_unreachable = now - 90 * 24 * 3600, \
> +	.default_expire_total = now - 90 * 24 * 3600, \
> +	.default_expire_unreachable = now - 30 * 24 * 3600, \
>  }
>  
>  /*
> diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
> index 8f78cf4b01..1239c078ef 100755
> --- a/t/t1410-reflog.sh
> +++ b/t/t1410-reflog.sh
> @@ -153,6 +153,19 @@ test_expect_success 'reflog expire should not barf on an annotated tag' '
>  	test_grep ! "error: [Oo]bject .* not a commit" err
>  '
>  
> +test_expect_success 'reflog expire keeps reachable entries for 90 days' '
> +	test_when_finished "rm -rf repo" &&
> +	git init repo &&
> +	(
> +		cd repo &&
> +		timestamp=$(test-tool date timestamp "60.days.ago") &&
> +		timestamp=${timestamp#* -> } &&
> +		test_commit --no-tag --date "$timestamp +0000" old &&
> +		git reflog expire --all &&
> +		test_stdout_line_count = 1 git reflog refs/heads/main
> +	)
> +'

Do you also want to see what happens to entries that point at
unreachable objects that is say 20 days and 40 days old,
respectively, plus an entry that points at a reachable object that
is 100 days old?  "Keeping" is "not expiring" and driven by the same
logic, so it is better to test both sides of the same coin, isn't it?

>  test_expect_success 'corrupt and check' '
>  
>  	corrupt $F &&

Thanks.

  reply	other threads:[~2026-09-22 17:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 18:32 reflog expire: default expiry times swapped since 2.50 r.norouzi
2026-09-22 16:54 ` [PATCH] reflog: fix default expiry periods Pushkar Singh
2026-09-22 17:27   ` Junio C Hamano [this message]
2026-09-22 18:02     ` Jeff King
2026-09-23 12:21       ` Patrick Steinhardt
2026-09-23 10:21   ` [PATCH v2] " Pushkar Singh
2026-09-23 19:26     ` Junio C Hamano
2026-09-24 14:12       ` Patrick Steinhardt
2026-09-24 15:46         ` Jeff King
2026-09-24 17:45           ` Junio C Hamano
2026-09-24 18:43             ` Jeff King
2026-09-28  6:53               ` Patrick Steinhardt
2026-09-24 17:43         ` Junio C Hamano
2026-09-24 17:58     ` [PATCH v3] " Pushkar Singh
2026-09-24 18:26       ` Junio C Hamano
2026-09-28  7:02       ` Patrick Steinhardt
2026-09-28 14:50         ` Junio C Hamano
2026-09-29  5:45           ` Patrick Steinhardt
2026-09-29 18:31             ` 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=xmqq5wzxfb79.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=pushkarkumarsingh1970@gmail.com \
    --cc=r.norouzi@proton.me \
    /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