1 #!/bin/sh
3 test_description='giving ignored paths to git add'
5 . ./test-lib.sh
7 test_expect_success setup '
8 mkdir sub dir dir/sub &&
9 echo sub >.gitignore &&
10 echo ign >>.gitignore &&
11 for p in . sub dir dir/sub
12 do
13 >"$p/ign" &&
14 >"$p/file" || exit 1
15 done
16 '
18 for i in file dir/file dir 'd*'
19 do
20 test_expect_success "no complaints for unignored $i" '
21 rm -f .git/index &&
22 git add "$i" &&
23 git ls-files "$i" >out &&
24 test -s out
25 '
26 done
28 for i in ign dir/ign dir/sub dir/sub/*ign sub/file sub sub/*
29 do
30 test_expect_success "complaints for ignored $i" '
31 rm -f .git/index &&
32 test_must_fail git add "$i" 2>err &&
33 git ls-files "$i" >out &&
34 ! test -s out
35 '
37 test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i output" '
38 grep -e "Use -f if" err
39 '
41 test_expect_success "complaints for ignored $i with unignored file" '
42 rm -f .git/index &&
43 test_must_fail git add "$i" file 2>err &&
44 git ls-files "$i" >out &&
45 ! test -s out
46 '
47 test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i with unignored file output" '
48 grep -e "Use -f if" err
49 '
50 done
52 for i in sub sub/*
53 do
54 test_expect_success "complaints for ignored $i in dir" '
55 rm -f .git/index &&
56 (
57 cd dir &&
58 test_must_fail git add "$i" 2>err &&
59 git ls-files "$i" >out &&
60 ! test -s out
61 )
62 '
64 test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in dir output" '
65 (
66 cd dir &&
67 grep -e "Use -f if" err
68 )
69 '
70 done
72 for i in ign file
73 do
74 test_expect_success "complaints for ignored $i in sub" '
75 rm -f .git/index &&
76 (
77 cd sub &&
78 test_must_fail git add "$i" 2>err &&
79 git ls-files "$i" >out &&
80 ! test -s out
81 )
82 '
84 test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in sub output" '
85 (
86 cd sub &&
87 grep -e "Use -f if" err
88 )
89 '
90 done
92 test_done