]>
Commit | Line | Data |
---|---|---|
13ab4462 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Test built-in diff output engine. | |
7 | ||
9d484b92 JH |
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. | |
13ab4462 | 11 | ' |
16d4bd4f ÆAB |
12 | |
13 | TEST_PASSES_SANITIZE_LEAK=true | |
13ab4462 | 14 | . ./test-lib.sh |
ebd73f50 | 15 | . "$TEST_DIRECTORY"/lib-diff.sh |
13ab4462 JH |
16 | |
17 | echo >path0 'Line 1 | |
18 | Line 2 | |
19 | line 3' | |
20 | cat path0 >path1 | |
21 | chmod +x path1 | |
9d484b92 JH |
22 | mkdir path2 |
23 | >path2/path3 | |
13ab4462 | 24 | |
8ade9b14 | 25 | test_expect_success 'update-index --add two files with and without +x.' ' |
9d484b92 | 26 | git update-index --add path0 path1 path2/path3 |
8ade9b14 | 27 | ' |
13ab4462 JH |
28 | |
29 | mv path0 path0- | |
30 | sed -e 's/line/Line/' <path0- >path0 | |
31 | chmod +x path0 | |
32 | rm -f path1 | |
8ade9b14 MM |
33 | test_expect_success 'git diff-files -p after editing work tree.' ' |
34 | git diff-files -p >actual | |
35 | ' | |
e58b97af AR |
36 | |
37 | # that's as far as it comes | |
e0d10e1c | 38 | if [ "$(git config --get core.filemode)" = false ] |
e58b97af AR |
39 | then |
40 | say 'filemode disabled on the filesystem' | |
41 | test_done | |
42 | fi | |
43 | ||
13ab4462 | 44 | cat >expected <<\EOF |
b58f23b3 JH |
45 | diff --git a/path0 b/path0 |
46 | old mode 100644 | |
47 | new mode 100755 | |
13ab4462 JH |
48 | --- a/path0 |
49 | +++ b/path0 | |
50 | @@ -1,3 +1,3 @@ | |
51 | Line 1 | |
52 | Line 2 | |
53 | -line 3 | |
54 | +Line 3 | |
b58f23b3 JH |
55 | diff --git a/path1 b/path1 |
56 | deleted file mode 100755 | |
13ab4462 JH |
57 | --- a/path1 |
58 | +++ /dev/null | |
59 | @@ -1,3 +0,0 @@ | |
60 | -Line 1 | |
61 | -Line 2 | |
62 | -line 3 | |
63 | EOF | |
64 | ||
8ade9b14 MM |
65 | test_expect_success 'validate git diff-files -p output.' ' |
66 | compare_diff_patch expected actual | |
67 | ' | |
13ab4462 | 68 | |
d09cd15d MM |
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 | |
73 | ' | |
74 | ||
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 | |
79 | ' | |
80 | ||
71482d38 MM |
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 | |
84 | ' | |
85 | ||
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 && | |
8cc5ff83 | 88 | grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual && |
71482d38 MM |
89 | tail -n +4 actual >actual-patch && |
90 | compare_diff_patch expected actual-patch | |
91 | ' | |
92 | ||
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 | |
97 | ' | |
98 | ||
9d484b92 JH |
99 | |
100 | # Smudge path2/path3 so that dirstat has something to show | |
101 | date >path2/path3 | |
102 | ||
103 | for format in stat raw numstat shortstat summary \ | |
104 | dirstat cumulative dirstat-by-file \ | |
105 | patch-with-raw patch-with-stat compact-summary | |
106 | do | |
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 | |
111 | ' | |
112 | ||
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 | |
117 | ' | |
118 | ||
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 | |
123 | ' | |
124 | done | |
125 | ||
13ab4462 | 126 | test_done |