Skip to content

Commit d491f5e

Browse files
hanwengitster
authored andcommitted
t5304: use "reflog expire --all" to clear the reflog
This test checks that unreachable objects are really removed. For the test to work, it has to ensure that no reflog retain any reachable objects. Previously, it did this by manipulating the file system to remove reflog in the first test, and relying on git not updating the reflog if the relevant logfile doesn't exist in follow-up tests. Now, explicitly clear the reflog using 'reflog expire'. This reduces the dependency between test functions. It also is more amenable to use with reftable, which has no concept of (non)-existence of a reflog Signed-off-by: Han-Wen Nienhuys <[email protected]> Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fa9cf6 commit d491f5e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

t/t5304-prune.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,28 @@ test_expect_success 'prune: prune nonsense parameters' '
8181

8282
test_expect_success 'prune: prune unreachable heads' '
8383
git config core.logAllRefUpdates false &&
84-
mv .git/logs .git/logs.old &&
85-
: > file2 &&
84+
>file2 &&
8685
git add file2 &&
8786
git commit -m temporary &&
8887
tmp_head=$(git rev-list -1 HEAD) &&
8988
git reset HEAD^ &&
89+
git reflog expire --all &&
9090
git prune &&
9191
test_must_fail git reset $tmp_head --
9292
'
9393

9494
test_expect_success 'prune: do not prune detached HEAD with no reflog' '
9595
git checkout --detach --quiet &&
9696
git commit --allow-empty -m "detached commit" &&
97-
# verify that there is no reflogs
98-
# (should be removed and disabled by previous test)
99-
test_path_is_missing .git/logs &&
97+
git reflog expire --all &&
10098
git prune -n >prune_actual &&
10199
test_must_be_empty prune_actual
102100
'
103101

104102
test_expect_success 'prune: prune former HEAD after checking out branch' '
105103
head_oid=$(git rev-parse HEAD) &&
106104
git checkout --quiet main &&
105+
git reflog expire --all &&
107106
git prune -v >prune_actual &&
108107
grep "$head_oid" prune_actual
109108
'

0 commit comments

Comments
 (0)