]> git.ipfire.org Git - thirdparty/git.git/blob - t/t2204-add-ignored.sh
Merge branch 'ab/receive-pack-use-after-free-fix'
[thirdparty/git.git] / t / t2204-add-ignored.sh
1 #!/bin/sh
2
3 test_description='giving ignored paths to git add'
4
5 . ./test-lib.sh
6
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 '
17
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
27
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_must_be_empty out
35 '
36
37 test_expect_success "complaints for ignored $i output" '
38 test_i18ngrep -e "Use -f if" err
39 '
40
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_must_be_empty out
46 '
47 test_expect_success "complaints for ignored $i with unignored file output" '
48 test_i18ngrep -e "Use -f if" err
49 '
50 done
51
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_must_be_empty out
61 )
62 '
63
64 test_expect_success "complaints for ignored $i in dir output" '
65 (
66 cd dir &&
67 test_i18ngrep -e "Use -f if" err
68 )
69 '
70 done
71
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_must_be_empty out
81 )
82 '
83
84 test_expect_success "complaints for ignored $i in sub output" '
85 (
86 cd sub &&
87 test_i18ngrep -e "Use -f if" err
88 )
89 '
90 done
91
92 test_done