path: root/builtin/diff.c
diff options
authorZbigniew Jędrzejewski-Szmek <>2012-03-01 12:26:39 (GMT)
committerJunio C Hamano <>2012-03-01 17:13:06 (GMT)
commitaf9fedc12873bf331019a502ed1fc944fa986713 (patch)
treee6d793a7e246fbe66b794b75f0d1b40031a9e002 /builtin/diff.c
parent31c2373d39558f98222a1fd8b83ed74ccaa87161 (diff)
diff --stat: use the full terminal width
Default to the real terminal width for diff --stat output, instead of the hard-coded 80 columns. Some projects (especially in Java), have long filename paths, with nested directories or long individual filenames. When files are renamed, the filename part in stat output can be almost useless. If the middle part between { and } is long (because the file was moved to a completely different directory), then most of the path would be truncated. It makes sense to detect and use the full terminal width and display full filenames if possible. The are commands like diff, show, and log, which can adapt the output to the terminal width. There are also commands like format-patch, whose output should be independent of the terminal width. Since it is safer to use the 80-column default, the real terminal width is only used if requested by the calling code by setting diffopts.stat_width=-1. Normally this value is 0, and can be set by the user only to a non-negative value, so -1 is safe to use internally. This patch only changes the diff builtin to use the full terminal width. Signed-off-by: Zbigniew Jędrzejewski-Szmek <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/diff.c')
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/diff.c b/builtin/diff.c
index 387afa7..81b6bae 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -285,6 +285,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
+ /* Scale to real terminal size */
+ rev.diffopt.stat_width = -1;
/* Default to let external and textconv be used */