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

Commit f35392b

Browse files
committed
Merge branch 'jk/repack-pack-keep-objects' into maint
* jk/repack-pack-keep-objects: repack: s/write_bitmap/&s/ in code repack: respect pack.writebitmaps repack: do not accidentally pack kept objects by default
2 parents 3fea9eb + d078d85 commit f35392b

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

builtin/repack.c

Lines changed: 9 additions & 5 deletions
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_bitmaps = -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_bitmaps = 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,
@@ -168,7 +172,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
168172
OPT__QUIET(&quiet, N_("be quiet")),
169173
OPT_BOOL('l', "local", &local,
170174
N_("pass --local to git-pack-objects")),
171-
OPT_BOOL('b', "write-bitmap-index", &write_bitmap,
175+
OPT_BOOL('b', "write-bitmap-index", &write_bitmaps,
172176
N_("write bitmap index")),
173177
OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
174178
N_("with -A, do not loosen objects older than this")),
@@ -191,7 +195,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
191195
git_repack_usage, 0);
192196

193197
if (pack_kept_objects < 0)
194-
pack_kept_objects = write_bitmap;
198+
pack_kept_objects = write_bitmaps > 0;
195199

196200
packdir = mkpathdup("%s/pack", get_object_directory());
197201
packtmp = mkpathdup("%s/.tmp-%d-pack", packdir, (int)getpid());
@@ -217,9 +221,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
217221
argv_array_pushf(&cmd_args, "--no-reuse-delta");
218222
if (no_reuse_object)
219223
argv_array_pushf(&cmd_args, "--no-reuse-object");
220-
if (write_bitmap >= 0)
224+
if (write_bitmaps >= 0)
221225
argv_array_pushf(&cmd_args, "--%swrite-bitmap-index",
222-
write_bitmap ? "" : "no-");
226+
write_bitmaps ? "" : "no-");
223227

224228
if (pack_everything & ALL_INTO_ONE) {
225229
get_non_kept_pack_filenames(&existing_packs);

t/t7700-repack.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,25 @@ 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
40-
git repack -Adl &&
40+
git repack -Adbl &&
41+
test_when_finished "found_duplicate_object=" &&
42+
for p in .git/objects/pack/*.idx; do
43+
idx=$(basename $p)
44+
test "pack-$packsha1.idx" = "$idx" && continue
45+
if git verify-pack -v $p | egrep "^$objsha1"; then
46+
found_duplicate_object=1
47+
echo "DUPLICATE OBJECT FOUND"
48+
break
49+
fi
50+
done &&
51+
test "$found_duplicate_object" = 1
52+
'
53+
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 &&
4157
test_when_finished "found_duplicate_object=" &&
4258
for p in .git/objects/pack/*.idx; do
4359
idx=$(basename $p)

0 commit comments

Comments
 (0)