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