18
git -C origin/main commit -m "sub updated"
19
'
20
21
-test_expect_success 'setup: clone' '
22
- mkdir clone &&
23
- git -C clone clone --recursive "$base_path/origin/main"
21
+test_expect_success 'setup: clone superproject to create main worktree' '
22
+ git clone --recursive "$base_path/origin/main" main
23
'
24
25
rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1")
26
rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1")
27
29
-test_expect_success 'checkout main' '
30
- mkdir default_checkout &&
31
- git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main"
28
+test_expect_success 'add superproject worktree' '
29
+ git -C main worktree add "$base_path/worktree" "$rev1_hash_main"
30
'
31
34
-test_expect_failure 'can see submodule diffs just after checkout' '
35
- git -C default_checkout/main diff --submodule master"^!" >out &&
32
+test_expect_failure 'submodule is checked out just after worktree add' '
33
+ git -C worktree diff --submodule master"^!" >out &&
34
grep "file1 updated" out
35
'
36
39
-test_expect_success 'checkout main and initialize independent clones' '
40
- mkdir fully_cloned_submodule &&
41
- git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" &&
42
- git -C fully_cloned_submodule/main submodule update
37
+test_expect_success 'add superproject worktree and initialize submodules' '
38
+ git -C main worktree add "$base_path/worktree-submodule-update" "$rev1_hash_main" &&
39
+ git -C worktree-submodule-update submodule update
40
'
41
45
-test_expect_success 'can see submodule diffs after independent cloning' '
46
- git -C fully_cloned_submodule/main diff --submodule master"^!" >out &&
42
+test_expect_success 'submodule is checked out just after submodule update in linked worktree' '
43
+ git -C worktree-submodule-update diff --submodule master"^!" >out &&
44
grep "file1 updated" out
45
'
46
50
-test_expect_success 'checkout sub manually' '
51
- mkdir linked_submodule &&
52
- git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" &&
53
- git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub"
47
+test_expect_success 'add superproject worktree and manually add submodule worktree' '
48
+ git -C main worktree add "$base_path/linked_submodule" "$rev1_hash_main" &&
49
+ git -C main/sub worktree add "$base_path/linked_submodule/sub" "$rev1_hash_sub"
50
'
51
56
-test_expect_success 'can see submodule diffs after manual checkout of linked submodule' '
57
- git -C linked_submodule/main diff --submodule master"^!" >out &&
52
+test_expect_success 'submodule is checked out after manually adding submodule worktree' '
53
+ git -C linked_submodule diff --submodule master"^!" >out &&
54
grep "file1 updated" out
55
'
56