Skip to content

Commit 4d0cc22

Browse files
committed
fast-import: count --max-pack-size in bytes
Similar in spirit to 07cf0f2 (make --max-pack-size argument to 'git pack-object' count in bytes, 2010-02-03) which made the option by the same name to pack-objects, this counts the pack size limit in bytes. In order not to cause havoc with people used to the previous megabyte scale an integer smaller than 8192 is interpreted in megabytes but the user gets a warning. Also a minimum size of 1 MiB is enforced to avoid an explosion of pack files. Signed-off-by: Junio C Hamano <[email protected]> Acked-by: Shawn O. Pearce <[email protected]> Acked-by: Nicolas Pitre <[email protected]>
1 parent 9f17688 commit 4d0cc22

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Documentation/RelNotes-1.7.0.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ Notes on behaviour change
4646
environment, and diff.*.command and diff.*.textconv in the config
4747
file.
4848

49-
* The --max-pack-size argument to 'git repack' and 'git pack-objects' was
50-
assuming the provided size to be expressed in MiB, unlike the
51-
corresponding config variable and other similar options accepting a size
52-
value. It is now expecting a size expressed in bytes, with a possible
49+
* The --max-pack-size argument to 'git repack', 'git pack-objects', and
50+
'git fast-import' was assuming the provided size to be expressed in MiB,
51+
unlike the corresponding config variable and other similar options accepting
52+
a size value. It is now expecting a size expressed in bytes, with a possible
5353
unit suffix of 'k', 'm', or 'g'.
5454

5555
Updates since v1.6.6

Documentation/git-fast-import.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ OPTIONS
4444
not contain the old commit).
4545

4646
--max-pack-size=<n>::
47-
Maximum size of each output packfile, expressed in MiB.
48-
The default is 4096 (4 GiB) as that is the maximum allowed
47+
Maximum size of each output packfile.
48+
The default is 4 GiB as that is the maximum allowed
4949
packfile size (due to file format limitations). Some
5050
importers may wish to lower this, such as to ensure the
5151
resulting packfiles fit on CDs.

fast-import.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,11 +2764,6 @@ static void option_date_format(const char *fmt)
27642764
die("unknown --date-format argument %s", fmt);
27652765
}
27662766

2767-
static void option_max_pack_size(const char *packsize)
2768-
{
2769-
max_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;
2770-
}
2771-
27722767
static void option_depth(const char *depth)
27732768
{
27742769
max_depth = strtoul(depth, NULL, 0);
@@ -2798,7 +2793,17 @@ static void option_export_pack_edges(const char *edges)
27982793
static int parse_one_option(const char *option)
27992794
{
28002795
if (!prefixcmp(option, "max-pack-size=")) {
2801-
option_max_pack_size(option + 14);
2796+
unsigned long v;
2797+
if (!git_parse_ulong(option + 14, &v))
2798+
return 0;
2799+
if (v < 8192) {
2800+
warning("max-pack-size is now in bytes, assuming --max-pack-size=%lum", v);
2801+
v *= 1024 * 1024;
2802+
} else if (v < 1024 * 1024) {
2803+
warning("minimum max-pack-size is 1 MiB");
2804+
v = 1024 * 1024;
2805+
}
2806+
max_packsize = v;
28022807
} else if (!prefixcmp(option, "big-file-threshold=")) {
28032808
unsigned long v;
28042809
if (!git_parse_ulong(option + 19, &v))

0 commit comments

Comments
 (0)