Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git add --all' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | ( |
Eric Sunshine | 2c2d0f9 | 2018-07-01 20:23:57 -0400 | [diff] [blame] | 9 | echo .gitignore && |
Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 10 | echo will-remove |
| 11 | ) >expect && |
| 12 | ( |
Eric Sunshine | 2c2d0f9 | 2018-07-01 20:23:57 -0400 | [diff] [blame] | 13 | echo actual && |
| 14 | echo expect && |
Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 15 | echo ignored |
| 16 | ) >.gitignore && |
Junio C Hamano | 29abb33 | 2015-10-24 19:31:11 -0700 | [diff] [blame] | 17 | git --literal-pathspecs add --all && |
Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 18 | >will-remove && |
| 19 | git add --all && |
| 20 | test_tick && |
| 21 | git commit -m initial && |
| 22 | git ls-files >actual && |
| 23 | test_cmp expect actual |
| 24 | ' |
| 25 | |
| 26 | test_expect_success 'git add --all' ' |
| 27 | ( |
Eric Sunshine | 2c2d0f9 | 2018-07-01 20:23:57 -0400 | [diff] [blame] | 28 | echo .gitignore && |
| 29 | echo not-ignored && |
| 30 | echo "M .gitignore" && |
| 31 | echo "A not-ignored" && |
Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 32 | echo "D will-remove" |
| 33 | ) >expect && |
| 34 | >ignored && |
| 35 | >not-ignored && |
| 36 | echo modification >>.gitignore && |
| 37 | rm -f will-remove && |
| 38 | git add --all && |
| 39 | git update-index --refresh && |
| 40 | git ls-files >actual && |
| 41 | git diff-index --name-status --cached HEAD >>actual && |
| 42 | test_cmp expect actual |
| 43 | ' |
| 44 | |
Junio C Hamano | 76b6235 | 2013-07-19 20:57:01 -0700 | [diff] [blame] | 45 | test_expect_success 'Just "git add" is a no-op' ' |
| 46 | git reset --hard && |
| 47 | echo >will-remove && |
| 48 | >will-not-be-added && |
| 49 | git add && |
| 50 | git diff-index --name-status --cached HEAD >actual && |
Ævar Arnfjörð Bjarmason | d3c6751 | 2018-07-27 17:48:11 +0000 | [diff] [blame] | 51 | test_must_be_empty actual |
Junio C Hamano | 76b6235 | 2013-07-19 20:57:01 -0700 | [diff] [blame] | 52 | ' |
| 53 | |
Junio C Hamano | 340ce9e | 2008-07-19 20:32:38 -0700 | [diff] [blame] | 54 | test_done |