summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Linus Torvalds <torvalds@osdl.org>2006-09-28 15:07:16 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-09-28 22:27:29 -0700
commit5c5b2ea9ab95f71ac155f12d75d1432b5c93c2bb (patch)
treea48aed109267f7568fe4365fb885d5c7ecbfcde3
parentdiff --stat: color output. (diff)
downloadtgif-5c5b2ea9ab95f71ac155f12d75d1432b5c93c2bb.tar.xz
diff --stat=width[,name-width]: allow custom diffstat output width.
Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--Documentation/diff-options.txt7
-rw-r--r--diff.c33
2 files changed, 30 insertions, 10 deletions
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index b5d9763594..7b7b9e8ce9 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -10,8 +10,11 @@
--patch-with-raw::
Synonym for "-p --raw".
---stat::
- Generate a diffstat.
+--stat[=width[,name-width]]::
+ Generate a diffstat. You can override the default
+ output width for 80-column terminal by "--stat=width".
+ The width of the filename part can be controlled by
+ giving another width to it separated by a comma.
--summary::
Output a condensed summary of extended header information
diff --git a/diff.c b/diff.c
index 3fd7a5220d..90e0844108 100644
--- a/diff.c
+++ b/diff.c
@@ -1735,15 +1735,32 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if (!strcmp(arg, "--patch-with-raw")) {
options->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;
}
- else if (!strcmp(arg, "--stat"))
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- else if (!strncmp(arg, "--stat-width=", 13)) {
- options->stat_width = strtoul(arg + 13, NULL, 10);
- options->output_format |= DIFF_FORMAT_DIFFSTAT;
- }
- else if (!strncmp(arg, "--stat-name-width=", 18)) {
- options->stat_name_width = strtoul(arg + 18, NULL, 10);
+ else if (!strncmp(arg, "--stat", 6)) {
+ char *end;
+ int width = options->stat_width;
+ int name_width = options->stat_name_width;
+ arg += 6;
+ end = (char *)arg;
+
+ switch (*arg) {
+ case '-':
+ if (!strncmp(arg, "-width=", 7))
+ width = strtoul(arg + 7, &end, 10);
+ else if (!strncmp(arg, "-name-width=", 12))
+ name_width = strtoul(arg + 12, &end, 10);
+ break;
+ case '=':
+ width = strtoul(arg+1, &end, 10);
+ if (*end == ',')
+ name_width = strtoul(end+1, &end, 10);
+ }
+
+ /* Important! This checks all the error cases! */
+ if (*end)
+ return 0;
options->output_format |= DIFF_FORMAT_DIFFSTAT;
+ options->stat_name_width = name_width;
+ options->stat_width = width;
}
else if (!strcmp(arg, "--check"))
options->output_format |= DIFF_FORMAT_CHECKDIFF;