git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] make --max-pack-size argument to 'git pack-object' count in bytes

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2010, 17:11 UTC
Message-ID
<7vtytxexjl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v7hqtty38.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> ...
>> Shouldn't we also change fast-import.c ?
>
> Surely; could you do the honors?  I cannot really decide how big the deal
> would be to break backward compatibility for max-pack-size myself.

I'll queue the "fix mismerge" one I got "Yup, looks good to me." from you, with this:

commit 76ea93ccb5df138eb57b2e8f2aee61dd1ca666ea
Author: Junio C Hamano <gitster@pobox.com>
Date:   Wed Feb 3 18:27:08 2010 -0800
    fast-import.c: Fix big-file-threshold parsing bug
    
    Manual merge made at 844ad3d (Merge branch 'sp/maint-fast-import-large-blob'
    into sp/fast-import-large-blob, 2010-02-01) did not correctly reflect the change
    of unit in which this variable's value is counted from its previous version.
    
    Now it counts in bytes, not in megabytes.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Acked-by: Shawn O. Pearce <spearce@spearce.org>

I am debating myself if we want to have another one (see below) on top; I am not a heavy user of fast-import and I don't know if existing users will be hurt by such a change and if so how much.

-- >8 --
Subject: [PATCH] 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, and because this is a sane thing to do anyway, a minimum size of 1 MiB is enforced to avoid an explosion of pack files.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/RelNotes-1.7.0.txt  |    8 ++++----
 Documentation/git-fast-import.txt |    4 ++--
 fast-import.c                     |   14 ++++++++------
 3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/Documentation/RelNotes-1.7.0.txt b/Documentation/RelNotes-1.7.0.txt
index e66945c..255666f 100644
--- a/Documentation/RelNotes-1.7.0.txt
+++ b/Documentation/RelNotes-1.7.0.txt
@@ -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
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 2691114..6764ff1 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -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.
diff --git a/fast-import.c b/fast-import.c
index a6730d0..09c0817 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -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);
@@ -2798,7 +2793,14 @@ 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 < 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))
-- 
1.7.0.rc1.199.g9253ab
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 6 of 16 in “fix multiple issues with t5300”
  1. 1/3 fix multiple issues with t5300Nicolas Pitre, Feb 4, 2010
  2. 2/3 pack-objects: fix pack generation when using pack_size_limitNicolas Pitre, Feb 4, 2010
  3. 3/3 make --max-pack-size argument to 'git pack-object' count in bytesNicolas Pitre, Feb 4, 2010
  4. Shawn O. PearceFeb 4, 2010
  5. Junio C HamanoFeb 4, 2010
  6. Junio C HamanoFeb 4, 2010
  7. Shawn O. PearceFeb 4, 2010
  8. Nicolas PitreFeb 4, 2010
  9. Shawn O. PearceFeb 4, 2010
  10. fast-import: count --max-pack-size in bytesJunio C Hamano, Feb 4, 2010
  11. Shawn O. PearceFeb 4, 2010
  12. Ilari LiusvaaraFeb 4, 2010
  13. Nicolas PitreFeb 4, 2010
  14. Shawn O. PearceFeb 4, 2010
  15. Nicolas PitreFeb 4, 2010
  16. Shawn O. PearceFeb 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.