Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Carl D. Worth |
| 4 | # |
| 5 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 6 | test_description='Test of git add, including the -- option.' |
Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 11 | 'Test of git add' \ |
| 12 | 'touch foo && git add foo' |
Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 13 | |
| 14 | test_expect_success \ |
| 15 | 'Post-check that foo is in the index' \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 16 | 'git ls-files foo | grep foo' |
Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 17 | |
| 18 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 19 | 'Test that "git add -- -q" works' \ |
| 20 | 'touch -- -q && git add -- -q' |
Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 21 | |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 22 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 23 | 'git add: Test that executable bit is not used if core.filemode=0' \ |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 24 | 'git config core.filemode 0 && |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 25 | echo foo >xfoo1 && |
| 26 | chmod 755 xfoo1 && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 27 | git add xfoo1 && |
| 28 | case "`git ls-files --stage xfoo1`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 29 | 100644" "*xfoo1) echo pass;; |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 30 | *) echo fail; git ls-files --stage xfoo1; (exit 1);; |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 31 | esac' |
| 32 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 33 | test_expect_success 'git add: filemode=0 should not get confused by symlink' ' |
Junio C Hamano | 185c975 | 2007-02-16 22:43:48 -0800 | [diff] [blame] | 34 | rm -f xfoo1 && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 35 | test_ln_s_add foo xfoo1 && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 36 | case "`git ls-files --stage xfoo1`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 37 | 120000" "*xfoo1) echo pass;; |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 38 | *) echo fail; git ls-files --stage xfoo1; (exit 1);; |
Junio C Hamano | 185c975 | 2007-02-16 22:43:48 -0800 | [diff] [blame] | 39 | esac |
| 40 | ' |
| 41 | |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 42 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 43 | 'git update-index --add: Test that executable bit is not used...' \ |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 44 | 'git config core.filemode 0 && |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 45 | echo foo >xfoo2 && |
| 46 | chmod 755 xfoo2 && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 47 | git update-index --add xfoo2 && |
| 48 | case "`git ls-files --stage xfoo2`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 49 | 100644" "*xfoo2) echo pass;; |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 50 | *) echo fail; git ls-files --stage xfoo2; (exit 1);; |
Junio C Hamano | 2bbaaed | 2006-11-22 16:33:32 -0800 | [diff] [blame] | 51 | esac' |
| 52 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 53 | test_expect_success 'git add: filemode=0 should not get confused by symlink' ' |
Junio C Hamano | 185c975 | 2007-02-16 22:43:48 -0800 | [diff] [blame] | 54 | rm -f xfoo2 && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 55 | test_ln_s_add foo xfoo2 && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 56 | case "`git ls-files --stage xfoo2`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 57 | 120000" "*xfoo2) echo pass;; |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 58 | *) echo fail; git ls-files --stage xfoo2; (exit 1);; |
Junio C Hamano | 185c975 | 2007-02-16 22:43:48 -0800 | [diff] [blame] | 59 | esac |
| 60 | ' |
| 61 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 62 | test_expect_success \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 63 | 'git update-index --add: Test that executable bit is not used...' \ |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 64 | 'git config core.filemode 0 && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 65 | test_ln_s_add xfoo2 xfoo3 && # runs git update-index --add |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 66 | case "`git ls-files --stage xfoo3`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 67 | 120000" "*xfoo3) echo pass;; |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 68 | *) echo fail; git ls-files --stage xfoo3; (exit 1);; |
Shawn Pearce | fd28b34 | 2006-09-27 01:21:19 -0400 | [diff] [blame] | 69 | esac' |
| 70 | |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 71 | test_expect_success '.gitignore test setup' ' |
| 72 | echo "*.ig" >.gitignore && |
| 73 | mkdir c.if d.ig && |
| 74 | >a.ig && >b.if && |
| 75 | >c.if/c.if && >c.if/c.ig && |
| 76 | >d.ig/d.if && >d.ig/d.ig |
| 77 | ' |
| 78 | |
| 79 | test_expect_success '.gitignore is honored' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 80 | git add . && |
Jeff King | bbf0812 | 2008-05-14 00:01:22 -0400 | [diff] [blame] | 81 | ! (git ls-files | grep "\\.ig") |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 82 | ' |
| 83 | |
| 84 | test_expect_success 'error out when attempting to add ignored ones without -f' ' |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 85 | test_must_fail git add a.?? && |
Jeff King | bbf0812 | 2008-05-14 00:01:22 -0400 | [diff] [blame] | 86 | ! (git ls-files | grep "\\.ig") |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 87 | ' |
| 88 | |
| 89 | test_expect_success 'error out when attempting to add ignored ones without -f' ' |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 90 | test_must_fail git add d.?? && |
Jeff King | bbf0812 | 2008-05-14 00:01:22 -0400 | [diff] [blame] | 91 | ! (git ls-files | grep "\\.ig") |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 92 | ' |
| 93 | |
| 94 | test_expect_success 'add ignored ones with -f' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 95 | git add -f a.?? && |
| 96 | git ls-files --error-unmatch a.ig |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 97 | ' |
| 98 | |
| 99 | test_expect_success 'add ignored ones with -f' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 100 | git add -f d.??/* && |
| 101 | git ls-files --error-unmatch d.ig/d.if d.ig/d.ig |
Junio C Hamano | 4d06f8a | 2006-12-29 11:01:31 -0800 | [diff] [blame] | 102 | ' |
| 103 | |
Junio C Hamano | 41a7aa5 | 2007-11-16 01:15:41 -0800 | [diff] [blame] | 104 | test_expect_success 'add ignored ones with -f' ' |
| 105 | rm -f .git/index && |
| 106 | git add -f d.?? && |
| 107 | git ls-files --error-unmatch d.ig/d.if d.ig/d.ig |
| 108 | ' |
| 109 | |
| 110 | test_expect_success '.gitignore with subdirectory' ' |
| 111 | |
| 112 | rm -f .git/index && |
| 113 | mkdir -p sub/dir && |
| 114 | echo "!dir/a.*" >sub/.gitignore && |
| 115 | >sub/a.ig && |
| 116 | >sub/dir/a.ig && |
| 117 | git add sub/dir && |
| 118 | git ls-files --error-unmatch sub/dir/a.ig && |
| 119 | rm -f .git/index && |
| 120 | ( |
| 121 | cd sub/dir && |
| 122 | git add . |
| 123 | ) && |
| 124 | git ls-files --error-unmatch sub/dir/a.ig |
| 125 | ' |
| 126 | |
Johannes Schindelin | c7f34c1 | 2007-04-23 10:21:25 +0200 | [diff] [blame] | 127 | mkdir 1 1/2 1/3 |
| 128 | touch 1/2/a 1/3/b 1/2/c |
| 129 | test_expect_success 'check correct prefix detection' ' |
Junio C Hamano | 41a7aa5 | 2007-11-16 01:15:41 -0800 | [diff] [blame] | 130 | rm -f .git/index && |
Johannes Schindelin | c7f34c1 | 2007-04-23 10:21:25 +0200 | [diff] [blame] | 131 | git add 1/2/a 1/3/b 1/2/c |
| 132 | ' |
| 133 | |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 134 | test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' ' |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 135 | for s in 1 2 3 |
| 136 | do |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 137 | echo $s > stage$s |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 138 | echo "100755 $(git hash-object -w stage$s) $s file" |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 139 | echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s symlink" |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 140 | done | git update-index --index-info && |
| 141 | git config core.filemode 0 && |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 142 | git config core.symlinks 0 && |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 143 | echo new > file && |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 144 | echo new > symlink && |
| 145 | git add file symlink && |
| 146 | git ls-files --stage | grep "^100755 .* 0 file$" && |
| 147 | git ls-files --stage | grep "^120000 .* 0 symlink$" |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 148 | ' |
| 149 | |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 150 | test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' ' |
| 151 | git rm --cached -f file symlink && |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 152 | ( |
| 153 | echo "100644 $(git hash-object -w stage1) 1 file" |
| 154 | echo "100755 $(git hash-object -w stage2) 2 file" |
Junio C Hamano | a697ec6 | 2007-08-03 14:31:47 -0700 | [diff] [blame] | 155 | echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink" |
| 156 | echo "120000 $(printf 2 | git hash-object -w -t blob --stdin) 2 symlink" |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 157 | ) | git update-index --index-info && |
| 158 | git config core.filemode 0 && |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 159 | git config core.symlinks 0 && |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 160 | echo new > file && |
Johannes Sixt | 05dcd69 | 2007-07-02 13:28:42 +0200 | [diff] [blame] | 161 | echo new > symlink && |
| 162 | git add file symlink && |
| 163 | git ls-files --stage | grep "^100755 .* 0 file$" && |
| 164 | git ls-files --stage | grep "^120000 .* 0 symlink$" |
Johannes Schindelin | 2031427 | 2007-06-29 18:32:46 +0100 | [diff] [blame] | 165 | ' |
| 166 | |
Alexandre Julliard | d616813 | 2007-08-11 23:59:01 +0200 | [diff] [blame] | 167 | test_expect_success 'git add --refresh' ' |
| 168 | >foo && git add foo && git commit -a -m "commit all" && |
| 169 | test -z "`git diff-index HEAD -- foo`" && |
| 170 | git read-tree HEAD && |
| 171 | case "`git diff-index HEAD -- foo`" in |
Ævar Arnfjörð Bjarmason | 335f878 | 2010-06-24 17:44:49 +0000 | [diff] [blame] | 172 | :100644" "*"M foo") echo pass;; |
Alexandre Julliard | d616813 | 2007-08-11 23:59:01 +0200 | [diff] [blame] | 173 | *) echo fail; (exit 1);; |
| 174 | esac && |
| 175 | git add --refresh -- foo && |
| 176 | test -z "`git diff-index HEAD -- foo`" |
| 177 | ' |
| 178 | |
Junio C Hamano | 3d1f148 | 2012-02-17 10:11:05 -0800 | [diff] [blame] | 179 | test_expect_success 'git add --refresh with pathspec' ' |
| 180 | git reset --hard && |
| 181 | echo >foo && echo >bar && echo >baz && |
| 182 | git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo && |
| 183 | echo "100644 $H 3 foo" | git update-index --index-info && |
| 184 | test-chmtime -60 bar baz && |
| 185 | >expect && |
| 186 | git add --refresh bar >actual && |
| 187 | test_cmp expect actual && |
| 188 | |
| 189 | git diff-files --name-only >actual && |
| 190 | ! grep bar actual&& |
| 191 | grep baz actual |
| 192 | ' |
| 193 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 194 | test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' ' |
Alex Riesen | 8959743 | 2008-05-12 19:58:48 +0200 | [diff] [blame] | 195 | git reset --hard && |
| 196 | date >foo1 && |
| 197 | date >foo2 && |
| 198 | chmod 0 foo2 && |
| 199 | test_must_fail git add --verbose . && |
| 200 | ! ( git ls-files foo1 | grep foo1 ) |
| 201 | ' |
| 202 | |
| 203 | rm -f foo2 |
| 204 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 205 | test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' ' |
Alex Riesen | 8959743 | 2008-05-12 19:58:48 +0200 | [diff] [blame] | 206 | git reset --hard && |
| 207 | date >foo1 && |
| 208 | date >foo2 && |
| 209 | chmod 0 foo2 && |
| 210 | test_must_fail git add --verbose --ignore-errors . && |
| 211 | git ls-files foo1 | grep foo1 |
| 212 | ' |
| 213 | |
| 214 | rm -f foo2 |
| 215 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 216 | test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' ' |
Alex Riesen | dad25e4 | 2008-05-12 19:59:23 +0200 | [diff] [blame] | 217 | git config add.ignore-errors 1 && |
| 218 | git reset --hard && |
| 219 | date >foo1 && |
| 220 | date >foo2 && |
| 221 | chmod 0 foo2 && |
| 222 | test_must_fail git add --verbose . && |
| 223 | git ls-files foo1 | grep foo1 |
| 224 | ' |
| 225 | rm -f foo2 |
| 226 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 227 | test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' ' |
Alex Riesen | dad25e4 | 2008-05-12 19:59:23 +0200 | [diff] [blame] | 228 | git config add.ignore-errors 0 && |
| 229 | git reset --hard && |
| 230 | date >foo1 && |
| 231 | date >foo2 && |
| 232 | chmod 0 foo2 && |
| 233 | test_must_fail git add --verbose . && |
| 234 | ! ( git ls-files foo1 | grep foo1 ) |
| 235 | ' |
Stephen Boyd | ed342fd | 2009-06-18 02:17:54 -0700 | [diff] [blame] | 236 | rm -f foo2 |
| 237 | |
Ævar Arnfjörð Bjarmason | c91cfd1 | 2010-08-06 22:09:09 +0000 | [diff] [blame] | 238 | test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' ' |
Stephen Boyd | ed342fd | 2009-06-18 02:17:54 -0700 | [diff] [blame] | 239 | git config add.ignore-errors 1 && |
| 240 | git reset --hard && |
| 241 | date >foo1 && |
| 242 | date >foo2 && |
| 243 | chmod 0 foo2 && |
| 244 | test_must_fail git add --verbose --no-ignore-errors . && |
| 245 | ! ( git ls-files foo1 | grep foo1 ) && |
| 246 | git config add.ignore-errors 0 |
| 247 | ' |
| 248 | rm -f foo2 |
Alex Riesen | dad25e4 | 2008-05-12 19:59:23 +0200 | [diff] [blame] | 249 | |
Johannes Sixt | 6fd1106 | 2009-03-13 23:00:15 +0100 | [diff] [blame] | 250 | test_expect_success BSLASHPSPEC "git add 'fo\\[ou\\]bar' ignores foobar" ' |
Kevin Ballard | ea335b5 | 2008-08-13 15:34:34 -0700 | [diff] [blame] | 251 | git reset --hard && |
Alex Riesen | 8134a00 | 2008-08-15 09:32:30 +0200 | [diff] [blame] | 252 | touch fo\[ou\]bar foobar && |
| 253 | git add '\''fo\[ou\]bar'\'' && |
Jeff King | 8753941 | 2008-09-30 04:03:55 -0400 | [diff] [blame] | 254 | git ls-files fo\[ou\]bar | fgrep fo\[ou\]bar && |
Kevin Ballard | ea335b5 | 2008-08-13 15:34:34 -0700 | [diff] [blame] | 255 | ! ( git ls-files foobar | grep foobar ) |
| 256 | ' |
| 257 | |
Jeff King | 6e4f981 | 2009-05-30 17:54:18 -0400 | [diff] [blame] | 258 | test_expect_success 'git add to resolve conflicts on otherwise ignored path' ' |
| 259 | git reset --hard && |
| 260 | H=$(git rev-parse :1/2/a) && |
| 261 | ( |
| 262 | echo "100644 $H 1 track-this" |
| 263 | echo "100644 $H 3 track-this" |
| 264 | ) | git update-index --index-info && |
| 265 | echo track-this >>.gitignore && |
| 266 | echo resolved >track-this && |
| 267 | git add track-this |
| 268 | ' |
| 269 | |
Chris Packham | 1e7ef74 | 2010-02-09 17:30:48 -0500 | [diff] [blame] | 270 | test_expect_success '"add non-existent" should fail' ' |
| 271 | test_must_fail git add non-existent && |
| 272 | ! (git ls-files | grep "non-existent") |
| 273 | ' |
| 274 | |
Jens Lehmann | 108da0d | 2010-07-10 00:18:38 +0200 | [diff] [blame] | 275 | test_expect_success 'git add --dry-run of existing changed file' " |
| 276 | echo new >>track-this && |
| 277 | git add --dry-run track-this >actual 2>&1 && |
| 278 | echo \"add 'track-this'\" | test_cmp - actual |
| 279 | " |
| 280 | |
| 281 | test_expect_success 'git add --dry-run of non-existing file' " |
| 282 | echo ignored-file >>.gitignore && |
Ævar Arnfjörð Bjarmason | 4816885 | 2011-02-22 23:41:31 +0000 | [diff] [blame] | 283 | test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 |
| 284 | " |
| 285 | |
Junio C Hamano | 68b2a00 | 2011-04-12 16:27:11 -0700 | [diff] [blame] | 286 | test_expect_success 'git add --dry-run of an existing file output' " |
Ævar Arnfjörð Bjarmason | 4816885 | 2011-02-22 23:41:31 +0000 | [diff] [blame] | 287 | echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect && |
Junio C Hamano | 68b2a00 | 2011-04-12 16:27:11 -0700 | [diff] [blame] | 288 | test_i18ncmp expect actual |
Jens Lehmann | 108da0d | 2010-07-10 00:18:38 +0200 | [diff] [blame] | 289 | " |
| 290 | |
Johannes Sixt | c1e02b2 | 2010-07-22 10:13:33 +0200 | [diff] [blame] | 291 | cat >expect.err <<\EOF |
Jens Lehmann | 108da0d | 2010-07-10 00:18:38 +0200 | [diff] [blame] | 292 | The following paths are ignored by one of your .gitignore files: |
| 293 | ignored-file |
| 294 | Use -f if you really want to add them. |
| 295 | fatal: no files added |
Johannes Sixt | c1e02b2 | 2010-07-22 10:13:33 +0200 | [diff] [blame] | 296 | EOF |
| 297 | cat >expect.out <<\EOF |
Jens Lehmann | 108da0d | 2010-07-10 00:18:38 +0200 | [diff] [blame] | 298 | add 'track-this' |
| 299 | EOF |
| 300 | |
| 301 | test_expect_success 'git add --dry-run --ignore-missing of non-existing file' ' |
Ævar Arnfjörð Bjarmason | 439fb82 | 2011-02-22 23:41:30 +0000 | [diff] [blame] | 302 | test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err |
| 303 | ' |
| 304 | |
Junio C Hamano | 68b2a00 | 2011-04-12 16:27:11 -0700 | [diff] [blame] | 305 | test_expect_success 'git add --dry-run --ignore-missing of non-existing file output' ' |
| 306 | test_i18ncmp expect.out actual.out && |
| 307 | test_i18ncmp expect.err actual.err |
Jens Lehmann | 108da0d | 2010-07-10 00:18:38 +0200 | [diff] [blame] | 308 | ' |
| 309 | |
Carl Worth | 60ace87 | 2006-02-21 15:33:49 -0800 | [diff] [blame] | 310 | test_done |