blob: 9c7adbdbe1cd7bf03e9b8f10a75f0acb4f37a5b2 [file] [log] [blame]
Nguyễn Thái Ngọc Duycbb31672010-10-22 01:48:14 -05001#!/bin/sh
2
3test_description='basic ls-files tests
4
5This test runs git ls-files with various unusual or malformed
6command-line arguments.
7'
8
9. ./test-lib.sh
10
11>empty
12
13test_expect_success 'ls-files in empty repository' '
14 git ls-files >actual &&
15 test_cmp empty actual
16'
17
18test_expect_success 'ls-files with nonexistent path' '
19 git ls-files doesnotexist >actual &&
20 test_cmp empty actual
21'
22
23test_expect_success 'ls-files with nonsense option' '
24 test_expect_code 129 git ls-files --nonsense 2>actual &&
Jiang Xin9a001382012-08-27 13:36:55 +080025 test_i18ngrep "[Uu]sage: git ls-files" actual
Nguyễn Thái Ngọc Duycbb31672010-10-22 01:48:14 -050026'
27
28test_expect_success 'ls-files -h in corrupt repository' '
29 mkdir broken &&
30 (
31 cd broken &&
32 git init &&
33 >.git/index &&
34 test_expect_code 129 git ls-files -h >usage 2>&1
35 ) &&
Jiang Xin9a001382012-08-27 13:36:55 +080036 test_i18ngrep "[Uu]sage: git ls-files " broken/usage
Nguyễn Thái Ngọc Duycbb31672010-10-22 01:48:14 -050037'
38
Martin Erik Werner655ee9e2014-02-04 15:25:20 +010039test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
Junio C Hamanof02033f2014-02-04 15:25:15 +010040 mkdir subs &&
41 ln -s nosuch link &&
42 ln -s ../nosuch subs/link &&
43 git add link subs/link &&
44 git ls-files -s link subs/link >expect &&
45 git ls-files -s "$(pwd)/link" "$(pwd)/subs/link" >actual &&
46 test_cmp expect actual &&
47
48 (
49 cd subs &&
50 git ls-files -s link >../expect &&
51 git ls-files -s "$(pwd)/link" >../actual
52 ) &&
53 test_cmp expect actual
54'
55
Nguyễn Thái Ngọc Duycbb31672010-10-22 01:48:14 -050056test_done