Merge branch 'ps/reftable-write-optim'
[alt-git.git] / t / t7409-submodule-detached-work-tree.sh
blob574a6fc526ea0c22ed2ca9df925854235632bb42
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_PASSES_SANITIZE_LEAK=true
17 . ./test-lib.sh
19 test_expect_success 'setup' '
20 git config --global protocol.file.allow always
23 test_expect_success 'submodule on detached working tree' '
24 git init --bare remote &&
25 test_create_repo bundle1 &&
27 cd bundle1 &&
28 test_commit "shoot" &&
29 git rev-parse --verify HEAD >../expect
30 ) &&
31 mkdir home &&
33 cd home &&
34 GIT_WORK_TREE="$(pwd)" &&
35 GIT_DIR="$(pwd)/.dotfiles" &&
36 export GIT_WORK_TREE GIT_DIR &&
37 git clone --bare ../remote .dotfiles &&
38 git submodule add ../bundle1 .vim/bundle/sogood &&
39 test_commit "sogood" &&
41 unset GIT_WORK_TREE GIT_DIR &&
42 cd .vim/bundle/sogood &&
43 git rev-parse --verify HEAD >actual &&
44 test_cmp ../../../../expect actual
45 ) &&
46 git push origin main
47 ) &&
48 mkdir home2 &&
50 cd home2 &&
51 git clone --bare ../remote .dotfiles &&
52 GIT_WORK_TREE="$(pwd)" &&
53 GIT_DIR="$(pwd)/.dotfiles" &&
54 export GIT_WORK_TREE GIT_DIR &&
55 git checkout main &&
56 git submodule update --init &&
58 unset GIT_WORK_TREE GIT_DIR &&
59 cd .vim/bundle/sogood &&
60 git rev-parse --verify HEAD >actual &&
61 test_cmp ../../../../expect actual
66 test_expect_success 'submodule on detached working pointed by core.worktree' '
67 mkdir home3 &&
69 cd home3 &&
70 GIT_DIR="$(pwd)/.dotfiles" &&
71 export GIT_DIR &&
72 git clone --bare ../remote "$GIT_DIR" &&
73 git config core.bare false &&
74 git config core.worktree .. &&
75 git checkout main &&
76 git submodule add ../bundle1 .vim/bundle/dupe &&
77 test_commit "dupe" &&
78 git push origin main
79 ) &&
81 cd home &&
82 GIT_DIR="$(pwd)/.dotfiles" &&
83 export GIT_DIR &&
84 git config core.bare false &&
85 git config core.worktree .. &&
86 git pull &&
87 git submodule update --init &&
88 test -f .vim/bundle/dupe/shoot.t
92 test_done