3 test_description
='Test submodule absorbgitdirs
5 This test verifies that `git submodue absorbgitdirs` moves a submodules git
6 directory into the superproject.
11 test_expect_success
'setup a real submodule' '
13 test_commit -C sub1 first &&
14 git submodule add ./sub1 &&
16 git commit -m superproject
19 test_expect_success
'absorb the git dir' '
24 git status >expect.1 &&
25 git -C sub1 rev-parse HEAD >expect.2 &&
26 git submodule absorbgitdirs &&
29 test -d .git/modules/sub1 &&
30 git status >actual.1 &&
31 git -C sub1 rev-parse HEAD >actual.2 &&
32 test_cmp expect.1 actual.1 &&
33 test_cmp expect.2 actual.2
36 test_expect_success
'absorbing does not fail for deinitalized submodules' '
37 test_when_finished "git submodule update --init" &&
38 git submodule deinit --all &&
39 git submodule absorbgitdirs &&
40 test -d .git/modules/sub1 &&
45 test_expect_success
'setup nested submodule' '
46 git init sub1/nested &&
47 test_commit -C sub1/nested first_nested &&
48 git -C sub1 submodule add ./nested &&
50 git -C sub1 commit -m "add nested" &&
52 git commit -m "sub1 to include nested submodule"
55 test_expect_success
'absorb the git dir in a nested submodule' '
56 git status >expect.1 &&
57 git -C sub1/nested rev-parse HEAD >expect.2 &&
58 git submodule absorbgitdirs &&
59 test -f sub1/nested/.git &&
60 test -d .git/modules/sub1/modules/nested &&
61 git status >actual.1 &&
62 git -C sub1/nested rev-parse HEAD >actual.2 &&
63 test_cmp expect.1 actual.1 &&
64 test_cmp expect.2 actual.2
67 test_expect_success
'setup a gitlink with missing .gitmodules entry' '
69 test_commit -C sub2 first &&
71 git commit -m superproject
74 test_expect_success
'absorbing the git dir fails for incomplete submodules' '
75 git status >expect.1 &&
76 git -C sub2 rev-parse HEAD >expect.2 &&
77 test_must_fail git submodule absorbgitdirs &&
81 git -C sub2 rev-parse HEAD >actual.2 &&
82 test_cmp expect.1 actual.1 &&
83 test_cmp expect.2 actual.2
86 test_expect_success
'setup a submodule with multiple worktrees' '
87 # first create another unembedded git dir in a new submodule
89 test_commit -C sub3 first &&
90 git submodule add ./sub3 &&
92 git commit -m "add another submodule" &&
93 git -C sub3 worktree add ../sub3_second_work_tree
96 test_expect_success
'absorbing fails for a submodule with multiple worktrees' '
97 test_must_fail git submodule absorbgitdirs sub3 2>error &&
98 test_i18ngrep "not supported" error