3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='git ls-files -k and -m flags test.
8 This test prepares the following in the cache:
12 path2/file2 - a file in a directory
13 path3/file3 - a file in a directory
14 pathx/ju - a file in a directory
15 submod1/ - a submodule
16 submod2/ - another submodule
18 and the following on the filesystem:
20 path0/file0 - a file in a directory
21 path1/file1 - a file in a directory
26 path6/file6 - a file in a directory
27 pathx/ju/nk - a file in a directory to be killed
28 submod1/ - a submodule (modified from the cache)
29 submod2/ - a submodule (matches the cache)
31 git ls-files -k should report that existing filesystem objects
32 path0/*, path1/*, path2 and path3 to be killed.
34 Also for modification test, the cache and working tree have:
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.
41 We should report path0, path1, path2/file2, path3/file3, path7 and path8
42 modified without reporting path9 and path10. submod1 is also modified.
45 TEST_PASSES_SANITIZE_LEAK
=true
48 test_expect_success
'git update-index --add to add various paths.' '
50 test_ln_s_add xyzzy path1 &&
51 mkdir path2 path3 pathx &&
59 git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 &&
61 git -C submod1 commit --allow-empty -m "empty 1" &&
63 git -C submod2 commit --allow-empty -m "empty 2" &&
64 git update-index --add submod[12] &&
67 git commit --allow-empty -m "empty 1 (updated)"
69 rm -fr path? # leave path10 alone
72 test_expect_success
'git ls-files -k to show killed files.' '
74 if test_have_prereq SYMLINKS
82 mkdir -p path0 path1 path6 pathx/ju &&
91 cat >.expected <<-\EOF
100 test_expect_success
'git ls-files -k output (w/o icase)' '
101 git ls-files -k >.output &&
102 test_cmp .expected .output
105 test_expect_success
'git ls-files -k output (w/ icase)' '
106 git -c core.ignorecase=true ls-files -k >.output &&
107 test_cmp .expected .output
110 test_expect_success
'git ls-files -m to show modified files.' '
111 git ls-files -m >.output
114 test_expect_success
'validate git ls-files -m output.' '
115 cat >.expected <<-\EOF &&
125 test_cmp .expected .output