]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t7410-submodule-checkout-to.sh
3 test_description
='Combination of submodules and multiple workdirs'
9 test_expect_success
'setup: make origin' '
10 mkdir -p origin/sub &&
12 cd origin/sub && git init &&
17 mkdir -p origin/main &&
19 cd origin/main && git init &&
20 git submodule add ../sub &&
21 git commit -m "add sub"
25 echo file1updated >file1 &&
27 git commit -m "file1 updated"
29 git -C origin/main/sub pull &&
33 git commit -m "sub updated"
37 test_expect_success
'setup: clone' '
39 git -C clone clone --recursive "$base_path/origin/main"
42 rev1_hash_main
=$
(git
--git-dir=origin
/main
/.git show
--pretty=format
:%h
-q "HEAD~1")
43 rev1_hash_sub
=$
(git
--git-dir=origin
/sub
/.git show
--pretty=format
:%h
-q "HEAD~1")
45 test_expect_success
'checkout main' '
46 mkdir default_checkout &&
47 git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main"
50 test_expect_failure
'can see submodule diffs just after checkout' '
51 git -C default_checkout/main diff --submodule master"^!" >out &&
52 grep "file1 updated" out
55 test_expect_success
'checkout main and initialize independent clones' '
56 mkdir fully_cloned_submodule &&
57 git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" &&
58 git -C fully_cloned_submodule/main submodule update
61 test_expect_success
'can see submodule diffs after independent cloning' '
62 git -C fully_cloned_submodule/main diff --submodule master"^!" >out &&
63 grep "file1 updated" out
66 test_expect_success
'checkout sub manually' '
67 mkdir linked_submodule &&
68 git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" &&
69 git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub"
72 test_expect_success
'can see submodule diffs after manual checkout of linked submodule' '
73 git -C linked_submodule/main diff --submodule master"^!" >out &&
74 grep "file1 updated" out