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 grep -e "Use -f if" err &&
36 cat err
37 '
39 test_expect_success "complaints for ignored $i with unignored file" '
40 rm -f .git/index &&
41 test_must_fail git add "$i" file 2>err &&
42 git ls-files "$i" >out &&
43 ! test -s out &&
44 grep -e "Use -f if" err &&
45 cat err
46 '
47 done
49 for i in sub sub/*
50 do
51 test_expect_success "complaints for ignored $i in dir" '
52 rm -f .git/index &&
53 (
54 cd dir &&
55 test_must_fail git add "$i" 2>err &&
56 git ls-files "$i" >out &&
57 ! test -s out &&
58 grep -e "Use -f if" err &&
59 cat err
60 )
61 '
62 done
64 for i in ign file
65 do
66 test_expect_success "complaints for ignored $i in sub" '
67 rm -f .git/index &&
68 (
69 cd sub &&
70 test_must_fail git add "$i" 2>err &&
71 git ls-files "$i" >out &&
72 ! test -s out &&
73 grep -e "Use -f if" err &&
74 cat err
75 )
76 '
77 done
79 test_done