Skip to content

Commit

Permalink
Introduce the config variable pack.packSizeLimit
Browse files Browse the repository at this point in the history
"git pack-objects" has the option --max-pack-size to limit the file
size of the packs to a certain amount of bytes.  On platforms where
the pack file size is limited by filesystem constraints, it is easy
to forget this option, and this option does not exist for "git gc"
to begin with.

So introduce a config variable to set the default maximum, but make
this overrideable by the command line.

Suggested by Tor Arvid Lund.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Feb 10, 2008
1 parent 201945e commit 2b84b5a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,12 @@ pack.indexVersion::
whenever the corresponding pack is larger than 2 GB. Otherwise
the default is 1.

pack.packSizeLimit:
The default maximum size of a pack. This setting only affects
packing to a file, i.e. the git:// protocol is unaffected. It
can be overridden by the `\--max-pack-size` option of
linkgit:git-repack[1].

pull.octopus::
The default merge strategy to use when pulling multiple branches
at once.
Expand Down
3 changes: 2 additions & 1 deletion Documentation/git-pack-objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ base-name::
--max-pack-size=<n>::
Maximum size of each output packfile, expressed in MiB.
If specified, multiple packfiles may be created.
The default is unlimited.
The default is unlimited, unless the config variable
`pack.packSizeLimit` is set.

--incremental::
This flag causes an object already in a pack ignored
Expand Down
10 changes: 9 additions & 1 deletion builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int allow_ofs_delta;
static const char *base_name;
static int progress = 1;
static int window = 10;
static uint32_t pack_size_limit;
static uint32_t pack_size_limit, pack_size_limit_cfg;
static int depth = 50;
static int delta_search_threads = 1;
static int pack_to_stdout;
Expand Down Expand Up @@ -1867,6 +1867,10 @@ static int git_pack_config(const char *k, const char *v)
die("bad pack.indexversion=%d", pack_idx_default_version);
return 0;
}
if (!strcmp(k, "pack.packsizelimit")) {
pack_size_limit_cfg = git_config_ulong(k, v);
return 0;
}
return git_default_config(k, v);
}

Expand Down Expand Up @@ -2096,6 +2100,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
}
if (!prefixcmp(arg, "--max-pack-size=")) {
char *end;
pack_size_limit_cfg = 0;
pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
if (!arg[16] || *end)
usage(pack_usage);
Expand Down Expand Up @@ -2220,6 +2225,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (pack_to_stdout != !base_name)
usage(pack_usage);

if (!pack_to_stdout && !pack_size_limit)
pack_size_limit = pack_size_limit_cfg;

if (pack_to_stdout && pack_size_limit)
die("--max-pack-size cannot be used to build a pack for transfer.");

Expand Down
6 changes: 6 additions & 0 deletions t/t5300-pack-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,10 @@ test_expect_success \
'make sure index-pack detects the SHA1 collision' \
'! git-index-pack -o bad.idx test-3.pack'

test_expect_success \
'honor pack.packSizeLimit' \
'git config pack.packSizeLimit 200 &&
packname_4=$(git pack-objects test-4 <obj-list) &&
test 3 = $(ls test-4-*.pack | wc -l)'

test_done

0 comments on commit 2b84b5a

Please sign in to comment.