77
88git_dir1=$( mktemp -d)
99git_dir2=$( mktemp -d)
10- trap ' rm -rf "$git_dir1" "$git_dir2"' EXIT
10+ git_submod=$( mktemp -d)
11+ trap ' rm -rf "$git_dir1" "$git_dir2" "$git_submod"' EXIT
1112cleanup
1213
1314# Prepare git repositories
1415
16+ pushd " $git_submod "
17+ git init .
18+ git config user.email " bob@bob.bob"
19+ git config user.name test
20+ echo sub > sub.txt
21+ git add sub.txt
22+ git commit -m import
23+ popd
24+
1525pushd " $git_dir1 "
1626git init .
1727git config user.email " bob@bob.bob"
1828git config user.name test
1929echo " hello world" > test.txt
2030git add test.txt
31+ git submodule add " $git_submod " submod
2132git commit -m " first commit"
2233git tag -a -m " First Tag" tag1
2334git checkout -b foobar
@@ -54,9 +65,20 @@ run_bob dev -DSCM_DIR="$git_dir1" -DSCM_REV="refs/heads/master" root
5465expect_output " hello world" cat dev/src/root/1/workspace/test.txt
5566expect_exist dev/src/root/1/workspace/canary.txt
5667
68+ # Enabling submodules on branch is ok
69+ run_bob dev -c submodules -DSCM_DIR=" $git_dir1 " -DSCM_REV=" refs/heads/master" root
70+ expect_exist dev/src/root/1/workspace/canary.txt
71+ expect_exist dev/src/root/1/workspace/submod/sub.txt
72+
73+ # But disabling submodules on branch must trigger an attic move
74+ run_bob dev -DSCM_DIR=" $git_dir1 " -DSCM_REV=" refs/heads/master" root
75+ expect_not_exist dev/src/root/1/workspace/canary.txt
76+ expect_not_exist dev/src/root/1/workspace/submod/sub.txt
77+
5778# Change repository but keep branch. This must move the dir into the attic
5879# because they do not share a common history and the branch cannot be
5980# forwarded.
81+ echo canary > dev/src/root/1/workspace/canary.txt
6082run_bob dev -DSCM_DIR=" $git_dir2 " -DSCM_REV=" refs/heads/master" root -j
6183expect_not_exist dev/src/root/1/workspace/test.txt
6284expect_output " hello bob" cat dev/src/root/1/workspace/bob.txt
@@ -71,13 +93,15 @@ expect_output "changed" cat dev/src/root/1/workspace/test.txt
7193expect_not_exist dev/src/root/1/workspace/bob.txt
7294expect_exist dev/src/root/1/workspace/canary.txt
7395
74- # Enabling submodules is ok
96+ # Enabling submodules on tags is ok
7597run_bob dev -c submodules -DSCM_DIR=" $git_dir1 " -DSCM_REV=" refs/tags/tag2" root
7698expect_exist dev/src/root/1/workspace/canary.txt
99+ expect_exist dev/src/root/1/workspace/submod/sub.txt
77100
78- # But disabling submodules must trigger an attic move
101+ # But disabling submodules on tags must trigger an attic move
79102run_bob dev -DSCM_DIR=" $git_dir1 " -DSCM_REV=" refs/tags/tag2" root
80103expect_not_exist dev/src/root/1/workspace/canary.txt
104+ expect_not_exist dev/src/root/1/workspace/submod/sub.txt
81105
82106# Trying to trigger an inline upgrade for dirty data will fail and move to attic.
83107echo canary > dev/src/root/1/workspace/canary.txt
0 commit comments