]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3000-ls-files-others.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t3000-ls-files-others.sh
CommitLineData
368f99d5
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
d8083e41 6test_description='basic tests for ls-files --others
368f99d5 7
5be60078 8This test runs git ls-files --others with the following on the
368f99d5
JH
9filesystem.
10
11 path0 - a file
12 path1 - a symlink
13 path2/file2 - a file in a directory
78c2cff6
JH
14 path3-junk - a file to confuse things
15 path3/file3 - a file in a directory
2fb6d6d6 16 path4 - an empty directory
368f99d5
JH
17'
18. ./test-lib.sh
19
bcefed41
JN
20test_expect_success 'setup ' '
21 date >path0 &&
22 if test_have_prereq SYMLINKS
23 then
24 ln -s xyzzy path1
25 else
26 date >path1
27 fi &&
28 mkdir path2 path3 path4 &&
29 date >path2/file2 &&
30 date >path2-junk &&
31 date >path3/file3 &&
32 date >path3-junk &&
33 git update-index --add path3-junk path3/file3
34'
78c2cff6 35
bcefed41
JN
36test_expect_success 'setup: expected output' '
37 cat >expected1 <<-\EOF &&
38 expected1
39 expected2
40 expected3
41 output
42 path0
43 path1
44 path2-junk
45 path2/file2
46 EOF
78c2cff6 47
bcefed41
JN
48 sed -e "s|path2/file2|path2/|" <expected1 >expected2 &&
49 cp expected2 expected3 &&
50 echo path4/ >>expected2
51'
78c2cff6 52
bcefed41
JN
53test_expect_success 'ls-files --others' '
54 git ls-files --others >output &&
55 test_cmp expected1 output
56'
78c2cff6 57
bcefed41
JN
58test_expect_success 'ls-files --others --directory' '
59 git ls-files --others --directory >output &&
60 test_cmp expected2 output
61'
2fb6d6d6 62
bcefed41
JN
63test_expect_success '--no-empty-directory hides empty directory' '
64 git ls-files --others --directory --no-empty-directory >output &&
65 test_cmp expected3 output
66'
2fb6d6d6 67
a2d5156c
JK
68test_expect_success 'ls-files --others handles non-submodule .git' '
69 mkdir not-a-submodule &&
70 echo foo >not-a-submodule/.git &&
71 git ls-files -o >output &&
72 test_cmp expected1 output
73'
74
e5fa45c1
JH
75test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
76 git init super &&
77 git init sub &&
78 (
79 cd sub &&
80 >a &&
81 git add a &&
82 git commit -m sub &&
83 git pack-refs --all
84 ) &&
85 (
86 cd super &&
3ea67379 87 "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" ../sub sub &&
e5fa45c1
JH
88 git ls-files --others --exclude-standard >../actual
89 ) &&
90 echo sub/ >expect &&
91 test_cmp expect actual
92'
93
368f99d5 94test_done