Skip to content

Commit

Permalink
fast-import: count --max-pack-size in bytes
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
  • Loading branch information
Junio C Hamano committed Feb 4, 2010
1 parent 9f17688 commit 4d0cc22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Documentation/RelNotes-1.7.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ Notes on behaviour change
environment, and diff.*.command and diff.*.textconv in the config
file.

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

Updates since v1.6.6
Expand Down
4 changes: 2 additions & 2 deletions Documentation/git-fast-import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ OPTIONS
not contain the old commit).

--max-pack-size=<n>::
Maximum size of each output packfile, expressed in MiB.
The default is 4096 (4 GiB) as that is the maximum allowed
Maximum size of each output packfile.
The default is 4 GiB as that is the maximum allowed
packfile size (due to file format limitations). Some
importers may wish to lower this, such as to ensure the
resulting packfiles fit on CDs.
Expand Down
17 changes: 11 additions & 6 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2764,11 +2764,6 @@ static void option_date_format(const char *fmt)
die("unknown --date-format argument %s", fmt);
}

static void option_max_pack_size(const char *packsize)
{
max_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;
}

static void option_depth(const char *depth)
{
max_depth = strtoul(depth, NULL, 0);
Expand Down Expand Up @@ -2798,7 +2793,17 @@ static void option_export_pack_edges(const char *edges)
static int parse_one_option(const char *option)
{
if (!prefixcmp(option, "max-pack-size=")) {
option_max_pack_size(option + 14);
unsigned long v;
if (!git_parse_ulong(option + 14, &v))
return 0;
if (v < 8192) {
warning("max-pack-size is now in bytes, assuming --max-pack-size=%lum", v);
v *= 1024 * 1024;
} else if (v < 1024 * 1024) {
warning("minimum max-pack-size is 1 MiB");
v = 1024 * 1024;
}
max_packsize = v;
} else if (!prefixcmp(option, "big-file-threshold=")) {
unsigned long v;
if (!git_parse_ulong(option + 19, &v))
Expand Down

0 comments on commit 4d0cc22

Please sign in to comment.