Skip to content

Commit 36eba03

Browse files
Eric Wonggitster
authored andcommitted
repack: enable bitmaps by default on bare repos
A typical use case for bare repos is for serving clones and fetches to clients. Enable bitmaps by default on bare repos to make it easier for admins to host git repos in a performant way. Signed-off-by: Eric Wong <[email protected]> Helped-by: Jeff King <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e94f7a commit 36eba03

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Documentation/config/repack.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ repack.writeBitmaps::
2424
packs created for clones and fetches, at the cost of some disk
2525
space and extra time spent on the initial repack. This has
2626
no effect if multiple packfiles are created.
27-
Defaults to false.
27+
Defaults to true on bare repos, false otherwise.

builtin/repack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
static int delta_base_offset = 1;
1616
static int pack_kept_objects = -1;
17-
static int write_bitmaps;
17+
static int write_bitmaps = -1;
1818
static int use_delta_islands;
1919
static char *packdir, *packtmp;
2020

@@ -343,6 +343,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
343343
(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
344344
die(_("--keep-unreachable and -A are incompatible"));
345345

346+
if (write_bitmaps < 0)
347+
write_bitmaps = (pack_everything & ALL_INTO_ONE) &&
348+
is_bare_repository();
346349
if (pack_kept_objects < 0)
347350
pack_kept_objects = write_bitmaps;
348351

t/t7700-repack.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,22 @@ test_expect_success 'repack --keep-pack' '
221221
)
222222
'
223223

224-
test_done
224+
test_expect_success 'bitmaps are created by default in bare repos' '
225+
git clone --bare .git bare.git &&
226+
git -C bare.git repack -ad &&
227+
bitmap=$(ls bare.git/objects/pack/*.bitmap) &&
228+
test_path_is_file "$bitmap"
229+
'
230+
231+
test_expect_success 'incremental repack does not complain' '
232+
git -C bare.git repack -q 2>repack.err &&
233+
test_must_be_empty repack.err
234+
'
225235

236+
test_expect_success 'bitmaps can be disabled on bare repos' '
237+
git -c repack.writeBitmaps=false -C bare.git repack -ad &&
238+
bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) &&
239+
test -z "$bitmap"
240+
'
241+
242+
test_done

0 commit comments

Comments
 (0)