]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7409-submodule-detached-work-tree.sh
Merge branch 'mk/workaround-pcre-jit-ucp-bug'
[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_PASSES_SANITIZE_LEAK=true
17 . ./test-lib.sh
18
19 test_expect_success 'setup' '
20 git config --global protocol.file.allow always
21 '
22
23 test_expect_success 'submodule on detached working tree' '
24 git init --bare remote &&
25 test_create_repo bundle1 &&
26 (
27 cd bundle1 &&
28 test_commit "shoot" &&
29 git rev-parse --verify HEAD >../expect
30 ) &&
31 mkdir home &&
32 (
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" &&
40 (
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 &&
49 (
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 &&
57 (
58 unset GIT_WORK_TREE GIT_DIR &&
59 cd .vim/bundle/sogood &&
60 git rev-parse --verify HEAD >actual &&
61 test_cmp ../../../../expect actual
62 )
63 )
64 '
65
66 test_expect_success 'submodule on detached working pointed by core.worktree' '
67 mkdir home3 &&
68 (
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 ) &&
80 (
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
89 )
90 '
91
92 test_done