Skip to content

Commit 15bf48b

Browse files
committed
Merge branch 'ds/maintenance-prefetch-cleanup'
Test clean-up plus UI improvement by hiding extra refs that the prefetch task uses from "log --decorate" output. * ds/maintenance-prefetch-cleanup: t7900: clean up some broken refs maintenance: set log.excludeDecoration durin prefetch
2 parents 18e3f5a + 3cf5f22 commit 15bf48b

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

builtin/gc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,12 @@ static int maintenance_task_prefetch(struct maintenance_run_opts *opts)
897897
struct string_list_item *item;
898898
struct string_list remotes = STRING_LIST_INIT_DUP;
899899

900+
git_config_set_multivar_gently("log.excludedecoration",
901+
"refs/prefetch/",
902+
"refs/prefetch/",
903+
CONFIG_FLAGS_FIXED_VALUE |
904+
CONFIG_FLAGS_MULTI_REPLACE);
905+
900906
if (for_each_remote(append_remote, &remotes)) {
901907
error(_("failed to fill remotes"));
902908
result = 1;

t/t7900-maintenance.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,31 @@ test_expect_success 'prefetch multiple remotes' '
149149
git log prefetch/remote2/two &&
150150
git fetch --all &&
151151
test_cmp_rev refs/remotes/remote1/one refs/prefetch/remote1/one &&
152-
test_cmp_rev refs/remotes/remote2/two refs/prefetch/remote2/two
152+
test_cmp_rev refs/remotes/remote2/two refs/prefetch/remote2/two &&
153+
154+
test_cmp_config refs/prefetch/ log.excludedecoration &&
155+
git log --oneline --decorate --all >log &&
156+
! grep "prefetch" log
157+
'
158+
159+
test_expect_success 'prefetch and existing log.excludeDecoration values' '
160+
git config --unset-all log.excludeDecoration &&
161+
git config log.excludeDecoration refs/remotes/remote1/ &&
162+
git maintenance run --task=prefetch &&
163+
164+
git config --get-all log.excludeDecoration >out &&
165+
grep refs/remotes/remote1/ out &&
166+
grep refs/prefetch/ out &&
167+
168+
git log --oneline --decorate --all >log &&
169+
! grep "prefetch" log &&
170+
! grep "remote1" log &&
171+
grep "remote2" log &&
172+
173+
# a second run does not change the config
174+
git maintenance run --task=prefetch &&
175+
git log --oneline --decorate --all >log2 &&
176+
test_cmp log log2
153177
'
154178

155179
test_expect_success 'loose-objects task' '
@@ -232,6 +256,13 @@ test_expect_success 'incremental-repack task' '
232256
HEAD
233257
^HEAD~1
234258
EOF
259+
260+
# Delete refs that have not been repacked in these packs.
261+
git for-each-ref --format="delete %(refname)" \
262+
refs/prefetch refs/tags >refs &&
263+
git update-ref --stdin <refs &&
264+
265+
# Replace the object directory with this pack layout.
235266
rm -f $packDir/pack-* &&
236267
rm -f $packDir/loose-* &&
237268
ls $packDir/*.pack >packs-before &&

0 commit comments

Comments
 (0)