1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='git ls-files -k and -m flags test.
7
8This 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
15and 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
25git ls-files -k should report that existing filesystem
26objects except path4, path5 and path6/file6 to be killed.
27
28Also 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
35We should report path0, path1, path2/file2, path3/file3, path7 and path8
36modified without reporting path9 and path10.
37'
38. ./test-lib.sh
39
40test_expect_success 'git update-index --add to add various paths.' '
41 date >path0 &&
42 if test_have_prereq SYMLINKS
43 then
44 ln -s xyzzy path1
45 else
46 date > path1
47 fi &&
48 mkdir path2 path3 &&
49 date >path2/file2 &&
50 date >path3/file3 &&
51 : >path7 &&
52 date >path8 &&
53 : >path9 &&
54 date >path10 &&
55 git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10 &&
56 rm -fr path? # leave path10 alone
57'
58
59test_expect_success 'git ls-files -k to show killed files.' '
60 date >path2 &&
61 if test_have_prereq SYMLINKS
62 then
63 ln -s frotz path3 &&
64 ln -s nitfol path5
65 else
66 date >path3 &&
67 date >path5
68 fi &&
69 mkdir path0 path1 path6 &&
70 date >path0/file0 &&
71 date >path1/file1 &&
72 date >path6/file6 &&
73 date >path7 &&
74 : >path8 &&
75 : >path9 &&
76 touch path10 &&
77 git ls-files -k >.output
78'
79
80test_expect_success 'validate git ls-files -k output.' '
81 cat >.expected <<-\EOF &&
82 path0/file0
83 path1/file1
84 path2
85 path3
86 EOF
87 test_cmp .expected .output
88'
89
90test_expect_success 'git ls-files -m to show modified files.' '
91 git ls-files -m >.output
92'
93
94test_expect_success 'validate git ls-files -m output.' '
95 cat >.expected <<-\EOF &&
96 path0
97 path1
98 path2/file2
99 path3/file3
100 path7
101 path8
102 EOF
103 test_cmp .expected .output
104'
105
106test_done