[PATCH 2/4] Allow detached form for git diff --stat-name-width and --stat-width.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
diff.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 41b39be..c8ee603 100644
--- a/diff.c
+++ b/diff.c
@@ -3044,6 +3044,7 @@ int diff_opt_parse(struct diff_options *options, const char **argv, int ac)
else if (!strcmp(arg, "-s"))
options->output_format |= DIFF_FORMAT_NO_OUTPUT;
else if (!prefixcmp(arg, "--stat")) {
+ argcount = 1;
char *end;
int width = options->stat_width;
int name_width = options->stat_name_width;
@@ -3052,8 +3053,20 @@ int diff_opt_parse(struct diff_options *options, const char **argv, int ac)
switch (*arg) {
case '-':
+ if (!strcmp(arg, "-width")) {
+ if (!argv[1])
+ die("Option `--stat-width' requires a value");
+ width = strtoul(argv[1], &end, 10);
+ argcount = 2;
+ }
if (!prefixcmp(arg, "-width="))
width = strtoul(arg + 7, &end, 10);
+ else if (!strcmp(arg, "-name-width")) {
+ if (!argv[1])
+ die("Option `--stat-name-width' requires a value");
+ name_width = strtoul(argv[1], &end, 10);
+ argcount = 2;
+ }
else if (!prefixcmp(arg, "-name-width="))
name_width = strtoul(arg + 12, &end, 10);
break;
@@ -3069,6 +3082,7 @@ int diff_opt_parse(struct diff_options *options, const char **argv, int ac)
options->output_format |= DIFF_FORMAT_DIFFSTAT;
options->stat_name_width = name_width;
options->stat_width = width;
+ return argcount;
}
/* renames options */
--
1.7.2.25.g9ebe3