{"thread":{"id":"8042","subject":"[PATCH 4/4] git-repack --max-pack-size: add option parsing to enable feature","startedAt":"2007-05-08T20:05:04Z","lastAt":"2007-05-08T20:05:04Z","messageCount":1,"participants":["Dana How"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"41492","messageId":"4640D7F0.40702@gmail.com","threadId":"8042","inReplyTo":null,"subject":"[PATCH 4/4] git-repack --max-pack-size: add option parsing to enable feature","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-05-08T20:05:04Z","receivedAt":"2007-05-08T20:05:04Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nAdd --max-pack-size parsing and usage messages.\nUpgrade git-repack.sh to handle multiple packfile names,\nand build packfiles in GIT_OBJECT_DIRECTORY not GIT_DIR.\nUpdate documentation.\n\nSigned-off-by: Dana L. How <danahow@gmail.com>\n---\n Documentation/git-pack-objects.txt |    5 +++++\n Documentation/git-repack.txt       |    5 +++++\n builtin-pack-objects.c             |    9 ++++++++-\n git-repack.sh                      |   14 ++++++++------\n 4 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt\nindex d9e11c6..e762cc7 100644\n--- a/Documentation/git-pack-objects.txt\n+++ b/Documentation/git-pack-objects.txt\n@@ -85,6 +85,11 @@ base-name::\n \ttimes to get to the necessary object.\n \tThe default value for both --window and --depth is 10.\n \n+--max-pack-size=<n>::\n+\tMaximum size of each output packfile, expressed in MiB.\n+\tIf specified,  multiple packfiles may be created.\n+\tThe default is unlimited.\n+\n --incremental::\n \tThis flag causes an object already in a pack ignored\n \teven if it appears in the standard input.\ndiff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt\nindex d39abc1..c6be673 100644\n--- a/Documentation/git-repack.txt\n+++ b/Documentation/git-repack.txt\n@@ -65,6 +65,11 @@ OPTIONS\n \tto be applied that many times to get to the necessary object.\n \tThe default value for both --window and --depth is 10.\n \n+--max-pack-size=<n>::\n+\tMaximum size of each output packfile, expressed in MiB.\n+\tIf specified,  multiple packfiles may be created.\n+\tThe default is unlimited.\n+\n \n Configuration\n -------------\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 2932b88..8824793 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -15,7 +15,7 @@\n #include \"progress.h\"\n \n static const char pack_usage[] = \"\\\n-git-pack-objects [{ -q | --progress | --all-progress }] \\n\\\n+git-pack-objects [{ -q | --progress | --all-progress }] [--max-pack-size=N] \\n\\\n \t[--local] [--incremental] [--window=N] [--depth=N] \\n\\\n \t[--no-reuse-delta] [--delta-base-offset] [--non-empty] \\n\\\n \t[--revs [--unpacked | --all]*] [--reflog] [--stdout | base-name] \\n\\\n@@ -1754,6 +1754,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t\tincremental = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!prefixcmp(arg, \"--max-pack-size=\")) {\n+\t\t\tchar *end;\n+\t\t\tpack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;\n+\t\t\tif (!arg[16] || *end)\n+\t\t\t\tusage(pack_usage);\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!prefixcmp(arg, \"--window=\")) {\n \t\t\tchar *end;\n \t\t\twindow = strtoul(arg+9, &end, 0);\ndiff --git a/git-repack.sh b/git-repack.sh\nindex ddfa8b4..44c12a7 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Linus Torvalds\n #\n \n-USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'\n+USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--max-pack-size=N] [--window=N] [--depth=N]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n@@ -18,6 +18,7 @@ do\n \t-q)\tquiet=-q ;;\n \t-f)\tno_reuse_delta=--no-reuse-delta ;;\n \t-l)\tlocal=--local ;;\n+\t--max-pack-size=*) extra=\"$extra $1\" ;;\n \t--window=*) extra=\"$extra $1\" ;;\n \t--depth=*) extra=\"$extra $1\" ;;\n \t*)\tusage ;;\n@@ -35,7 +36,7 @@ true)\n esac\n \n PACKDIR=\"$GIT_OBJECT_DIRECTORY/pack\"\n-PACKTMP=\"$GIT_DIR/.tmp-$$-pack\"\n+PACKTMP=\"$GIT_OBJECT_DIRECTORY/.tmp-$$-pack\"\n rm -f \"$PACKTMP\"-*\n trap 'rm -f \"$PACKTMP\"-*' 0 1 2 3 15\n \n@@ -62,11 +63,12 @@ case \",$all_into_one,\" in\n esac\n \n args=\"$args $local $quiet $no_reuse_delta$extra\"\n-name=$(git-pack-objects --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n+names=$(git-pack-objects --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n \texit 1\n-if [ -z \"$name\" ]; then\n+if [ -z \"$names\" ]; then\n \techo Nothing new to pack.\n-else\n+fi\n+for name in $names ; do\n \tchmod a-w \"$PACKTMP-$name.pack\"\n \tchmod a-w \"$PACKTMP-$name.idx\"\n \tif test \"$quiet\" != '-q'; then\n@@ -92,7 +94,7 @@ else\n \t\texit 1\n \t}\n \trm -f \"$PACKDIR/old-pack-$name.pack\" \"$PACKDIR/old-pack-$name.idx\"\n-fi\n+done\n \n if test \"$remove_redundant\" = t\n then\n-- \n1.5.2.rc0.787.g0014\n"}]}