]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7409-submodule-detached-work-tree.sh
The third batch
[thirdparty/git.git] / t / t7409-submodule-detached-work-tree.sh
CommitLineData
be8779f7
DG
1#!/bin/sh
2#
3# Copyright (c) 2012 Daniel Graña
4#
5
6test_description='Test submodules on detached working tree
7
8This test verifies that "git submodule" initialization, update and addition works
c9a800a6 9on detached working trees
be8779f7
DG
10'
11
12TEST_NO_CREATE_REPO=1
01dc8133 13GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
14export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
15
c65d18cb 16TEST_PASSES_SANITIZE_LEAK=true
be8779f7
DG
17. ./test-lib.sh
18
0d3beb71
TB
19test_expect_success 'setup' '
20 git config --global protocol.file.allow always
21'
22
be8779f7
DG
23test_expect_success 'submodule on detached working tree' '
24 git init --bare remote &&
25 test_create_repo bundle1 &&
95e77053
DG
26 (
27 cd bundle1 &&
28 test_commit "shoot" &&
29 git rev-parse --verify HEAD >../expect
30 ) &&
be8779f7
DG
31 mkdir home &&
32 (
33 cd home &&
a8addfec
TB
34 GIT_WORK_TREE="$(pwd)" &&
35 GIT_DIR="$(pwd)/.dotfiles" &&
36 export GIT_WORK_TREE GIT_DIR &&
be8779f7
DG
37 git clone --bare ../remote .dotfiles &&
38 git submodule add ../bundle1 .vim/bundle/sogood &&
39 test_commit "sogood" &&
95e77053
DG
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 ) &&
01dc8133 46 git push origin main
be8779f7
DG
47 ) &&
48 mkdir home2 &&
49 (
50 cd home2 &&
be8779f7 51 git clone --bare ../remote .dotfiles &&
a8addfec
TB
52 GIT_WORK_TREE="$(pwd)" &&
53 GIT_DIR="$(pwd)/.dotfiles" &&
54 export GIT_WORK_TREE GIT_DIR &&
01dc8133 55 git checkout main &&
95e77053
DG
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 )
be8779f7
DG
63 )
64'
65
66test_expect_success 'submodule on detached working pointed by core.worktree' '
67 mkdir home3 &&
68 (
69 cd home3 &&
a8addfec
TB
70 GIT_DIR="$(pwd)/.dotfiles" &&
71 export GIT_DIR &&
be8779f7
DG
72 git clone --bare ../remote "$GIT_DIR" &&
73 git config core.bare false &&
74 git config core.worktree .. &&
01dc8133 75 git checkout main &&
be8779f7
DG
76 git submodule add ../bundle1 .vim/bundle/dupe &&
77 test_commit "dupe" &&
01dc8133 78 git push origin main
be8779f7
DG
79 ) &&
80 (
81 cd home &&
a8addfec
TB
82 GIT_DIR="$(pwd)/.dotfiles" &&
83 export GIT_DIR &&
be8779f7
DG
84 git config core.bare false &&
85 git config core.worktree .. &&
86 git pull &&
95e77053
DG
87 git submodule update --init &&
88 test -f .vim/bundle/dupe/shoot.t
be8779f7
DG
89 )
90'
91
92test_done