Junio C Hamano [off-list ref] writes:
Zbigniew Jędrzejewski-Szmek [off-list ref] writes:
quoted
Eleven tests for various combinations of a long filename and/or big
change count and ways to specify widths for diff --stat.
---
Sign-off?
...
The same comment as the previous one. Because you change the allocation
to the graph part in your patch to diff.c, which hasn't happened in [1/3]
yet, this should expect the existing behaviour (narrower graph) in this
step, and then be updated to expect the output shown above in the [2/3]
patch that changes the implementation in diff.c.
The previous review message in a patch form that can be squashed on top of
this patch.
-- >8 --
Subject: [PATCH] (squash to the previous -- replace the log message with this)
diff --stat: tests for long filenames and big change counts
In preparation for updates to the "diff --stat" that updates the logic
to split the allotted columns into the name part and the graph part to
make the output more readable, add a handful of tests to document the
corner case behaviour in which long filenames and big changes are shown.
When a pathname is so long that it cannot fit on the column, the current
code truncates it to make sure that the graph part has enough room to show
a meaningful graph. If the actual change is small (e.g. only one line
changed), this results in the final output that is shorter than the width
we aim for. A couple of new tests marked with test_expect_failure
demonstrate this bug.
---
t/t4014-format-patch.sh | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index f6ebb51..0376186 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -897,18 +897,18 @@ test_expect_success 'format patch ignores color.ui' '
# 120 character name
name=aaaaaaaaaa
name=$name$name$name$name$name$name$name$name$name$name$name$name
-test_expect_success 'preparation' "
- >\"$name\" &&
- git add \"$name\" &&
+test_expect_success 'preparation' '
+ >"$name" &&
+ git add "$name" &&
git commit -m message &&
- echo a >\"$name\" &&
- git commit -m message \"$name\"
-"
+ echo a >"$name" &&
+ git commit -m message "$name"
+'
cat >expect <<'EOF'
...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
EOF
-test_expect_success 'format patch graph width defaults to 80 columns' '
+test_expect_failure 'format patch graph width defaults to 80 columns' '
git format-patch --stat --stdout -1 >output &&
grep " | " output >actual &&
test_cmp expect actual
@@ -917,13 +917,13 @@ test_expect_success 'format patch graph width defaults to 80 columns' '
cat >expect <<'EOF'
...aaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
EOF
-test_expect_success 'format patch --stat=width with long name' '
+test_expect_failure 'format patch --stat=width with long name' '
git format-patch --stat=40 --stdout -1 >output &&
grep " | " output >actual &&
test_cmp expect actual
'
-test_expect_success 'format patch --stat-width=width works with long name' '
+test_expect_failure 'format patch --stat-width=width works with long name' '
git format-patch --stat-width=40 --stdout -1 >output &&
grep " | " output >actual &&
test_cmp expect actual
@@ -941,26 +941,21 @@ test_expect_success 'format patch --stat-name-width with long name' '
test_cmp expect actual
'
-test_expect_success 'preparation' '
+test_expect_success 'preparation for big change tests' '
>abcd &&
git add abcd &&
git commit -m message &&
i=0 &&
- while test $i -lt 1000; do
- echo $i &&
- i=$(($i + 1))
+ while test $i -lt 1000
+ do
+ echo $i && i=$(($i + 1))
done >abcd &&
git commit -m message abcd
'
cat >expect <<'EOF'
- abcd | 1000 ++++++++++++++++++++++++++++++++++++++++
+ abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
-test_expect_success 'format patch graph part width is 40 columns' '
- git format-patch --stat --stdout -1 >output &&
- grep " | " output >actual &&
- test_cmp expect actual
-'
test_expect_success 'format patch ignores COLUMNS' '
COLUMNS=200 git format-patch --stat --stdout -1 >output
@@ -984,7 +979,7 @@ test_expect_success 'format patch --stat-width=width with big change' '
'
cat >expect <<'EOF'
- ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
+ ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++
EOF
test_expect_success 'format patch --stat=width with big change and long name' '
cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
--
1.7.9.1.237.g00b59