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