reflog: fix default expiry periods
The default reflog expiry periods were swapped when they were moved to
REFLOG_EXPIRE_OPTIONS_INIT() by 8565827570 (builtin/reflog: stop storing
default reflog expiry dates globally).
This caused reachable entries to expire after 30 days instead of 90 days,
and unreachable entries after 90 days instead of 30 days.
Reported-by: r.norouzi <r.norouzi@proton.me>
Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
next
parent
e9019fcafe
commit
60cf500551
4
reflog.h
4
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, \
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -153,6 +153,72 @@ 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 reachable-keep" &&
|
||||
git init reachable-keep &&
|
||||
(
|
||||
cd reachable-keep &&
|
||||
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 'reflog expire removes reachable entries after 90 days' '
|
||||
test_when_finished "rm -rf reachable-expire" &&
|
||||
git init reachable-expire &&
|
||||
(
|
||||
cd reachable-expire &&
|
||||
timestamp=$(test-tool date timestamp "100.days.ago") &&
|
||||
timestamp=${timestamp#* -> } &&
|
||||
test_commit --no-tag --date "$timestamp +0000" old &&
|
||||
git reflog expire --all &&
|
||||
test_stdout_line_count = 0 git reflog refs/heads/main
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'reflog expire keeps unreachable entries for 30 days' '
|
||||
test_when_finished "rm -rf unreachable-keep" &&
|
||||
git init unreachable-keep &&
|
||||
(
|
||||
cd unreachable-keep &&
|
||||
test_commit --no-tag base &&
|
||||
base=$(git rev-parse HEAD) &&
|
||||
timestamp=$(test-tool date timestamp "20.days.ago") &&
|
||||
timestamp=${timestamp#* -> } &&
|
||||
test_commit --no-tag --date "$timestamp +0000" old &&
|
||||
old=$(git rev-parse HEAD) &&
|
||||
git update-ref refs/heads/main "$base" &&
|
||||
git rev-list --all --objects >reachable &&
|
||||
test_grep ! "$old" reachable &&
|
||||
git reflog expire --all &&
|
||||
git reflog --format='%H' refs/heads/main >actual &&
|
||||
test_grep "$old" actual
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'reflog expire removes unreachable entries after 30 days' '
|
||||
test_when_finished "rm -rf unreachable-expire" &&
|
||||
git init unreachable-expire &&
|
||||
(
|
||||
cd unreachable-expire &&
|
||||
test_commit --no-tag base &&
|
||||
base=$(git rev-parse HEAD) &&
|
||||
timestamp=$(test-tool date timestamp "40.days.ago") &&
|
||||
timestamp=${timestamp#* -> } &&
|
||||
test_commit --no-tag --date "$timestamp +0000" old &&
|
||||
old=$(git rev-parse HEAD) &&
|
||||
git update-ref refs/heads/main "$base" &&
|
||||
git rev-list --all --objects >reachable &&
|
||||
test_grep ! "$old" reachable &&
|
||||
git reflog expire --all &&
|
||||
git reflog --format='%H' refs/heads/main >actual &&
|
||||
test_grep ! "$old" actual
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'corrupt and check' '
|
||||
|
||||
corrupt $F &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue