diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-03-01 13:26:39 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-03-01 09:13:06 -0800 |
commit | af9fedc12873bf331019a502ed1fc944fa986713 (patch) | |
tree | e6d793a7e246fbe66b794b75f0d1b40031a9e002 /t/t4052-stat-output.sh | |
parent | 31c2373d39558f98222a1fd8b83ed74ccaa87161 (diff) | |
download | git-af9fedc12873bf331019a502ed1fc944fa986713.tar.gz git-af9fedc12873bf331019a502ed1fc944fa986713.tar.xz |
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 <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4052-stat-output.sh')
-rwxr-xr-x | t/t4052-stat-output.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh index f766c4768..29c06e59a 100755 --- a/t/t4052-stat-output.sh +++ b/t/t4052-stat-output.sh @@ -83,6 +83,10 @@ cat >expect80 <<'EOF' abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EOF +cat >expect200 <<'EOF' + abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +EOF + while read verb expect cmd args do test_expect_success "$cmd $verb COLUMNS (big change)" ' @@ -92,7 +96,7 @@ do ' done <<\EOF ignores expect80 format-patch -1 --stdout -ignores expect80 diff HEAD^ HEAD --stat +respects expect200 diff HEAD^ HEAD --stat ignores expect80 show --stat ignores expect80 log -1 --stat EOF @@ -146,6 +150,9 @@ EOF cat >expect80 <<'EOF' ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++ EOF +cat >expect200 <<'EOF' + ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +EOF while read verb expect cmd args do test_expect_success "$cmd $verb COLUMNS (long filename)" ' @@ -155,7 +162,7 @@ do ' done <<\EOF ignores expect80 format-patch -1 --stdout -ignores expect80 diff HEAD^ HEAD --stat +respects expect200 diff HEAD^ HEAD --stat ignores expect80 show --stat ignores expect80 log -1 --stat EOF |