diff options
author | René Scharfe <l.s.r@web.de> | 2022-12-01 23:51:21 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-12-02 08:25:29 +0900 |
commit | 6c6048fa7f1cf7b9ae79beb0f57fd03dd4021bb4 (patch) | |
tree | ff3c1d6a7f9ca68a70219b2674585fad081b75c7 /diff.c | |
parent | c5630c4868c74aab2fc4e8a4ef4bfc9c51534e0e (diff) | |
download | git-6c6048fa7f1cf7b9ae79beb0f57fd03dd4021bb4.tar.gz |
diff: use add_diff_options() in diff_opt_parse()
Prepare the removal of the parseopts member of struct diff_options by
using the API function add_diff_options() instead of accessing it
directly to get the command line option definitions. Building the copy
by concatenating with an empty option array is slightly awkward, but
simpler than a non-concat version of add_diff_options() would be to use
in places that need concatenation.
Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -5680,15 +5680,19 @@ static void prep_parse_options(struct diff_options *options) int diff_opt_parse(struct diff_options *options, const char **av, int ac, const char *prefix) { + struct option no_options[] = { OPT_END() }; + struct option *parseopts = add_diff_options(no_options, options); + if (!prefix) prefix = ""; - ac = parse_options(ac, av, prefix, options->parseopts, NULL, + ac = parse_options(ac, av, prefix, parseopts, NULL, PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_UNKNOWN_OPT | PARSE_OPT_NO_INTERNAL_HELP | PARSE_OPT_ONE_SHOT | PARSE_OPT_STOP_AT_NON_OPTION); + free(parseopts); return ac; } |