git-repack --max-pack-size: add option parsing to enable feature
Add --max-pack-size parsing and usage messages. Upgrade git-repack.sh to handle multiple packfile names, and build packfiles in GIT_OBJECT_DIRECTORY not GIT_DIR. Update documentation. Signed-off-by: Dana L. How <danahow@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Dana L. How committed
May 13, 2007 at 12:47 UTC
6b94b1a09af9cf877f0bc43d6097bce56f856866
4 files changed
+26
-7
Documentation/git-pack-objects.txt
+5
@@ -85,6 +85,11 @@ base-name::
85
times to get to the necessary object.
86
The default value for --window is 10 and --depth is 50.
87
88
+--max-pack-size=<n>::
89
+ Maximum size of each output packfile, expressed in MiB.
90
+ If specified, multiple packfiles may be created.
91
+ The default is unlimited.
92
+
93
--incremental::
94
This flag causes an object already in a pack ignored
95
even if it appears in the standard input.
Documentation/git-repack.txt
+5
@@ -65,6 +65,11 @@ OPTIONS
65
to be applied that many times to get to the necessary object.
66
The default value for --window is 10 and --depth is 50.
67
68
+--max-pack-size=<n>::
69
+ Maximum size of each output packfile, expressed in MiB.
70
+ If specified, multiple packfiles may be created.
71
+ The default is unlimited.
72
+
73
74
Configuration
75
-------------
builtin-pack-objects.c
+8
-1
@@ -15,7 +15,7 @@
15
#include "progress.h"
16
17
static const char pack_usage[] = "\
18
-git-pack-objects [{ -q | --progress | --all-progress }] \n\
18
+git-pack-objects [{ -q | --progress | --all-progress }] [--max-pack-size=N] \n\
19
[--local] [--incremental] [--window=N] [--depth=N] \n\
20
[--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\
21
[--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
@@ -1713,6 +1713,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1713
pack_compression_level = level;
1714
continue;
1715
}
1716
+ if (!prefixcmp(arg, "--max-pack-size=")) {
1717
+ char *end;
1718
+ pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
1719
+ if (!arg[16] || *end)
1720
+ usage(pack_usage);
1721
+ continue;
1722
+ }
1723
if (!prefixcmp(arg, "--window=")) {
1724
char *end;
1725
window = strtoul(arg+9, &end, 0);
git-repack.sh
+8
-6
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005 Linus Torvalds
4
#
5
6
-USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]'
6
+USAGE='[-a] [-d] [-f] [-l] [-n] [-q] [--max-pack-size=N] [--window=N] [--depth=N]'
7
SUBDIRECTORY_OK='Yes'
8
. git-sh-setup
9
@@ -18,6 +18,7 @@ do
18
-q) quiet=-q ;;
19
-f) no_reuse=--no-reuse-object ;;
20
-l) local=--local ;;
21
+ --max-pack-size=*) extra="$extra $1" ;;
22
--window=*) extra="$extra $1" ;;
23
--depth=*) extra="$extra $1" ;;
24
*) usage ;;
@@ -35,7 +36,7 @@ true)
36
esac
37
38
PACKDIR="$GIT_OBJECT_DIRECTORY/pack"
38
-PACKTMP="$GIT_DIR/.tmp-$$-pack"
39
+PACKTMP="$GIT_OBJECT_DIRECTORY/.tmp-$$-pack"
40
rm -f "$PACKTMP"-*
41
trap 'rm -f "$PACKTMP"-*' 0 1 2 3 15
42
@@ -62,11 +63,12 @@ case ",$all_into_one," in
63
esac
64
65
args="$args $local $quiet $no_reuse$extra"
65
-name=$(git-pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
66
+names=$(git-pack-objects --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
67
exit 1
67
-if [ -z "$name" ]; then
68
+if [ -z "$names" ]; then
69
echo Nothing new to pack.
69
-else
70
+fi
71
+for name in $names ; do
72
chmod a-w "$PACKTMP-$name.pack"
73
chmod a-w "$PACKTMP-$name.idx"
74
if test "$quiet" != '-q'; then
@@ -92,7 +94,7 @@ else
94
exit 1
95
}
96
rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
95
-fi
97
+done
98
99
if test "$remove_redundant" = t
100
then