]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5572-pull-submodule.sh
Merge branch 'dl/test-must-fail-fixes-5'
[thirdparty/git.git] / t / t5572-pull-submodule.sh
CommitLineData
921f50b4
JL
1#!/bin/sh
2
3test_description='pull can handle submodules'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-submodule-update.sh
7
8reset_branch_to_HEAD () {
9 git branch -D "$1" &&
10 git checkout -b "$1" HEAD &&
11 git branch --set-upstream-to="origin/$1" "$1"
12}
13
14git_pull () {
15 reset_branch_to_HEAD "$1" &&
5b0ac09f
DL
16 may_only_be_test_must_fail "$2" &&
17 $2 git pull
921f50b4
JL
18}
19
20# pulls without conflicts
aa06180a 21test_submodule_switch_func "git_pull"
921f50b4
JL
22
23git_pull_ff () {
24 reset_branch_to_HEAD "$1" &&
5b0ac09f
DL
25 may_only_be_test_must_fail "$2" &&
26 $2 git pull --ff
921f50b4
JL
27}
28
aa06180a 29test_submodule_switch_func "git_pull_ff"
921f50b4
JL
30
31git_pull_ff_only () {
32 reset_branch_to_HEAD "$1" &&
5b0ac09f
DL
33 may_only_be_test_must_fail "$2" &&
34 $2 git pull --ff-only
921f50b4
JL
35}
36
aa06180a 37test_submodule_switch_func "git_pull_ff_only"
921f50b4
JL
38
39git_pull_noff () {
40 reset_branch_to_HEAD "$1" &&
5b0ac09f
DL
41 may_only_be_test_must_fail "$2" &&
42 $2 git pull --no-ff
921f50b4
JL
43}
44
45KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
46KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
aa06180a 47test_submodule_switch_func "git_pull_noff"
921f50b4 48
a6d7eb2c
SB
49test_expect_success 'pull --recurse-submodule setup' '
50 test_create_repo child &&
51 test_commit -C child bar &&
52
53 test_create_repo parent &&
54 test_commit -C child foo &&
55
56 git -C parent submodule add ../child sub &&
57 git -C parent commit -m "add submodule" &&
58
59 git clone --recurse-submodules parent super
60'
61
62test_expect_success 'recursive pull updates working tree' '
63 test_commit -C child merge_strategy &&
64 git -C parent submodule update --remote &&
65 git -C parent add sub &&
66 git -C parent commit -m "update submodule" &&
67
68 git -C super pull --no-rebase --recurse-submodules &&
69 test_path_is_file super/sub/merge_strategy.t
70'
71
121e43fa
NMC
72test_expect_success "submodule.recurse option triggers recursive pull" '
73 test_commit -C child merge_strategy_2 &&
74 git -C parent submodule update --remote &&
75 git -C parent add sub &&
76 git -C parent commit -m "update submodule" &&
77
78 git -C super -c submodule.recurse pull --no-rebase &&
79 test_path_is_file super/sub/merge_strategy_2.t
80'
81
82test_expect_success " --[no-]recurse-submodule and submodule.recurse" '
83 test_commit -C child merge_strategy_3 &&
84 git -C parent submodule update --remote &&
85 git -C parent add sub &&
86 git -C parent commit -m "update submodule" &&
87
88 git -C super -c submodule.recurse pull --no-recurse-submodules --no-rebase &&
89 test_path_is_missing super/sub/merge_strategy_3.t &&
90 git -C super -c submodule.recurse=false pull --recurse-submodules --no-rebase &&
91 test_path_is_file super/sub/merge_strategy_3.t &&
92
93 test_commit -C child merge_strategy_4 &&
94 git -C parent submodule update --remote &&
95 git -C parent add sub &&
96 git -C parent commit -m "update submodule" &&
97
98 git -C super -c submodule.recurse=false pull --no-recurse-submodules --no-rebase &&
99 test_path_is_missing super/sub/merge_strategy_4.t &&
100 git -C super -c submodule.recurse=true pull --recurse-submodules --no-rebase &&
101 test_path_is_file super/sub/merge_strategy_4.t
102'
103
a6d7eb2c
SB
104test_expect_success 'recursive rebasing pull' '
105 # change upstream
106 test_commit -C child rebase_strategy &&
107 git -C parent submodule update --remote &&
108 git -C parent add sub &&
109 git -C parent commit -m "update submodule" &&
110
111 # also have local commits
112 test_commit -C super/sub local_stuff &&
113
114 git -C super pull --rebase --recurse-submodules &&
115 test_path_is_file super/sub/rebase_strategy.t &&
116 test_path_is_file super/sub/local_stuff.t
117'
118
119test_expect_success 'pull rebase recursing fails with conflicts' '
120
121 # local changes in submodule recorded in superproject:
122 test_commit -C super/sub local_stuff_2 &&
123 git -C super add sub &&
124 git -C super commit -m "local update submodule" &&
125
126 # and in the remote as well:
127 test_commit -C child important_upstream_work &&
128 git -C parent submodule update --remote &&
129 git -C parent add sub &&
130 git -C parent commit -m "remote update submodule" &&
131
132 # Unfortunately we fail here, despite no conflict in the
133 # submodule itself, but the merge strategy in submodules
134 # does not support rebase:
135 test_must_fail git -C super pull --rebase --recurse-submodules 2>err &&
136 test_i18ngrep "locally recorded submodule modifications" err
137'
138
4d36f88b
JT
139test_expect_success 'branch has no merge base with remote-tracking counterpart' '
140 rm -rf parent child &&
141
142 test_create_repo a-submodule &&
143 test_commit -C a-submodule foo &&
144
145 test_create_repo parent &&
146 git -C parent submodule add "$(pwd)/a-submodule" &&
147 git -C parent commit -m foo &&
148
149 git clone parent child &&
150
151 # Reset master so that it has no merge base with
152 # refs/remotes/origin/master.
153 OTHER=$(git -C child commit-tree -m bar \
154 $(git -C child rev-parse HEAD^{tree})) &&
155 git -C child reset --hard "$OTHER" &&
156
157 git -C child pull --recurse-submodules --rebase
158'
159
921f50b4 160test_done