Skip to content

Commit 9410741

Browse files
ttaylorrgitster
authored andcommitted
pack-objects: allow setting pack.allowPackReuse to "single"
In e704fc7 (pack-objects: introduce pack.allowPackReuse, 2019-12-18), the `pack.allowPackReuse` configuration option was introduced, allowing users to disable the pack reuse mechanism. To prepare for debugging multi-pack reuse, allow setting configuration to "single" in addition to the usual bool-or-int values. "single" implies the same behavior as "true", "1", "yes", and so on. But it will complement a new "multi" value (to be introduced in a future commit). When set to "single", we will only perform pack reuse on a single pack, regardless of whether or not there are multiple MIDX'd packs. This requires no code changes (yet), since we only support single pack reuse. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3bea0c0 commit 9410741

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Documentation/config/pack.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ all existing objects. You can force recompression by passing the -F option
2828
to linkgit:git-repack[1].
2929

3030
pack.allowPackReuse::
31-
When true, and when reachability bitmaps are enabled,
31+
When true or "single", and when reachability bitmaps are enabled,
3232
pack-objects will try to send parts of the bitmapped packfile
3333
verbatim. This can reduce memory and CPU usage to serve fetches,
3434
but might result in sending a slightly larger pack. Defaults to

builtin/pack-objects.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ static struct bitmap *reuse_packfile_bitmap;
229229

230230
static int use_bitmap_index_default = 1;
231231
static int use_bitmap_index = -1;
232-
static int allow_pack_reuse = 1;
232+
static enum {
233+
NO_PACK_REUSE = 0,
234+
SINGLE_PACK_REUSE,
235+
} allow_pack_reuse = SINGLE_PACK_REUSE;
233236
static enum {
234237
WRITE_BITMAP_FALSE = 0,
235238
WRITE_BITMAP_QUIET,
@@ -3244,7 +3247,17 @@ static int git_pack_config(const char *k, const char *v,
32443247
return 0;
32453248
}
32463249
if (!strcmp(k, "pack.allowpackreuse")) {
3247-
allow_pack_reuse = git_config_bool(k, v);
3250+
int res = git_parse_maybe_bool_text(v);
3251+
if (res < 0) {
3252+
if (!strcasecmp(v, "single"))
3253+
allow_pack_reuse = SINGLE_PACK_REUSE;
3254+
else
3255+
die(_("invalid pack.allowPackReuse value: '%s'"), v);
3256+
} else if (res) {
3257+
allow_pack_reuse = SINGLE_PACK_REUSE;
3258+
} else {
3259+
allow_pack_reuse = NO_PACK_REUSE;
3260+
}
32483261
return 0;
32493262
}
32503263
if (!strcmp(k, "pack.threads")) {
@@ -3999,7 +4012,7 @@ static void loosen_unused_packed_objects(void)
39994012
*/
40004013
static int pack_options_allow_reuse(void)
40014014
{
4002-
return allow_pack_reuse &&
4015+
return allow_pack_reuse != NO_PACK_REUSE &&
40034016
pack_to_stdout &&
40044017
!ignore_packed_keep_on_disk &&
40054018
!ignore_packed_keep_in_core &&

0 commit comments

Comments
 (0)