From 1a85b49b87af0e17a503b94df10d0b39472ad5b8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 14 Mar 2019 04:25:04 -0700 Subject: parse-options: make OPT_ARGUMENT() more useful `OPT_ARGUMENT()` is intended to keep the specified long option in `argv` and not to do anything else. However, it would make a lot of sense for the caller to know whether this option was seen at all or not. For example, we want to teach `git difftool` to work outside of any Git worktree, but only when `--no-index` was specified. Note: nothing in Git uses OPT_ARGUMENT(). Even worse, looking through the commit history, one can easily see that nothing even ever used it, apart from the regression test. So not only do we make `OPT_ARGUMENT()` more useful, we are also about to introduce its first real user! Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- parse-options.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'parse-options.c') diff --git a/parse-options.c b/parse-options.c index cec74522e5..1d57802da0 100644 --- a/parse-options.c +++ b/parse-options.c @@ -286,6 +286,8 @@ again: optname(options, flags)); if (*rest) continue; + if (options->value) + *(int *)options->value = options->defval; p->out[p->cpidx++] = arg - 2; return PARSE_OPT_DONE; } -- cgit v1.3-5-g9baa