Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 3198b89

Browse files
peffgitster
authored andcommitted
repack: respect pack.writebitmaps
The config option to turn on bitmaps is read all the way down in the plumbing of pack-objects. This makes it hard for other options in the porcelain of repack to make decisions based on the bitmap setting. For example, repack.packKeptObjects tries to kick in by default only when bitmaps are turned on. But it can't do so reliably because it doesn't yet know whether we are using bitmaps. This patch teaches repack to respect pack.writebitmaps. It means we pass a redundant command-line flag to pack-objects, but that's OK; it shouldn't affect the outcome. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64d3dc9 commit 3198b89

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

builtin/repack.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
static int delta_base_offset = 1;
1212
static int pack_kept_objects = -1;
13+
static int write_bitmap = -1;
1314
static char *packdir, *packtmp;
1415

1516
static const char *const git_repack_usage[] = {
@@ -27,6 +28,10 @@ static int repack_config(const char *var, const char *value, void *cb)
2728
pack_kept_objects = git_config_bool(var, value);
2829
return 0;
2930
}
31+
if (!strcmp(var, "pack.writebitmaps")) {
32+
write_bitmap = git_config_bool(var, value);
33+
return 0;
34+
}
3035
return git_default_config(var, value, cb);
3136
}
3237

@@ -149,7 +154,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
149154
int no_update_server_info = 0;
150155
int quiet = 0;
151156
int local = 0;
152-
int write_bitmap = -1;
153157

154158
struct option builtin_repack_options[] = {
155159
OPT_BIT('a', NULL, &pack_everything,

t/t7700-repack.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
3535
test -z "$found_duplicate_object"
3636
'
3737

38-
test_expect_success 'writing bitmaps can duplicate .keep objects' '
38+
test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' '
3939
# build on $objsha1, $packsha1, and .keep state from previous
4040
git repack -Adbl &&
4141
test_when_finished "found_duplicate_object=" &&
@@ -51,6 +51,22 @@ test_expect_success 'writing bitmaps can duplicate .keep objects' '
5151
test "$found_duplicate_object" = 1
5252
'
5353

54+
test_expect_success 'writing bitmaps via config can duplicate .keep objects' '
55+
# build on $objsha1, $packsha1, and .keep state from previous
56+
git -c pack.writebitmaps=true repack -Adl &&
57+
test_when_finished "found_duplicate_object=" &&
58+
for p in .git/objects/pack/*.idx; do
59+
idx=$(basename $p)
60+
test "pack-$packsha1.idx" = "$idx" && continue
61+
if git verify-pack -v $p | egrep "^$objsha1"; then
62+
found_duplicate_object=1
63+
echo "DUPLICATE OBJECT FOUND"
64+
break
65+
fi
66+
done &&
67+
test "$found_duplicate_object" = 1
68+
'
69+
5470
test_expect_success 'loose objects in alternate ODB are not repacked' '
5571
mkdir alt_objects &&
5672
echo `pwd`/alt_objects > .git/objects/info/alternates &&

0 commit comments

Comments
 (0)