Skip to content

Commit 4f8e8b0

Browse files
committed
Merge branch 'ew/repack-with-bitmaps-by-default' into next
The connectivity bitmaps are created by default in bare repositories now; also the pathname hash-cache is created by default to avoid making crappy deltas when repacking. * ew/repack-with-bitmaps-by-default: pack-objects: default to writing bitmap hash-cache t5310: correctly remove bitmaps for jgit test repack: enable bitmaps by default on bare repos
2 parents f2820cf + d431660 commit 4f8e8b0

File tree

8 files changed

+28
-13
lines changed

8 files changed

+28
-13
lines changed

Documentation/config/pack.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,4 @@ pack.writeBitmapHashCache::
124124
bitmapped and non-bitmapped objects (e.g., when serving a fetch
125125
between an older, bitmapped pack and objects that have been
126126
pushed since the last gc). The downside is that it consumes 4
127-
bytes per object of disk space, and that JGit's bitmap
128-
implementation does not understand it, causing it to complain if
129-
Git and JGit are used on the same repository. Defaults to false.
127+
bytes per object of disk space. Defaults to true.

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/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static off_t reuse_packfile_offset;
9797
static int use_bitmap_index_default = 1;
9898
static int use_bitmap_index = -1;
9999
static int write_bitmap_index;
100-
static uint16_t write_bitmap_options;
100+
static uint16_t write_bitmap_options = BITMAP_OPT_HASH_CACHE;
101101

102102
static int exclude_promisor_objects;
103103

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/perf/p5310-pack-bitmaps.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ test_perf_large_repo
1212
# We intentionally use the deprecated pack.writebitmaps
1313
# config so that we can test against older versions of git.
1414
test_expect_success 'setup bitmap config' '
15-
git config pack.writebitmaps true &&
16-
git config pack.writebitmaphashcache true
15+
git config pack.writebitmaps true
1716
'
1817

1918
test_perf 'repack to disk' '

t/perf/p5311-pack-bitmaps-fetch.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ test_perf_default_repo
77

88
test_expect_success 'create bitmapped server repo' '
99
git config pack.writebitmaps true &&
10-
git config pack.writebitmaphashcache true &&
1110
git repack -ad
1211
'
1312

t/t5310-pack-bitmaps.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ test_expect_success 'setup repo with moderate-sized history' '
3434
bitmaptip=$(git rev-parse master) &&
3535
blob=$(echo tagged-blob | git hash-object -w --stdin) &&
3636
git tag tagged-blob $blob &&
37-
git config repack.writebitmaps true &&
38-
git config pack.writebitmaphashcache true
37+
git config repack.writebitmaps true
3938
'
4039

4140
test_expect_success 'full repack creates bitmaps' '
@@ -269,7 +268,7 @@ test_expect_success JGIT 'we can read jgit bitmaps' '
269268
git clone --bare . compat-jgit.git &&
270269
(
271270
cd compat-jgit.git &&
272-
rm -f .git/objects/pack/*.bitmap &&
271+
rm -f objects/pack/*.bitmap &&
273272
jgit gc &&
274273
git rev-list --test-bitmap HEAD
275274
)

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)