| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='ls-files --exclude does not affect index files' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'create repo with file' ' |
| 8 | echo content >file && |
| 9 | git add file && |
| 10 | git commit -m file && |
| 11 | echo modification >file |
| 12 | ' |
| 13 | |
| 14 | check_output() { |
| 15 | test_expect_success "ls-files output contains file ($1)" " |
| 16 | echo '$2' >expect && |
| 17 | git ls-files --exclude-standard --$1 >output && |
| 18 | test_cmp expect output |
| 19 | " |
| 20 | } |
| 21 | |
| 22 | check_all_output() { |
| 23 | check_output 'cached' 'file' |
| 24 | check_output 'modified' 'file' |
| 25 | } |
| 26 | |
| 27 | check_all_output |
| 28 | test_expect_success 'add file to gitignore' ' |
| 29 | echo file >.gitignore |
| 30 | ' |
| 31 | check_all_output |
| 32 | |
| 33 | test_expect_success 'ls-files -i -c lists only tracked-but-ignored files' ' |
| 34 | echo content >other-file && |
| 35 | git add other-file && |
| 36 | echo file >expect && |
| 37 | git ls-files -i -c --exclude-standard >output && |
| 38 | test_cmp expect output |
| 39 | ' |
| 40 | |
| 41 | test_done |