summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-28 22:08:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-28 22:08:46 (GMT)
commitf427b94985f7f8cde46df20f644760adc0ca6735 (patch)
tree8b36ce0f3145357c9ae9fef1a82f035a0494247e /builtin
parent5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d (diff)
parentf1e4fb2462894585d88c190aa9f16826f45ebbeb (diff)
downloadgit-f427b94985f7f8cde46df20f644760adc0ca6735.zip
git-f427b94985f7f8cde46df20f644760adc0ca6735.tar.gz
git-f427b94985f7f8cde46df20f644760adc0ca6735.tar.bz2
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.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8ec459f..4c51aec 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);