]>
Commit | Line | Data |
---|---|---|
60ace879 CW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Carl D. Worth | |
4 | # | |
5 | ||
6 | test_description='Test of git-add, including the -- option.' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
10 | test_expect_success \ | |
11 | 'Test of git-add' \ | |
12 | 'touch foo && git-add foo' | |
13 | ||
14 | test_expect_success \ | |
15 | 'Post-check that foo is in the index' \ | |
16 | 'git-ls-files foo | grep foo' | |
17 | ||
18 | test_expect_success \ | |
19 | 'Test that "git-add -- -q" works' \ | |
20 | 'touch -- -q && git-add -- -q' | |
21 | ||
fd28b34a SP |
22 | test_expect_success \ |
23 | 'git-add: Test that executable bit is not used if core.filemode=0' \ | |
e0d10e1c | 24 | 'git config core.filemode 0 && |
fd28b34a SP |
25 | echo foo >xfoo1 && |
26 | chmod 755 xfoo1 && | |
27 | git-add xfoo1 && | |
28 | case "`git-ls-files --stage xfoo1`" in | |
29 | 100644" "*xfoo1) echo ok;; | |
2bbaaed9 | 30 | *) echo fail; git-ls-files --stage xfoo1; (exit 1);; |
fd28b34a SP |
31 | esac' |
32 | ||
185c975f JH |
33 | test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' |
34 | rm -f xfoo1 && | |
35 | ln -s foo xfoo1 && | |
36 | git-add xfoo1 && | |
37 | case "`git-ls-files --stage xfoo1`" in | |
38 | 120000" "*xfoo1) echo ok;; | |
39 | *) echo fail; git-ls-files --stage xfoo1; (exit 1);; | |
40 | esac | |
41 | ' | |
42 | ||
fd28b34a SP |
43 | test_expect_success \ |
44 | 'git-update-index --add: Test that executable bit is not used...' \ | |
e0d10e1c | 45 | 'git config core.filemode 0 && |
fd28b34a SP |
46 | echo foo >xfoo2 && |
47 | chmod 755 xfoo2 && | |
209e7569 | 48 | git-update-index --add xfoo2 && |
fd28b34a SP |
49 | case "`git-ls-files --stage xfoo2`" in |
50 | 100644" "*xfoo2) echo ok;; | |
2bbaaed9 JH |
51 | *) echo fail; git-ls-files --stage xfoo2; (exit 1);; |
52 | esac' | |
53 | ||
185c975f JH |
54 | test_expect_success 'git-add: filemode=0 should not get confused by symlink' ' |
55 | rm -f xfoo2 && | |
56 | ln -s foo xfoo2 && | |
57 | git update-index --add xfoo2 && | |
58 | case "`git-ls-files --stage xfoo2`" in | |
59 | 120000" "*xfoo2) echo ok;; | |
60 | *) echo fail; git-ls-files --stage xfoo2; (exit 1);; | |
61 | esac | |
62 | ' | |
63 | ||
2bbaaed9 JH |
64 | test_expect_success \ |
65 | 'git-update-index --add: Test that executable bit is not used...' \ | |
e0d10e1c | 66 | 'git config core.filemode 0 && |
2bbaaed9 JH |
67 | ln -s xfoo2 xfoo3 && |
68 | git-update-index --add xfoo3 && | |
69 | case "`git-ls-files --stage xfoo3`" in | |
70 | 120000" "*xfoo3) echo ok;; | |
71 | *) echo fail; git-ls-files --stage xfoo3; (exit 1);; | |
fd28b34a SP |
72 | esac' |
73 | ||
4d06f8ac JH |
74 | test_expect_success '.gitignore test setup' ' |
75 | echo "*.ig" >.gitignore && | |
76 | mkdir c.if d.ig && | |
77 | >a.ig && >b.if && | |
78 | >c.if/c.if && >c.if/c.ig && | |
79 | >d.ig/d.if && >d.ig/d.ig | |
80 | ' | |
81 | ||
82 | test_expect_success '.gitignore is honored' ' | |
83 | git-add . && | |
84 | ! git-ls-files | grep "\\.ig" | |
85 | ' | |
86 | ||
87 | test_expect_success 'error out when attempting to add ignored ones without -f' ' | |
88 | ! git-add a.?? && | |
89 | ! git-ls-files | grep "\\.ig" | |
90 | ' | |
91 | ||
92 | test_expect_success 'error out when attempting to add ignored ones without -f' ' | |
93 | ! git-add d.?? && | |
94 | ! git-ls-files | grep "\\.ig" | |
95 | ' | |
96 | ||
97 | test_expect_success 'add ignored ones with -f' ' | |
98 | git-add -f a.?? && | |
99 | git-ls-files --error-unmatch a.ig | |
100 | ' | |
101 | ||
102 | test_expect_success 'add ignored ones with -f' ' | |
103 | git-add -f d.??/* && | |
104 | git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig | |
105 | ' | |
106 | ||
60ace879 | 107 | test_done |