@matheusbsbs / matheus-bagliano / commits / 4d0cc22437
Fork 0

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 <gitster@pobox.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Acked-by: Nicolas Pitre <nico@fluxnic.net>

Junio C Hamano committed Feb 4, 2010 at 11:10 UTC 4d0cc2243778b38c3759c6a08f4f1ed64155a070
3 files changed +17 -12
Documentation/RelNotes-1.7.0.txt
+4 -4
@@ -46,10 +46,10 @@ Notes on behaviour change
46 environment, and diff.*.command and diff.*.textconv in the config
47 file.
48
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
53 unit suffix of 'k', 'm', or 'g'.
54
55 Updates since v1.6.6
Documentation/git-fast-import.txt
+2 -2
@@ -44,8 +44,8 @@ OPTIONS
44 not contain the old commit).
45
46 --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
49 packfile size (due to file format limitations). Some
50 importers may wish to lower this, such as to ensure the
51 resulting packfiles fit on CDs.
fast-import.c
+11 -6
@@ -2764,11 +2764,6 @@ static void option_date_format(const char *fmt)
2764 die("unknown --date-format argument %s", fmt);
2765 }
2766
2767 -static void option_max_pack_size(const char *packsize)
2768 -{
2769 - max_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;
2770 -}
2771 -
2767 static void option_depth(const char *depth)
2768 {
2769 max_depth = strtoul(depth, NULL, 0);
@@ -2798,7 +2793,17 @@ static void option_export_pack_edges(const char *edges)
2793 static int parse_one_option(const char *option)
2794 {
2795 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;
2807 } else if (!prefixcmp(option, "big-file-threshold=")) {
2808 unsigned long v;
2809 if (!git_parse_ulong(option + 19, &v))