diff-parseopt: convert -O
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Mar 24, 2019 at 15:20 UTC
f731814b3a5eec699b73bbb72ff07de66aea100d
1 file changed
+3
-20
diff.c
+3
-20
@@ -4617,22 +4617,6 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va
4617
return 1;
4618
}
4619
4620
-static inline int short_opt(char opt, const char **argv,
4621
- const char **optarg)
4622
-{
4623
- const char *arg = argv[0];
4624
- if (arg[0] != '-' || arg[1] != opt)
4625
- return 0;
4626
- if (arg[2] != '\0') {
4627
- *optarg = arg + 2;
4628
- return 1;
4629
- }
4630
- if (!argv[1])
4631
- die("Option '%c' requires a value", opt);
4632
- *optarg = argv[1];
4633
- return 2;
4634
-}
4635
-
4620
int parse_long_opt(const char *opt, const char **argv,
4621
const char **optarg)
4622
{
@@ -5397,6 +5381,8 @@ static void prep_parse_options(struct diff_options *options)
5381
OPT_BIT_F(0, "pickaxe-regex", &options->pickaxe_opts,
5382
N_("treat <string> in -S as extended POSIX regular expression"),
5383
DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG),
5384
+ OPT_FILENAME('O', NULL, &options->orderfile,
5385
+ N_("control the order in which files appear in the output")),
5386
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
5387
N_("Output to a specific file"),
5388
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5449,10 +5435,7 @@ int diff_opt_parse(struct diff_options *options,
5435
}
5436
5437
/* misc options */
5452
- else if ((argcount = short_opt('O', av, &optarg))) {
5453
- options->orderfile = prefix_filename(prefix, optarg);
5454
- return argcount;
5455
- } else if (skip_prefix(arg, "--find-object=", &arg))
5438
+ else if (skip_prefix(arg, "--find-object=", &arg))
5439
return parse_objfind_opt(options, arg);
5440
else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) {
5441
int offending = parse_diff_filter_opt(optarg, options);