Skip to content

Commit 947604d

Browse files
committed
Merge branch 'ew/fetch-no-write-fetch-head-fix'
* ew/fetch-no-write-fetch-head-fix: fetch: pass --no-write-fetch-head to subprocesses
2 parents 9de14c7 + 15184ae commit 947604d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

builtin/fetch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,8 @@ static void add_options_to_argv(struct strvec *argv)
18831883
strvec_push(argv, "--ipv4");
18841884
else if (family == TRANSPORT_FAMILY_IPV6)
18851885
strvec_push(argv, "--ipv6");
1886+
if (!write_fetch_head)
1887+
strvec_push(argv, "--no-write-fetch-head");
18861888
}
18871889

18881890
/* Fetch multiple remotes in parallel */

t/t5514-fetch-multiple.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ test_expect_success 'git fetch --all' '
5858
test_cmp expect output)
5959
'
6060

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+
6168
test_expect_success 'git fetch --all should continue if a remote has errors' '
6269
(git clone one test2 &&
6370
cd test2 &&

t/t5526-fetch-submodules.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
167167
verify_fetch_result actual.err
168168
'
169169

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+
170183
test_expect_success "submodule.recurse option triggers recursive fetch" '
171184
add_submodule_commits &&
172185
(

0 commit comments

Comments
 (0)