]>
Commit | Line | Data |
---|---|---|
368f99d5 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git ls-files -k and -m flags test. |
368f99d5 JH |
7 | |
8 | This test prepares the following in the cache: | |
9 | ||
10 | path0 - a file | |
11 | path1 - a symlink | |
12 | path2/file2 - a file in a directory | |
13 | path3/file3 - a file in a directory | |
3c568751 | 14 | pathx/ju - a file in a directory |
26c986e1 JH |
15 | submod1/ - a submodule |
16 | submod2/ - another submodule | |
368f99d5 JH |
17 | |
18 | and the following on the filesystem: | |
19 | ||
20 | path0/file0 - a file in a directory | |
21 | path1/file1 - a file in a directory | |
22 | path2 - a file | |
23 | path3 - a symlink | |
24 | path4 - a file | |
25 | path5 - a symlink | |
26 | path6/file6 - a file in a directory | |
3c568751 | 27 | pathx/ju/nk - a file in a directory to be killed |
26c986e1 JH |
28 | submod1/ - a submodule (modified from the cache) |
29 | submod2/ - a submodule (matches the cache) | |
368f99d5 | 30 | |
26c986e1 JH |
31 | git ls-files -k should report that existing filesystem objects |
32 | path0/*, path1/*, path2 and path3 to be killed. | |
b0391890 JH |
33 | |
34 | Also for modification test, the cache and working tree have: | |
35 | ||
36 | path7 - an empty file, modified to a non-empty file. | |
37 | path8 - a non-empty file, modified to an empty file. | |
38 | path9 - an empty file, cache dirtied. | |
39 | path10 - a non-empty file, cache dirtied. | |
40 | ||
41 | We should report path0, path1, path2/file2, path3/file3, path7 and path8 | |
26c986e1 | 42 | modified without reporting path9 and path10. submod1 is also modified. |
368f99d5 JH |
43 | ' |
44 | . ./test-lib.sh | |
45 | ||
cb648689 JS |
46 | test_expect_success 'git update-index --add to add various paths.' ' |
47 | date >path0 && | |
889c6f0e | 48 | test_ln_s_add xyzzy path1 && |
4c4d9d9b | 49 | mkdir path2 path3 pathx && |
cb648689 JS |
50 | date >path2/file2 && |
51 | date >path3/file3 && | |
4c4d9d9b | 52 | >pathx/ju && |
cb648689 JS |
53 | : >path7 && |
54 | date >path8 && | |
55 | : >path9 && | |
56 | date >path10 && | |
4c4d9d9b | 57 | git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && |
e6821d09 JK |
58 | git init submod1 && |
59 | git -C submod1 commit --allow-empty -m "empty 1" && | |
60 | git init submod2 && | |
61 | git -C submod2 commit --allow-empty -m "empty 2" && | |
99094a7a | 62 | git update-index --add submod[12] && |
26c986e1 JH |
63 | ( |
64 | cd submod1 && | |
65 | git commit --allow-empty -m "empty 1 (updated)" | |
66 | ) && | |
cb648689 JS |
67 | rm -fr path? # leave path10 alone |
68 | ' | |
368f99d5 | 69 | |
cb648689 JS |
70 | test_expect_success 'git ls-files -k to show killed files.' ' |
71 | date >path2 && | |
72 | if test_have_prereq SYMLINKS | |
73 | then | |
74 | ln -s frotz path3 && | |
75 | ln -s nitfol path5 | |
76 | else | |
77 | date >path3 && | |
78 | date >path5 | |
79 | fi && | |
4c4d9d9b | 80 | mkdir -p path0 path1 path6 pathx/ju && |
cb648689 JS |
81 | date >path0/file0 && |
82 | date >path1/file1 && | |
83 | date >path6/file6 && | |
84 | date >path7 && | |
85 | : >path8 && | |
86 | : >path9 && | |
87 | touch path10 && | |
4c4d9d9b JH |
88 | >pathx/ju/nk && |
89 | cat >.expected <<-\EOF | |
cb648689 JS |
90 | path0/file0 |
91 | path1/file1 | |
92 | path2 | |
93 | path3 | |
4c4d9d9b | 94 | pathx/ju/nk |
cb648689 | 95 | EOF |
680be044 | 96 | ' |
b0391890 | 97 | |
4c4d9d9b | 98 | test_expect_success 'git ls-files -k output (w/o icase)' ' |
60687de5 | 99 | git ls-files -k >.output && |
4c4d9d9b JH |
100 | test_cmp .expected .output |
101 | ' | |
102 | ||
103 | test_expect_success 'git ls-files -k output (w/ icase)' ' | |
60687de5 | 104 | git -c core.ignorecase=true ls-files -k >.output && |
cb648689 JS |
105 | test_cmp .expected .output |
106 | ' | |
b0391890 | 107 | |
cb648689 JS |
108 | test_expect_success 'git ls-files -m to show modified files.' ' |
109 | git ls-files -m >.output | |
110 | ' | |
b0391890 | 111 | |
cb648689 JS |
112 | test_expect_success 'validate git ls-files -m output.' ' |
113 | cat >.expected <<-\EOF && | |
114 | path0 | |
115 | path1 | |
116 | path2/file2 | |
117 | path3/file3 | |
118 | path7 | |
119 | path8 | |
4c4d9d9b | 120 | pathx/ju |
26c986e1 | 121 | submod1 |
cb648689 JS |
122 | EOF |
123 | test_cmp .expected .output | |
124 | ' | |
b0391890 | 125 | |
368f99d5 | 126 | test_done |