From 4dbdc42d9e7c3968ff7f690d00680419c9b8cb0f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Apr 2024 15:34:27 +0200 Subject: Adding upstream version 1:2.43.0. Signed-off-by: Daniel Baumann --- t/t4049-diff-stat-count.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 t/t4049-diff-stat-count.sh (limited to 't/t4049-diff-stat-count.sh') diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh new file mode 100755 index 0000000..0a4fc73 --- /dev/null +++ b/t/t4049-diff-stat-count.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright (c) 2011, Google Inc. + +test_description='diff --stat-count' + +TEST_PASSES_SANITIZE_LEAK=true +. ./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_cmp 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_cmp 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 || return 1 + 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_cmp expect actual +' + +test_done -- cgit v1.2.3