fetch: pass --no-write-fetch-head to subprocesses
It seems a user would expect this option would work regardless of whether it's fetching from a single remote, many remotes, or recursing into submodules. Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Mar 8, 2023 at 22:22 UTC
15184ae9da1474908060a5c9b8c6ca88891e415e
3 files changed
+22
builtin/fetch.c
+2
@@ -1880,6 +1880,8 @@ static void add_options_to_argv(struct strvec *argv)
1880
strvec_push(argv, "--ipv4");
1881
else if (family == TRANSPORT_FAMILY_IPV6)
1882
strvec_push(argv, "--ipv6");
1883
+ if (!write_fetch_head)
1884
+ strvec_push(argv, "--no-write-fetch-head");
1885
}
1886
1887
/* Fetch multiple remotes in parallel */
t/t5514-fetch-multiple.sh
+7
@@ -58,6 +58,13 @@ test_expect_success 'git fetch --all' '
58
test_cmp expect output)
59
'
60
61
+test_expect_success 'git fetch --all --no-write-fetch-head' '
62
+ (cd test &&
63
+ rm -f .git/FETCH_HEAD &&
64
+ git fetch --all --no-write-fetch-head &&
65
+ test_path_is_missing .git/FETCH_HEAD)
66
+'
67
+
68
test_expect_success 'git fetch --all should continue if a remote has errors' '
69
(git clone one test2 &&
70
cd test2 &&
t/t5526-fetch-submodules.sh
+13
@@ -167,6 +167,19 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
167
verify_fetch_result actual.err
168
'
169
170
+test_expect_success "fetch --recurse-submodules honors --no-write-fetch-head" '
171
+ (
172
+ cd downstream &&
173
+ git submodule foreach --recursive \
174
+ sh -c "cd \"\$(git rev-parse --git-dir)\" && rm -f FETCH_HEAD" &&
175
+
176
+ git fetch --recurse-submodules --no-write-fetch-head &&
177
+
178
+ git submodule foreach --recursive \
179
+ sh -c "cd \"\$(git rev-parse --git-dir)\" && ! test -f FETCH_HEAD"
180
+ )
181
+'
182
+
183
test_expect_success "submodule.recurse option triggers recursive fetch" '
184
add_submodule_commits &&
185
(