git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] reflog: fix default expiry periods

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2026, 17:27 UTC
Message-ID
<xmqq5wzxfb79.fsf@gitster.g>
In-Reply-To
<20260922165433.591551-2-pushkarkumarsingh1970@gmail.com>
Pushkar Singh <pushkarkumarsingh1970@gmail.com> writes:
Show 9 quoted lines
> 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.

Show 6 quoted lines
> 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(-)
Show 35 quoted lines
> 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.
Previous: Pushkar SinghNext: Jeff King
Message 3 of 19 in “reflog expire: default expiry times swapped since 2.50”
  1. r.norouziSep 19, 2026
  2. reflog: fix default expiry periodsPushkar Singh, Sep 22, 2026
  3. Junio C HamanoSep 22, 2026
  4. Jeff KingSep 22, 2026
  5. Patrick SteinhardtSep 23, 2026
  6. reflog: fix default expiry periodsPushkar Singh, Sep 23, 2026
  7. Junio C HamanoSep 23, 2026
  8. Patrick SteinhardtSep 24, 2026
  9. Jeff KingSep 24, 2026
  10. Junio C HamanoSep 24, 2026
  11. Jeff KingSep 24, 2026
  12. Patrick SteinhardtSep 28, 2026
  13. Junio C HamanoSep 24, 2026
  14. reflog: fix default expiry periodsPushkar Singh, Sep 24, 2026
  15. Junio C HamanoSep 24, 2026
  16. Patrick SteinhardtSep 28, 2026
  17. Junio C HamanoSep 28, 2026
  18. Patrick SteinhardtSep 29, 2026
  19. Junio C HamanoSep 29, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.