3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='Test built-in diff output engine.
8 We happen to know that all diff plumbing and diff Porcelain share the
9 same command line parser, so testing one should be sufficient; pick
10 diff-files as a representative.
13 TEST_PASSES_SANITIZE_LEAK
=true
15 .
"$TEST_DIRECTORY"/lib-diff.sh
25 test_expect_success
'update-index --add two files with and without +x.' '
26 git update-index --add path0 path1 path2/path3
30 sed -e 's/line/Line/' <path0-
>path0
33 test_expect_success
'git diff-files -p after editing work tree.' '
34 git diff-files -p >actual
37 # that's as far as it comes
38 if [ "$(git config --get core.filemode)" = false
]
40 say
'filemode disabled on the filesystem'
45 diff --git a
/path0 b
/path0
55 diff --git a
/path1 b
/path1
56 deleted
file mode
100755
65 test_expect_success
'validate git diff-files -p output.' '
66 compare_diff_patch expected actual
69 test_expect_success
'git diff-files -s after editing work tree' '
70 git diff-files -s >actual 2>err &&
71 test_must_be_empty actual &&
72 test_must_be_empty err
75 test_expect_success
'git diff-files --no-patch as synonym for -s' '
76 git diff-files --no-patch >actual 2>err &&
77 test_must_be_empty actual &&
78 test_must_be_empty err
81 test_expect_success
'git diff-files --no-patch --patch shows the patch' '
82 git diff-files --no-patch --patch >actual &&
83 compare_diff_patch expected actual
86 test_expect_success
'git diff-files --no-patch --patch-with-raw shows the patch and raw data' '
87 git diff-files --no-patch --patch-with-raw >actual &&
88 grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual &&
89 tail -n +4 actual >actual-patch &&
90 compare_diff_patch expected actual-patch
93 test_expect_success
'git diff-files --patch --no-patch does not show the patch' '
94 git diff-files --patch --no-patch >actual 2>err &&
95 test_must_be_empty actual &&
96 test_must_be_empty err
100 # Smudge path2/path3 so that dirstat has something to show
103 for format
in stat raw numstat shortstat summary \
104 dirstat cumulative dirstat-by-file \
105 patch-with-raw patch-with-stat compact-summary
107 test_expect_success
"--no-patch in 'git diff-files --no-patch --$format' is a no-op" '
108 git diff-files --no-patch "--$format" >actual &&
109 git diff-files "--$format" >expect &&
110 test_cmp expect actual
113 test_expect_success
"--no-patch clears all previous ones" '
114 git diff-files --$format -s -p >actual &&
115 git diff-files -p >expect &&
116 test_cmp expect actual
119 test_expect_success
"--no-patch in 'git diff --no-patch --$format' is a no-op" '
120 git diff --no-patch "--$format" >actual &&
121 git diff "--$format" >expect &&
122 test_cmp expect actual