Sync with 2.38.5
[git.git] / t / t7409-submodule-detached-work-tree.sh
blob374ed481e9c64b9813a11b57c80f7b6f22c791e1
1 #!/bin/sh
3 # Copyright (c) 2012 Daniel GraƱa
6 test_description='Test submodules on detached working tree
8 This test verifies that "git submodule" initialization, update and addition works
9 on detached working trees
12 TEST_NO_CREATE_REPO=1
13 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
14 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
16 . ./test-lib.sh
18 test_expect_success 'setup' '
19 git config --global protocol.file.allow always
22 test_expect_success 'submodule on detached working tree' '
23 git init --bare remote &&
24 test_create_repo bundle1 &&
26 cd bundle1 &&
27 test_commit "shoot" &&
28 git rev-parse --verify HEAD >../expect
29 ) &&
30 mkdir home &&
32 cd home &&
33 GIT_WORK_TREE="$(pwd)" &&
34 GIT_DIR="$(pwd)/.dotfiles" &&
35 export GIT_WORK_TREE GIT_DIR &&
36 git clone --bare ../remote .dotfiles &&
37 git submodule add ../bundle1 .vim/bundle/sogood &&
38 test_commit "sogood" &&
40 unset GIT_WORK_TREE GIT_DIR &&
41 cd .vim/bundle/sogood &&
42 git rev-parse --verify HEAD >actual &&
43 test_cmp ../../../../expect actual
44 ) &&
45 git push origin main
46 ) &&
47 mkdir home2 &&
49 cd home2 &&
50 git clone --bare ../remote .dotfiles &&
51 GIT_WORK_TREE="$(pwd)" &&
52 GIT_DIR="$(pwd)/.dotfiles" &&
53 export GIT_WORK_TREE GIT_DIR &&
54 git checkout main &&
55 git submodule update --init &&
57 unset GIT_WORK_TREE GIT_DIR &&
58 cd .vim/bundle/sogood &&
59 git rev-parse --verify HEAD >actual &&
60 test_cmp ../../../../expect actual
65 test_expect_success 'submodule on detached working pointed by core.worktree' '
66 mkdir home3 &&
68 cd home3 &&
69 GIT_DIR="$(pwd)/.dotfiles" &&
70 export GIT_DIR &&
71 git clone --bare ../remote "$GIT_DIR" &&
72 git config core.bare false &&
73 git config core.worktree .. &&
74 git checkout main &&
75 git submodule add ../bundle1 .vim/bundle/dupe &&
76 test_commit "dupe" &&
77 git push origin main
78 ) &&
80 cd home &&
81 GIT_DIR="$(pwd)/.dotfiles" &&
82 export GIT_DIR &&
83 git config core.bare false &&
84 git config core.worktree .. &&
85 git pull &&
86 git submodule update --init &&
87 test -f .vim/bundle/dupe/shoot.t
91 test_done