diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-05-11 15:27:23 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-11 15:27:23 +0900 |
commit | 1af57f5d321aeb95dbdbe48bdb2b0e1e37528323 (patch) | |
tree | fecc8dcdda06c52d926b1a83bdef50ef3d36300c /builtin/pack-objects.c | |
parent | Merge branch 'jk/doc-format-patch-skips-merges' (diff) | |
parent | pack-objects: clamp negative depth to 0 (diff) | |
download | tgif-1af57f5d321aeb95dbdbe48bdb2b0e1e37528323.tar.xz |
Merge branch 'jk/pack-objects-negative-options-fix'
Options to "git pack-objects" that take numeric values like
--window and --depth should not accept negative values; the input
validation has been tightened.
* jk/pack-objects-negative-options-fix:
pack-objects: clamp negative depth to 0
t5316: check behavior of pack-objects --depth=0
pack-objects: clamp negative window size to 0
t5300: check that we produced expected number of deltas
t5300: modernize basic tests
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r-- | builtin/pack-objects.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index cdc38c275b..6ded130e45 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3867,6 +3867,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (pack_to_stdout != !base_name || argc) usage_with_options(pack_usage, pack_objects_options); + if (depth < 0) + depth = 0; if (depth >= (1 << OE_DEPTH_BITS)) { warning(_("delta chain depth %d is too deep, forcing %d"), depth, (1 << OE_DEPTH_BITS) - 1); @@ -3877,6 +3879,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) (1U << OE_Z_DELTA_BITS) - 1); cache_max_small_delta_size = (1U << OE_Z_DELTA_BITS) - 1; } + if (window < 0) + window = 0; strvec_push(&rp, "pack-objects"); if (thin) { |