summaryrefslogtreecommitdiff
path: root/t/t4049-diff-stat-count.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-11-29 12:53:54 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-11-29 12:53:54 -0800
commita4eab8f38ec174abe5eeab8649953460d80d634c (patch)
tree1f2d2f50ceee4b45c5732841cc65d0bef95724aa /t/t4049-diff-stat-count.sh
parentMerge branch 'fc/remote-hg' (diff)
parentt4049: refocus tests (diff)
downloadtgif-a4eab8f38ec174abe5eeab8649953460d80d634c.tar.xz
Merge branch 'lt/diff-stat-show-0-lines'
"git diff --stat" miscounted the total number of changed lines when binary files were involved and hidden beyond --stat-count. It also miscounted the total number of changed files when there were unmerged paths. * lt/diff-stat-show-0-lines: t4049: refocus tests diff --shortstat: do not count "unmerged" entries diff --stat: do not count "unmerged" entries diff --stat: move the "total count" logic to the last loop diff --stat: use "file" temporary variable to refer to data->files[i] diff --stat: status of unmodified pair in diff-q is not zero test: add failing tests for "diff --stat" to t4049
Diffstat (limited to 't/t4049-diff-stat-count.sh')
-rwxr-xr-xt/t4049-diff-stat-count.sh48
1 files changed, 45 insertions, 3 deletions
diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh
index 7b3ef00533..5b594e878f 100755
--- a/t/t4049-diff-stat-count.sh
+++ b/t/t4049-diff-stat-count.sh
@@ -4,20 +4,62 @@
test_description='diff --stat-count'
. ./test-lib.sh
-test_expect_success setup '
+test_expect_success 'setup' '
>a &&
>b &&
>c &&
>d &&
git add a b c d &&
- chmod +x c d &&
+ git commit -m initial
+'
+
+test_expect_success 'mode-only change show as a 0-line change' '
+ git reset --hard &&
+ test_chmod +x b d &&
+ echo a >a &&
+ echo c >c &&
+ cat >expect <<-\EOF
+ a | 1 +
+ b | 0
+ ...
+ 4 files changed, 2 insertions(+)
+ EOF
+ git diff --stat --stat-count=2 HEAD >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'binary changes do not count in lines' '
+ git reset --hard &&
+ echo a >a &&
+ echo c >c &&
+ cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
+ cat >expect <<-\EOF
+ a | 1 +
+ c | 1 +
+ ...
+ 3 files changed, 2 insertions(+)
+ EOF
+ git diff --stat --stat-count=2 >actual &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'exclude unmerged entries from total file count' '
+ git reset --hard &&
echo a >a &&
echo b >b &&
+ git ls-files -s a >x &&
+ git rm -f d &&
+ for stage in 1 2 3
+ do
+ sed -e "s/ 0 a/ $stage d/" x
+ done |
+ git update-index --index-info &&
+ echo d >d &&
cat >expect <<-\EOF
a | 1 +
b | 1 +
...
- 4 files changed, 2 insertions(+)
+ 3 files changed, 3 insertions(+)
EOF
git diff --stat --stat-count=2 >actual &&
test_i18ncmp expect actual