3 # Copyright (c) 2006 Carl D. Worth
6 test_description
='Test of git-add, including the -- option.'
12 'touch foo && git-add foo'
15 'Post-check that foo is in the index' \
16 'git-ls-files foo | grep foo'
19 'Test that "git-add -- -q" works' \
20 'touch -- -q && git-add -- -q'
23 'git-add: Test that executable bit is not used if core.filemode=0' \
24 'git config core.filemode 0 &&
28 case "`git-ls-files --stage xfoo1`" in
29 100644" "*xfoo1) echo ok;;
30 *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
33 test_expect_success
'git-add: filemode=0 should not get confused by symlink' '
37 case "`git-ls-files --stage xfoo1`" in
38 120000" "*xfoo1) echo ok;;
39 *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
44 'git-update-index --add: Test that executable bit is not used...' \
45 'git config core.filemode 0 &&
48 git-update-index --add xfoo2 &&
49 case "`git-ls-files --stage xfoo2`" in
50 100644" "*xfoo2) echo ok;;
51 *) echo fail; git-ls-files --stage xfoo2; (exit 1);;
54 test_expect_success
'git-add: filemode=0 should not get confused by symlink' '
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);;
65 'git-update-index --add: Test that executable bit is not used...' \
66 'git config core.filemode 0 &&
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);;
74 test_expect_success
'.gitignore test setup' '
75 echo "*.ig" >.gitignore &&
78 >c.if/c.if && >c.if/c.ig &&
79 >d.ig/d.if && >d.ig/d.ig
82 test_expect_success
'.gitignore is honored' '
84 ! git-ls-files | grep "\\.ig"
87 test_expect_success
'error out when attempting to add ignored ones without -f' '
89 ! git-ls-files | grep "\\.ig"
92 test_expect_success
'error out when attempting to add ignored ones without -f' '
94 ! git-ls-files | grep "\\.ig"
97 test_expect_success
'add ignored ones with -f' '
99 git-ls-files --error-unmatch a.ig
102 test_expect_success
'add ignored ones with -f' '
104 git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig
108 touch 1/2/a
1/3/b
1/2/c
109 test_expect_success
'check correct prefix detection' '
110 git add 1/2/a 1/3/b 1/2/c
113 test_expect_success
'git add and filemode=0 with unmerged entries' '
119 echo "100755 $(git hash-object -w stage$s) $s file"
120 done | git update-index --index-info &&
121 git config core.filemode 0 &&
124 git ls-files --stage | grep "^100755 .* 0 file$"
127 test_expect_success
'git add and filemode=0 prefers stage 2 over stage 1' '
128 git rm --cached -f file &&
130 echo "100644 $(git hash-object -w stage1) 1 file"
131 echo "100755 $(git hash-object -w stage2) 2 file"
132 ) | git update-index --index-info &&
133 git config core.filemode 0 &&
136 git ls-files --stage | grep "^100755 .* 0 file$"