зеркало из https://github.com/microsoft/git.git
diff: parse separate options --stat-width n, --stat-name-width n
Part of a campaign for unstuck forms of options. [jn: with some refactoring] Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
4d7f7a4ae7
Коммит
1e57208ef0
28
diff.c
28
diff.c
|
@ -3035,16 +3035,34 @@ static int stat_opt(struct diff_options *options, const char **av)
|
||||||
char *end;
|
char *end;
|
||||||
int width = options->stat_width;
|
int width = options->stat_width;
|
||||||
int name_width = options->stat_name_width;
|
int name_width = options->stat_name_width;
|
||||||
|
int argcount = 1;
|
||||||
|
|
||||||
arg += strlen("--stat");
|
arg += strlen("--stat");
|
||||||
end = (char *)arg;
|
end = (char *)arg;
|
||||||
|
|
||||||
switch (*arg) {
|
switch (*arg) {
|
||||||
case '-':
|
case '-':
|
||||||
if (!prefixcmp(arg, "-width="))
|
if (!prefixcmp(arg, "-width")) {
|
||||||
width = strtoul(arg + 7, &end, 10);
|
arg += strlen("-width");
|
||||||
else if (!prefixcmp(arg, "-name-width="))
|
if (*arg == '=')
|
||||||
name_width = strtoul(arg + 12, &end, 10);
|
width = strtoul(arg + 1, &end, 10);
|
||||||
|
else if (!*arg && !av[1])
|
||||||
|
die("Option '--stat-width' requires a value");
|
||||||
|
else if (!*arg) {
|
||||||
|
width = strtoul(av[1], &end, 10);
|
||||||
|
argcount = 2;
|
||||||
|
}
|
||||||
|
} else if (!prefixcmp(arg, "-name-width")) {
|
||||||
|
arg += strlen("-name-width");
|
||||||
|
if (*arg == '=')
|
||||||
|
name_width = strtoul(arg + 1, &end, 10);
|
||||||
|
else if (!*arg && !av[1])
|
||||||
|
die("Option '--stat-name-width' requires a value");
|
||||||
|
else if (!*arg) {
|
||||||
|
name_width = strtoul(av[1], &end, 10);
|
||||||
|
argcount = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
width = strtoul(arg+1, &end, 10);
|
width = strtoul(arg+1, &end, 10);
|
||||||
|
@ -3058,7 +3076,7 @@ static int stat_opt(struct diff_options *options, const char **av)
|
||||||
options->output_format |= DIFF_FORMAT_DIFFSTAT;
|
options->output_format |= DIFF_FORMAT_DIFFSTAT;
|
||||||
options->stat_name_width = name_width;
|
options->stat_name_width = name_width;
|
||||||
options->stat_width = width;
|
options->stat_width = width;
|
||||||
return 1;
|
return argcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
int diff_opt_parse(struct diff_options *options, const char **av, int ac)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче