diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:46 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:46 -0800 |
commit | f427b94985f7f8cde46df20f644760adc0ca6735 (patch) | |
tree | 8b36ce0f3145357c9ae9fef1a82f035a0494247e /builtin | |
parent | 5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d (diff) | |
parent | f1e4fb2462894585d88c190aa9f16826f45ebbeb (diff) | |
download | git-f427b94985f7f8cde46df20f644760adc0ca6735.tar.gz |
Merge branch 'cc/skip-to-optional-val'
Introduce a helper to simplify code to parse a common pattern that
expects either "--key" or "--key=<something>".
* cc/skip-to-optional-val:
t4045: reindent to make helpers readable
diff: add tests for --relative without optional prefix value
diff: use skip_to_optional_arg_default() in parsing --relative
diff: use skip_to_optional_arg_default()
diff: use skip_to_optional_arg()
index-pack: use skip_to_optional_arg()
git-compat-util: introduce skip_to_optional_arg()
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/index-pack.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 8ec459f522..4c51aec81f 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1660,10 +1660,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) from_stdin = 1; } else if (!strcmp(arg, "--fix-thin")) { fix_thin_pack = 1; - } else if (!strcmp(arg, "--strict")) { - strict = 1; - do_fsck_object = 1; - } else if (skip_prefix(arg, "--strict=", &arg)) { + } else if (skip_to_optional_arg(arg, "--strict", &arg)) { strict = 1; do_fsck_object = 1; fsck_set_msg_types(&fsck_options, arg); @@ -1679,10 +1676,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) verify = 1; show_stat = 1; stat_only = 1; - } else if (!strcmp(arg, "--keep")) { - keep_msg = ""; - } else if (starts_with(arg, "--keep=")) { - keep_msg = arg + 7; + } else if (skip_to_optional_arg(arg, "--keep", &keep_msg)) { + ; /* nothing to do */ } else if (starts_with(arg, "--threads=")) { char *end; nr_threads = strtoul(arg+10, &end, 0); |