diff options
author | Junio C Hamano <junkio@cox.net> | 2007-05-20 02:19:19 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-05-20 02:19:19 -0700 |
commit | 45bde46bfb9cbc5565f9fc6caa819333578c53e1 (patch) | |
tree | 48f99ae41d842204af4ea63d3bd7bff788b068e3 /builtin-pack-objects.c | |
parent | e223249a13799c047797c80eab21e4e257283c3d (diff) | |
parent | 960ccca6803c9fb57429d43572a9545a96107e32 (diff) | |
download | git-45bde46bfb9cbc5565f9fc6caa819333578c53e1.tar.gz |
Merge branch 'dh/pack'
* dh/pack:
Custom compression levels for objects and packs
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r-- | builtin-pack-objects.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 5fa98132fe..d165f10288 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -68,6 +68,8 @@ static int depth = 50; static int pack_to_stdout; static int num_preferred_base; static struct progress progress_state; +static int pack_compression_level = Z_DEFAULT_COMPRESSION; +static int pack_compression_seen; /* * The object names in objects array are hashed with this hashtable, @@ -418,7 +420,7 @@ static unsigned long write_object(struct sha1file *f, sha1write(f, entry->delta->sha1, 20); hdrlen += 20; } - datalen = sha1write_compressed(f, buf, size); + datalen = sha1write_compressed(f, buf, size, pack_compression_level); free(buf); } else { @@ -1427,6 +1429,16 @@ static int git_pack_config(const char *k, const char *v) depth = git_config_int(k, v); return 0; } + if (!strcmp(k, "pack.compression")) { + int level = git_config_int(k, v); + if (level == -1) + level = Z_DEFAULT_COMPRESSION; + else if (level < 0 || level > Z_BEST_COMPRESSION) + die("bad pack compression level %d", level); + pack_compression_level = level; + pack_compression_seen = 1; + return 0; + } return git_default_config(k, v); } @@ -1538,6 +1550,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) rp_ac = 2; git_config(git_pack_config); + if (!pack_compression_seen && core_compression_seen) + pack_compression_level = core_compression_level; progress = isatty(2); for (i = 1; i < argc; i++) { @@ -1558,6 +1572,18 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) incremental = 1; continue; } + if (!prefixcmp(arg, "--compression=")) { + char *end; + int level = strtoul(arg+14, &end, 0); + if (!arg[14] || *end) + usage(pack_usage); + if (level == -1) + level = Z_DEFAULT_COMPRESSION; + else if (level < 0 || level > Z_BEST_COMPRESSION) + die("bad pack compression level %d", level); + pack_compression_level = level; + continue; + } if (!prefixcmp(arg, "--window=")) { char *end; window = strtoul(arg+9, &end, 0); |