@ -3395,12 +3395,10 @@ int parse_long_opt(const char *opt, const char **argv,
const char **optarg)
const char **optarg)
{
{
const char *arg = argv[0];
const char *arg = argv[0];
if (arg[0] != '-' || arg[1] != '-')
if (!skip_prefix(arg, "--", &arg))
return 0;
return 0;
arg += strlen("--");
if (!skip_prefix(arg, opt, &arg))
if (!starts_with(arg, opt))
return 0;
return 0;
arg += strlen(opt);
if (*arg == '=') { /* stuck form: --option=value */
if (*arg == '=') { /* stuck form: --option=value */
*optarg = arg + 1;
*optarg = arg + 1;
return 1;
return 1;
@ -3429,8 +3427,7 @@ static int stat_opt(struct diff_options *options, const char **av)
switch (*arg) {
switch (*arg) {
case '-':
case '-':
if (starts_with(arg, "-width")) {
if (skip_prefix(arg, "-width", &arg)) {
arg += strlen("-width");
if (*arg == '=')
if (*arg == '=')
width = strtoul(arg + 1, &end, 10);
width = strtoul(arg + 1, &end, 10);
else if (!*arg && !av[1])
else if (!*arg && !av[1])
@ -3439,8 +3436,7 @@ static int stat_opt(struct diff_options *options, const char **av)
width = strtoul(av[1], &end, 10);
width = strtoul(av[1], &end, 10);
argcount = 2;
argcount = 2;
}
}
} else if (starts_with(arg, "-name-width")) {
} else if (skip_prefix(arg, "-name-width", &arg)) {
arg += strlen("-name-width");
if (*arg == '=')
if (*arg == '=')
name_width = strtoul(arg + 1, &end, 10);
name_width = strtoul(arg + 1, &end, 10);
else if (!*arg && !av[1])
else if (!*arg && !av[1])
@ -3449,8 +3445,7 @@ static int stat_opt(struct diff_options *options, const char **av)
name_width = strtoul(av[1], &end, 10);
name_width = strtoul(av[1], &end, 10);
argcount = 2;
argcount = 2;
}
}
} else if (starts_with(arg, "-graph-width")) {
} else if (skip_prefix(arg, "-graph-width", &arg)) {
arg += strlen("-graph-width");
if (*arg == '=')
if (*arg == '=')
graph_width = strtoul(arg + 1, &end, 10);
graph_width = strtoul(arg + 1, &end, 10);
else if (!*arg && !av[1])
else if (!*arg && !av[1])
@ -3459,8 +3454,7 @@ static int stat_opt(struct diff_options *options, const char **av)
graph_width = strtoul(av[1], &end, 10);
graph_width = strtoul(av[1], &end, 10);
argcount = 2;
argcount = 2;
}
}
} else if (starts_with(arg, "-count")) {
} else if (skip_prefix(arg, "-count", &arg)) {
arg += strlen("-count");
if (*arg == '=')
if (*arg == '=')
count = strtoul(arg + 1, &end, 10);
count = strtoul(arg + 1, &end, 10);
else if (!*arg && !av[1])
else if (!*arg && !av[1])
@ -3905,16 +3899,13 @@ static int diff_scoreopt_parse(const char *opt)
cmd = *opt++;
cmd = *opt++;
if (cmd == '-') {
if (cmd == '-') {
/* convert the long-form arguments into short-form versions */
/* convert the long-form arguments into short-form versions */
if (starts_with(opt, "break-rewrites")) {
if (skip_prefix(opt, "break-rewrites", &opt)) {
opt += strlen("break-rewrites");
if (*opt == 0 || *opt++ == '=')
if (*opt == 0 || *opt++ == '=')
cmd = 'B';
cmd = 'B';
} else if (starts_with(opt, "find-copies")) {
} else if (skip_prefix(opt, "find-copies", &opt)) {
opt += strlen("find-copies");
if (*opt == 0 || *opt++ == '=')
if (*opt == 0 || *opt++ == '=')
cmd = 'C';
cmd = 'C';
} else if (starts_with(opt, "find-renames")) {
} else if (skip_prefix(opt, "find-renames", &opt)) {
opt += strlen("find-renames");
if (*opt == 0 || *opt++ == '=')
if (*opt == 0 || *opt++ == '=')
cmd = 'M';
cmd = 'M';
}
}