| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | . "$(dirname "$0")/testlib.sh" |
| 4 | reponame="submodule-recurse-test-repo" |
| 5 | submodname="submodule-recurse-test-submodule" |
| 6 | |
| 7 | begin_test "submodule with submodule.recurse = true" |
| 8 | ( |
| 9 | set -e |
| 10 | |
| 11 | setup_remote_repo "$reponame" |
| 12 | setup_remote_repo "$submodname" |
| 13 | |
| 14 | clone_repo "$submodname" submodule |
| 15 | |
| 16 | git lfs track "*.dat" 2>&1 | tee track.log |
| 17 | grep "Tracking \"\*.dat\"" track.log |
| 18 | |
| 19 | echo "foo" > file.dat |
| 20 | git add .gitattributes file.dat |
| 21 | git commit -a -m "add file" |
| 22 | git push origin main |
| 23 | subcommit1=$(git rev-parse HEAD) |
| 24 | |
| 25 | echo "bar" > file.dat |
| 26 | git add file.dat |
| 27 | git commit -a -m "update file" |
| 28 | git push origin main |
| 29 | subcommit2=$(git rev-parse HEAD) |
| 30 | |
| 31 | clone_repo "$reponame" repo |
| 32 | git submodule add "$GITSERVER/$submodname" submodule |
| 33 | git submodule update --init --recursive |
| 34 | git -C submodule reset --hard "$subcommit1" |
| 35 | git add .gitmodules submodule |
| 36 | git commit -m "add submodule" |
| 37 | git push origin main |
| 38 | |
| 39 | git checkout -b feature |
| 40 | git -C submodule reset --hard "$subcommit2" |
| 41 | git add .gitmodules submodule |
| 42 | git commit -m "update submodule" |
| 43 | git push origin feature |
| 44 | |
| 45 | clone_repo "$reponame" repo-no-recurse |
| 46 | git submodule update --init --recursive |
| 47 | git checkout feature |
| 48 | |
| 49 | if [[ -d "submodule/lfs/logs" ]] |
| 50 | then |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | clone_repo "$reponame" repo-recurse |
| 55 | git config submodule.recurse true |
| 56 | git submodule update --init --recursive |
| 57 | git checkout feature |
| 58 | |
| 59 | if [[ -d "submodule/lfs/logs" ]] |
| 60 | then |
| 61 | exit 1 |
| 62 | fi |
| 63 | ) |
| 64 | end_test |