Raw
1 #!/bin/sh
2
3 test_description='basic ls-files tests
4
5 This test runs git ls-files with various unusual or malformed
6 command-line arguments.
7 '
8
9 . ./test-lib.sh
10
11 test_expect_success 'ls-files in empty repository' '
12 git ls-files >actual &&
13 test_must_be_empty actual
14 '
15
16 test_expect_success 'ls-files with nonexistent path' '
17 git ls-files doesnotexist >actual &&
18 test_must_be_empty actual
19 '
20
21 test_expect_success 'ls-files with nonsense option' '
22 test_expect_code 129 git ls-files --nonsense 2>actual &&
23 test_grep "[Uu]sage: git ls-files" actual
24 '
25
26 test_expect_success 'ls-files -h in corrupt repository' '
27 mkdir broken &&
28 (
29 cd broken &&
30 git init &&
31 >.git/index &&
32 git ls-files -h >usage 2>&1
33 ) &&
34 test_grep "[Uu]sage: git ls-files " broken/usage
35 '
36
37 test_expect_success 'ls-files does not crash with -h' '
38 git ls-files -h >usage &&
39 test_grep "[Uu]sage: git ls-files " usage &&
40 nongit git ls-files -h >usage &&
41 test_grep "[Uu]sage: git ls-files " usage
42 '
43
44 test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
45 mkdir subs &&
46 ln -s nosuch link &&
47 ln -s ../nosuch subs/link &&
48 git add link subs/link &&
49 git ls-files -s link subs/link >expect &&
50 git ls-files -s "$(pwd)/link" "$(pwd)/subs/link" >actual &&
51 test_cmp expect actual &&
52
53 (
54 cd subs &&
55 git ls-files -s link >../expect &&
56 git ls-files -s "$(pwd)/link" >../actual
57 ) &&
58 test_cmp expect actual
59 '
60
61 test_done