t / t4049-diff-stat-count.shon commit git-p4: avoid "stat" command in t9815 git-p4-submit-fail (3a692b3)
   1#!/bin/sh
   2# Copyright (c) 2011, Google Inc.
   3
   4test_description='diff --stat-count'
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        >a &&
   9        >b &&
  10        >c &&
  11        >d &&
  12        git add a b c d &&
  13        git commit -m initial
  14'
  15
  16test_expect_success 'mode-only change show as a 0-line change' '
  17        git reset --hard &&
  18        test_chmod +x b d &&
  19        echo a >a &&
  20        echo c >c &&
  21        cat >expect <<-\EOF &&
  22         a | 1 +
  23         b | 0
  24         ...
  25         4 files changed, 2 insertions(+)
  26        EOF
  27        git diff --stat --stat-count=2 HEAD >actual &&
  28        test_i18ncmp expect actual
  29'
  30
  31test_expect_success 'binary changes do not count in lines' '
  32        git reset --hard &&
  33        echo a >a &&
  34        echo c >c &&
  35        cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
  36        cat >expect <<-\EOF &&
  37         a | 1 +
  38         c | 1 +
  39         ...
  40         3 files changed, 2 insertions(+)
  41        EOF
  42        git diff --stat --stat-count=2 >actual &&
  43        test_i18ncmp expect actual
  44'
  45
  46test_expect_success 'exclude unmerged entries from total file count' '
  47        git reset --hard &&
  48        echo a >a &&
  49        echo b >b &&
  50        git ls-files -s a >x &&
  51        git rm -f d &&
  52        for stage in 1 2 3
  53        do
  54                sed -e "s/ 0    a/ $stage       d/" x
  55        done |
  56        git update-index --index-info &&
  57        echo d >d &&
  58        cat >expect <<-\EOF &&
  59         a | 1 +
  60         b | 1 +
  61         ...
  62         3 files changed, 3 insertions(+)
  63        EOF
  64        git diff --stat --stat-count=2 >actual &&
  65        test_i18ncmp expect actual
  66'
  67
  68test_done