about summary refs log tree commit diff
path: root/t/t4049-diff-stat-count.sh
diff options
context:
space:
mode:
authorVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
committerVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
commit1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (patch)
treee3accb9beed5c4c1b5a05c99db71ab2841f0ed04 /t/t4049-diff-stat-count.sh
Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git
git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
Diffstat (limited to 't/t4049-diff-stat-count.sh')
-rwxr-xr-xt/t4049-diff-stat-count.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh
new file mode 100755
index 000000000000..a34121740a4a
--- /dev/null
+++ b/t/t4049-diff-stat-count.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Copyright (c) 2011, Google Inc.
+
+test_description='diff --stat-count'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	>a &&
+	>b &&
+	>c &&
+	>d &&
+	git add a b 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 +
+	 ...
+	 3 files changed, 3 insertions(+)
+	EOF
+	git diff --stat --stat-count=2 >actual &&
+	test_i18ncmp expect actual
+'
+
+test_done