@matheusbsbs / matheus-bagliano / commits / 2b84b5a874
Fork 0

Introduce the config variable pack.packSizeLimit

"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>

Johannes Schindelin committed Feb 5, 2008 at 14:25 UTC 2b84b5a874d3281d15aa0b73426b13597cd02520
4 files changed +23 -2
Documentation/config.txt
+6
@@ -766,6 +766,12 @@ pack.indexVersion::
766 whenever the corresponding pack is larger than 2 GB. Otherwise
767 the default is 1.
768
769 +pack.packSizeLimit:
770 + The default maximum size of a pack. This setting only affects
771 + packing to a file, i.e. the git:// protocol is unaffected. It
772 + can be overridden by the `\--max-pack-size` option of
773 + linkgit:git-repack[1].
774 +
775 pull.octopus::
776 The default merge strategy to use when pulling multiple branches
777 at once.
Documentation/git-pack-objects.txt
+2 -1
@@ -99,7 +99,8 @@ base-name::
99 --max-pack-size=<n>::
100 Maximum size of each output packfile, expressed in MiB.
101 If specified, multiple packfiles may be created.
102 - The default is unlimited.
102 + The default is unlimited, unless the config variable
103 + `pack.packSizeLimit` is set.
104
105 --incremental::
106 This flag causes an object already in a pack ignored
builtin-pack-objects.c
+9 -1
@@ -68,7 +68,7 @@ static int allow_ofs_delta;
68 static const char *base_name;
69 static int progress = 1;
70 static int window = 10;
71 -static uint32_t pack_size_limit;
71 +static uint32_t pack_size_limit, pack_size_limit_cfg;
72 static int depth = 50;
73 static int delta_search_threads = 1;
74 static int pack_to_stdout;
@@ -1867,6 +1867,10 @@ static int git_pack_config(const char *k, const char *v)
1867 die("bad pack.indexversion=%d", pack_idx_default_version);
1868 return 0;
1869 }
1870 + if (!strcmp(k, "pack.packsizelimit")) {
1871 + pack_size_limit_cfg = git_config_ulong(k, v);
1872 + return 0;
1873 + }
1874 return git_default_config(k, v);
1875 }
1876
@@ -2096,6 +2100,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2100 }
2101 if (!prefixcmp(arg, "--max-pack-size=")) {
2102 char *end;
2103 + pack_size_limit_cfg = 0;
2104 pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
2105 if (!arg[16] || *end)
2106 usage(pack_usage);
@@ -2220,6 +2225,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2225 if (pack_to_stdout != !base_name)
2226 usage(pack_usage);
2227
2228 + if (!pack_to_stdout && !pack_size_limit)
2229 + pack_size_limit = pack_size_limit_cfg;
2230 +
2231 if (pack_to_stdout && pack_size_limit)
2232 die("--max-pack-size cannot be used to build a pack for transfer.");
2233
t/t5300-pack-object.sh
+6
@@ -268,4 +268,10 @@ test_expect_success \
268 'make sure index-pack detects the SHA1 collision' \
269 '! git-index-pack -o bad.idx test-3.pack'
270
271 +test_expect_success \
272 + 'honor pack.packSizeLimit' \
273 + 'git config pack.packSizeLimit 200 &&
274 + packname_4=$(git pack-objects test-4 <obj-list) &&
275 + test 3 = $(ls test-4-*.pack | wc -l)'
276 +
277 test_done