Skip to content

Commit abe4fc4

Browse files
committed
test: test submodules enable when being on branch
1 parent 3ba60b2 commit abe4fc4

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

test/git-scm-switch/run.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,28 @@
77

88
git_dir1=$(mktemp -d)
99
git_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
1112
cleanup
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+
1525
pushd "$git_dir1"
1626
git init .
1727
git config user.email "bob@bob.bob"
1828
git config user.name test
1929
echo "hello world" > test.txt
2030
git add test.txt
31+
git submodule add "$git_submod" submod
2132
git commit -m "first commit"
2233
git tag -a -m "First Tag" tag1
2334
git checkout -b foobar
@@ -54,9 +65,20 @@ run_bob dev -DSCM_DIR="$git_dir1" -DSCM_REV="refs/heads/master" root
5465
expect_output "hello world" cat dev/src/root/1/workspace/test.txt
5566
expect_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
6082
run_bob dev -DSCM_DIR="$git_dir2" -DSCM_REV="refs/heads/master" root -j
6183
expect_not_exist dev/src/root/1/workspace/test.txt
6284
expect_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
7193
expect_not_exist dev/src/root/1/workspace/bob.txt
7294
expect_exist dev/src/root/1/workspace/canary.txt
7395

74-
# Enabling submodules is ok
96+
# Enabling submodules on tags is ok
7597
run_bob dev -c submodules -DSCM_DIR="$git_dir1" -DSCM_REV="refs/tags/tag2" root
7698
expect_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
79102
run_bob dev -DSCM_DIR="$git_dir1" -DSCM_REV="refs/tags/tag2" root
80103
expect_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.
83107
echo canary > dev/src/root/1/workspace/canary.txt

0 commit comments

Comments
 (0)