| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='handling of common mistakes people may make with submodules' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'create embedded repository' ' |
| 8 | git init embed && |
| 9 | test_commit -C embed one |
| 10 | ' |
| 11 | |
| 12 | test_expect_success 'git-add on embedded repository warns' ' |
| 13 | test_when_finished "git rm --cached -f embed" && |
| 14 | git add embed 2>stderr && |
| 15 | test_grep warning stderr |
| 16 | ' |
| 17 | |
| 18 | test_expect_success '--no-warn-embedded-repo suppresses warning' ' |
| 19 | test_when_finished "git rm --cached -f embed" && |
| 20 | git add --no-warn-embedded-repo embed 2>stderr && |
| 21 | test_grep ! warning stderr |
| 22 | ' |
| 23 | |
| 24 | test_expect_success 'no warning when updating entry' ' |
| 25 | test_when_finished "git rm --cached -f embed" && |
| 26 | git add embed && |
| 27 | git -C embed commit --allow-empty -m two && |
| 28 | git add embed 2>stderr && |
| 29 | test_grep ! warning stderr |
| 30 | ' |
| 31 | |
| 32 | test_expect_success 'submodule add does not warn' ' |
| 33 | test_when_finished "git rm -rf submodule .gitmodules" && |
| 34 | git -c protocol.file.allow=always \ |
| 35 | submodule add ./embed submodule 2>stderr && |
| 36 | test_grep ! warning stderr |
| 37 | ' |
| 38 | |
| 39 | test_done |