]>
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 | |
14 | ||
15 | and the following on the filesystem: | |
16 | ||
17 | path0/file0 - a file in a directory | |
18 | path1/file1 - a file in a directory | |
19 | path2 - a file | |
20 | path3 - a symlink | |
21 | path4 - a file | |
22 | path5 - a symlink | |
23 | path6/file6 - a file in a directory | |
24 | ||
5be60078 | 25 | git ls-files -k should report that existing filesystem |
368f99d5 | 26 | objects except path4, path5 and path6/file6 to be killed. |
b0391890 JH |
27 | |
28 | Also for modification test, the cache and working tree have: | |
29 | ||
30 | path7 - an empty file, modified to a non-empty file. | |
31 | path8 - a non-empty file, modified to an empty file. | |
32 | path9 - an empty file, cache dirtied. | |
33 | path10 - a non-empty file, cache dirtied. | |
34 | ||
35 | We should report path0, path1, path2/file2, path3/file3, path7 and path8 | |
36 | modified without reporting path9 and path10. | |
368f99d5 JH |
37 | ' |
38 | . ./test-lib.sh | |
39 | ||
40 | date >path0 | |
704a3143 JS |
41 | if test_have_prereq SYMLINKS |
42 | then | |
43 | ln -s xyzzy path1 | |
44 | else | |
45 | date > path1 | |
46 | fi | |
368f99d5 JH |
47 | mkdir path2 path3 |
48 | date >path2/file2 | |
49 | date >path3/file3 | |
b0391890 JH |
50 | : >path7 |
51 | date >path8 | |
52 | : >path9 | |
53 | date >path10 | |
368f99d5 | 54 | test_expect_success \ |
5be60078 JH |
55 | 'git update-index --add to add various paths.' \ |
56 | "git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10" | |
368f99d5 | 57 | |
b0391890 | 58 | rm -fr path? ;# leave path10 alone |
368f99d5 | 59 | date >path2 |
704a3143 JS |
60 | if test_have_prereq SYMLINKS |
61 | then | |
62 | ln -s frotz path3 | |
63 | ln -s nitfol path5 | |
64 | else | |
65 | date > path3 | |
66 | date > path5 | |
67 | fi | |
368f99d5 JH |
68 | mkdir path0 path1 path6 |
69 | date >path0/file0 | |
70 | date >path1/file1 | |
71 | date >path6/file6 | |
b0391890 JH |
72 | date >path7 |
73 | : >path8 | |
74 | : >path9 | |
75 | touch path10 | |
368f99d5 JH |
76 | |
77 | test_expect_success \ | |
5be60078 JH |
78 | 'git ls-files -k to show killed files.' \ |
79 | 'git ls-files -k >.output' | |
368f99d5 JH |
80 | cat >.expected <<EOF |
81 | path0/file0 | |
82 | path1/file1 | |
83 | path2 | |
84 | path3 | |
85 | EOF | |
86 | ||
87 | test_expect_success \ | |
5be60078 | 88 | 'validate git ls-files -k output.' \ |
188c3827 | 89 | 'test_cmp .expected .output' |
b0391890 JH |
90 | |
91 | test_expect_success \ | |
5be60078 JH |
92 | 'git ls-files -m to show modified files.' \ |
93 | 'git ls-files -m >.output' | |
b0391890 JH |
94 | cat >.expected <<EOF |
95 | path0 | |
96 | path1 | |
97 | path2/file2 | |
98 | path3/file3 | |
99 | path7 | |
100 | path8 | |
101 | EOF | |
102 | ||
103 | test_expect_success \ | |
5be60078 | 104 | 'validate git ls-files -m output.' \ |
188c3827 | 105 | 'test_cmp .expected .output' |
b0391890 | 106 | |
368f99d5 | 107 | test_done |