]>
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 | ||
8 | ' | |
16d4bd4f ÆAB |
9 | |
10 | TEST_PASSES_SANITIZE_LEAK=true | |
13ab4462 | 11 | . ./test-lib.sh |
ebd73f50 | 12 | . "$TEST_DIRECTORY"/lib-diff.sh |
13ab4462 JH |
13 | |
14 | echo >path0 'Line 1 | |
15 | Line 2 | |
16 | line 3' | |
17 | cat path0 >path1 | |
18 | chmod +x path1 | |
19 | ||
8ade9b14 MM |
20 | test_expect_success 'update-index --add two files with and without +x.' ' |
21 | git update-index --add path0 path1 | |
22 | ' | |
13ab4462 JH |
23 | |
24 | mv path0 path0- | |
25 | sed -e 's/line/Line/' <path0- >path0 | |
26 | chmod +x path0 | |
27 | rm -f path1 | |
8ade9b14 MM |
28 | test_expect_success 'git diff-files -p after editing work tree.' ' |
29 | git diff-files -p >actual | |
30 | ' | |
e58b97af AR |
31 | |
32 | # that's as far as it comes | |
e0d10e1c | 33 | if [ "$(git config --get core.filemode)" = false ] |
e58b97af AR |
34 | then |
35 | say 'filemode disabled on the filesystem' | |
36 | test_done | |
37 | fi | |
38 | ||
13ab4462 | 39 | cat >expected <<\EOF |
b58f23b3 JH |
40 | diff --git a/path0 b/path0 |
41 | old mode 100644 | |
42 | new mode 100755 | |
13ab4462 JH |
43 | --- a/path0 |
44 | +++ b/path0 | |
45 | @@ -1,3 +1,3 @@ | |
46 | Line 1 | |
47 | Line 2 | |
48 | -line 3 | |
49 | +Line 3 | |
b58f23b3 JH |
50 | diff --git a/path1 b/path1 |
51 | deleted file mode 100755 | |
13ab4462 JH |
52 | --- a/path1 |
53 | +++ /dev/null | |
54 | @@ -1,3 +0,0 @@ | |
55 | -Line 1 | |
56 | -Line 2 | |
57 | -line 3 | |
58 | EOF | |
59 | ||
8ade9b14 MM |
60 | test_expect_success 'validate git diff-files -p output.' ' |
61 | compare_diff_patch expected actual | |
62 | ' | |
13ab4462 | 63 | |
d09cd15d MM |
64 | test_expect_success 'git diff-files -s after editing work tree' ' |
65 | git diff-files -s >actual 2>err && | |
66 | test_must_be_empty actual && | |
67 | test_must_be_empty err | |
68 | ' | |
69 | ||
70 | test_expect_success 'git diff-files --no-patch as synonym for -s' ' | |
71 | git diff-files --no-patch >actual 2>err && | |
72 | test_must_be_empty actual && | |
73 | test_must_be_empty err | |
74 | ' | |
75 | ||
71482d38 MM |
76 | test_expect_success 'git diff-files --no-patch --patch shows the patch' ' |
77 | git diff-files --no-patch --patch >actual && | |
78 | compare_diff_patch expected actual | |
79 | ' | |
80 | ||
81 | test_expect_success 'git diff-files --no-patch --patch-with-raw shows the patch and raw data' ' | |
82 | git diff-files --no-patch --patch-with-raw >actual && | |
8cc5ff83 | 83 | grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual && |
71482d38 MM |
84 | tail -n +4 actual >actual-patch && |
85 | compare_diff_patch expected actual-patch | |
86 | ' | |
87 | ||
88 | test_expect_success 'git diff-files --patch --no-patch does not show the patch' ' | |
89 | git diff-files --patch --no-patch >actual 2>err && | |
90 | test_must_be_empty actual && | |
91 | test_must_be_empty err | |
92 | ' | |
93 | ||
13ab4462 | 94 | test_done |