#!/bin/sh # Copyright (c) 2011, Google Inc. global test_description := ''diff --stat-count'' source ./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 (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"diff --stat-count">)} spids: [7] ) ] spids: [7] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\t>a &&\n"> <"\t>b &&\n"> <"\t>c &&\n"> <"\t>d &&\n"> <"\tgit add a b c d &&\n"> <"\tgit commit -m initial\n"> ) } ) (C {(test_expect_success)} {(SQ <"mode-only change show as a 0-line change">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\ttest_chmod +x b d &&\n"> <"\techo a >a &&\n"> <"\techo c >c &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t a | 1 +\n"> <"\t b | 0\n"> <"\t ...\n"> <"\t 4 files changed, 2 insertions(+)\n"> <"\tEOF\n"> <"\tgit diff --stat --stat-count=2 HEAD >actual &&\n"> <"\ttest_i18ncmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"binary changes do not count in lines">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\techo a >a &&\n"> <"\techo c >c &&\n"> <"\tcat \"$TEST_DIRECTORY\"/test-binary-1.png >d &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t a | 1 +\n"> <"\t c | 1 +\n"> <"\t ...\n"> <"\t 3 files changed, 2 insertions(+)\n"> <"\tEOF\n"> <"\tgit diff --stat --stat-count=2 >actual &&\n"> <"\ttest_i18ncmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"exclude unmerged entries from total file count">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\techo a >a &&\n"> <"\techo b >b &&\n"> <"\tgit ls-files -s a >x &&\n"> <"\tgit rm -f d &&\n"> <"\tfor stage in 1 2 3\n"> <"\tdo\n"> <"\t\tsed -e \"s/ 0\ta/ $stage\td/\" x\n"> <"\tdone |\n"> <"\tgit update-index --index-info &&\n"> <"\techo d >d &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t a | 1 +\n"> <"\t b | 1 +\n"> <"\t ...\n"> <"\t 3 files changed, 3 insertions(+)\n"> <"\tEOF\n"> <"\tgit diff --stat --stat-count=2 >actual &&\n"> <"\ttest_i18ncmp expect actual\n"> ) } ) (C {(test_done)}) ] )