Skip to content

Commit d60dc1a

Browse files
committed
Merge branch 'ew/repack-with-bitmaps-by-default'
Generation of pack bitmaps are now disabled when .keep files exist, as these are mutually exclusive features. * ew/repack-with-bitmaps-by-default: repack: disable bitmaps-by-default if .keep files exist
2 parents 68e65de + 7328482 commit d60dc1a

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

builtin/repack.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ static void remove_pack_on_signal(int signo)
8989
raise(signo);
9090
}
9191

92+
static int has_pack_keep_file(void)
93+
{
94+
struct packed_git *p;
95+
96+
for (p = get_all_packs(the_repository); p; p = p->next) {
97+
if (p->pack_keep)
98+
return 1;
99+
}
100+
return 0;
101+
}
102+
92103
/*
93104
* Adds all packs hex strings to the fname list, which do not
94105
* have a corresponding .keep file. These packs are not to
@@ -333,9 +344,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
333344
(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
334345
die(_("--keep-unreachable and -A are incompatible"));
335346

336-
if (write_bitmaps < 0)
347+
if (write_bitmaps < 0) {
337348
write_bitmaps = (pack_everything & ALL_INTO_ONE) &&
338-
is_bare_repository();
349+
is_bare_repository() &&
350+
keep_pack_list.nr == 0 &&
351+
!has_pack_keep_file();
352+
}
339353
if (pack_kept_objects < 0)
340354
pack_kept_objects = write_bitmaps;
341355

t/t7700-repack.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,14 @@ test_expect_success 'bitmaps can be disabled on bare repos' '
239239
test -z "$bitmap"
240240
'
241241

242+
test_expect_success 'no bitmaps created if .keep files present' '
243+
pack=$(ls bare.git/objects/pack/*.pack) &&
244+
test_path_is_file "$pack" &&
245+
keep=${pack%.pack}.keep &&
246+
>"$keep" &&
247+
git -C bare.git repack -ad &&
248+
find bare.git/objects/pack/ -type f -name "*.bitmap" >actual &&
249+
test_must_be_empty actual
250+
'
251+
242252
test_done

0 commit comments

Comments
 (0)