[PATCH] reflog: fix default expiry periods
- From
Pushkar Singh <pushkarkumarsingh1970@gmail.com>
- Date
- Sep 22, 2026, 16:54 UTC
- Message-ID
- <20260922165433.591551-2-pushkarkumarsingh1970@gmail.com>
- In-Reply-To
- <GZicFFe4cqB928v52ERTcEFaAFtAwL0rp8VaCKSMyYzJ48XbQ9XoduiDtsou0Qp4N2CGmCS49uRbxi9dUWwlFzgzlt0PkGzR7IkqysP9tVQ=@proton.me>
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.
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 + ) +' + test_expect_success 'corrupt and check' ' corrupt $F &&
-- 2.56.0.rc1.320.g68acceee5b.dirty