]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7409-submodule-detached-work-tree.sh
Merge branch 'ar/submodule-helper-include-cleanup'
[thirdparty/git.git] / t / t7409-submodule-detached-work-tree.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2012 Daniel GraƱa
4 #
5
6 test_description='Test submodules on detached working tree
7
8 This test verifies that "git submodule" initialization, update and addition works
9 on detached working trees
10 '
11
12 TEST_NO_CREATE_REPO=1
13 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
14 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
15
16 . ./test-lib.sh
17
18 test_expect_success 'submodule on detached working tree' '
19 git init --bare remote &&
20 test_create_repo bundle1 &&
21 (
22 cd bundle1 &&
23 test_commit "shoot" &&
24 git rev-parse --verify HEAD >../expect
25 ) &&
26 mkdir home &&
27 (
28 cd home &&
29 GIT_WORK_TREE="$(pwd)" &&
30 GIT_DIR="$(pwd)/.dotfiles" &&
31 export GIT_WORK_TREE GIT_DIR &&
32 git clone --bare ../remote .dotfiles &&
33 git submodule add ../bundle1 .vim/bundle/sogood &&
34 test_commit "sogood" &&
35 (
36 unset GIT_WORK_TREE GIT_DIR &&
37 cd .vim/bundle/sogood &&
38 git rev-parse --verify HEAD >actual &&
39 test_cmp ../../../../expect actual
40 ) &&
41 git push origin main
42 ) &&
43 mkdir home2 &&
44 (
45 cd home2 &&
46 git clone --bare ../remote .dotfiles &&
47 GIT_WORK_TREE="$(pwd)" &&
48 GIT_DIR="$(pwd)/.dotfiles" &&
49 export GIT_WORK_TREE GIT_DIR &&
50 git checkout main &&
51 git submodule update --init &&
52 (
53 unset GIT_WORK_TREE GIT_DIR &&
54 cd .vim/bundle/sogood &&
55 git rev-parse --verify HEAD >actual &&
56 test_cmp ../../../../expect actual
57 )
58 )
59 '
60
61 test_expect_success 'submodule on detached working pointed by core.worktree' '
62 mkdir home3 &&
63 (
64 cd home3 &&
65 GIT_DIR="$(pwd)/.dotfiles" &&
66 export GIT_DIR &&
67 git clone --bare ../remote "$GIT_DIR" &&
68 git config core.bare false &&
69 git config core.worktree .. &&
70 git checkout main &&
71 git submodule add ../bundle1 .vim/bundle/dupe &&
72 test_commit "dupe" &&
73 git push origin main
74 ) &&
75 (
76 cd home &&
77 GIT_DIR="$(pwd)/.dotfiles" &&
78 export GIT_DIR &&
79 git config core.bare false &&
80 git config core.worktree .. &&
81 git pull &&
82 git submodule update --init &&
83 test -f .vim/bundle/dupe/shoot.t
84 )
85 '
86
87 test_done