Skip to content

Commit 129510a

Browse files
phil-blaingitster
authored andcommitted
t2405: clarify test descriptions and simplify test
When 'checkout --to' functionality was moved to 'worktree add', tests were adapted in f194b1e (tests: worktree: retrofit "checkout --to" tests for "worktree add", 2015-07-06). The calls were changed to 'worktree add' in this test (then t7410), but the test descriptions were not updated, keeping 'checkout' instead of using the new terminology (linked worktrees). Also, in the test each worktree is created in $TRASH_DIRECTORY/<leading-directory>/main, where the name of <leading-directory> carries some information about what behavior each test verifies. This directory structure is not mandatory for the tests; the worktrees can live next to one another in the trash directory. Clarify the tests by using the right terminology, and remove the unnecessary leading directories such that all superproject worktrees are directly next to one another in the trash directory. Signed-off-by: Philippe Blain <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4eaadc8 commit 129510a

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

t/t2405-worktree-submodule.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,39 @@ test_expect_success 'setup: create origin repos' '
1818
git -C origin/main commit -m "sub updated"
1919
'
2020

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
2423
'
2524

2625
rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1")
2726
rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1")
2827

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"
3230
'
3331

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 &&
3634
grep "file1 updated" out
3735
'
3836

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
4340
'
4441

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 &&
4744
grep "file1 updated" out
4845
'
4946

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"
5450
'
5551

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 &&
5854
grep "file1 updated" out
5955
'
6056

0 commit comments

Comments
 (0)