summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <worldhello.net@gmail.com>2020-03-11 14:59:05 +0800
committerLibravatar Jiang Xin <worldhello.net@gmail.com>2020-03-11 14:59:05 +0800
commit52b2742df81a528f1fb0c5fa89bb408781459576 (patch)
tree1c075ab0c311e094d3dfbab3f1c018d3772af348 /parse-options.c
parentl10n: tr: Add glossary for Turkish translations (diff)
parentGit 2.26-rc1 (diff)
downloadtgif-52b2742df81a528f1fb0c5fa89bb408781459576.tar.xz
Merge branch 'master' of github.com:git/git into git-po-master
* 'master' of github.com:git/git: (27 commits) Git 2.26-rc1 remote-curl: show progress for fetches over dumb HTTP show_one_mergetag: print non-parent in hex form. config.mak.dev: re-enable -Wformat-zero-length rebase-interactive.c: silence format-zero-length warnings mingw: workaround for hangs when sending STDIN t6020: new test with interleaved lexicographic ordering of directories t6022, t6046: test expected behavior instead of testing a proxy for it t3035: prefer test_must_fail to bash negation for git commands t6020, t6022, t6035: update merge tests to use test helper functions t602[1236], t6034: modernize test formatting merge-recursive: apply collision handling unification to recursive case completion: add diff --color-moved[-ws] t1050: replace test -f with test_path_is_file am: support --show-current-patch=diff to retrieve .git/rebase-apply/patch am: support --show-current-patch=raw as a synonym for--show-current-patch am: convert "resume" variable to a struct parse-options: convert "command mode" to a flag parse-options: add testcases for OPT_CMDMODE() stash push: support the --pathspec-from-file option ...
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/parse-options.c b/parse-options.c
index a0cef401fc..63d6bab60c 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -61,7 +61,7 @@ static enum parse_opt_result opt_command_mode_error(
*/
for (that = all_opts; that->type != OPTION_END; that++) {
if (that == opt ||
- that->type != OPTION_CMDMODE ||
+ !(that->flags & PARSE_OPT_CMDMODE) ||
that->value != opt->value ||
that->defval != *(int *)opt->value)
continue;
@@ -95,6 +95,14 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
return error(_("%s takes no value"), optname(opt, flags));
+ /*
+ * Giving the same mode option twice, although unnecessary,
+ * is not a grave error, so let it pass.
+ */
+ if ((opt->flags & PARSE_OPT_CMDMODE) &&
+ *(int *)opt->value && *(int *)opt->value != opt->defval)
+ return opt_command_mode_error(opt, all_opts, flags);
+
switch (opt->type) {
case OPTION_LOWLEVEL_CALLBACK:
return opt->ll_callback(p, opt, NULL, unset);
@@ -130,16 +138,6 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
*(int *)opt->value = unset ? 0 : opt->defval;
return 0;
- case OPTION_CMDMODE:
- /*
- * Giving the same mode option twice, although is unnecessary,
- * is not a grave error, so let it pass.
- */
- if (*(int *)opt->value && *(int *)opt->value != opt->defval)
- return opt_command_mode_error(opt, all_opts, flags);
- *(int *)opt->value = opt->defval;
- return 0;
-
case OPTION_STRING:
if (unset)
*(const char **)opt->value = NULL;