]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: pass --no-write-fetch-head to subprocesses
authorEric Wong <e@80x24.org>
Wed, 8 Mar 2023 22:22:05 +0000 (22:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Mar 2023 19:06:39 +0000 (11:06 -0800)
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>
builtin/fetch.c
t/t5514-fetch-multiple.sh
t/t5526-fetch-submodules.sh

index a09606b472622c133a683513ffdbe184952f2b01..78513f1708219031b41248563117935c95a35479 100644 (file)
@@ -1880,6 +1880,8 @@ static void add_options_to_argv(struct strvec *argv)
                strvec_push(argv, "--ipv4");
        else if (family == TRANSPORT_FAMILY_IPV6)
                strvec_push(argv, "--ipv6");
+       if (!write_fetch_head)
+               strvec_push(argv, "--no-write-fetch-head");
 }
 
 /* Fetch multiple remotes in parallel */
index 54f422ced3241870a40da6714c34564abab7c119..98f034aa77bb243492ea1232549f7d1ec195a152 100755 (executable)
@@ -58,6 +58,13 @@ test_expect_success 'git fetch --all' '
         test_cmp expect output)
 '
 
+test_expect_success 'git fetch --all --no-write-fetch-head' '
+       (cd test &&
+       rm -f .git/FETCH_HEAD &&
+       git fetch --all --no-write-fetch-head &&
+       test_path_is_missing .git/FETCH_HEAD)
+'
+
 test_expect_success 'git fetch --all should continue if a remote has errors' '
        (git clone one test2 &&
         cd test2 &&
index b9546ef8e5e5cd3a734228c4d65ffdb59f568684..dcdbe26a08e1e3db99338a740e10011981b292af 100755 (executable)
@@ -167,6 +167,19 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
        verify_fetch_result actual.err
 '
 
+test_expect_success "fetch --recurse-submodules honors --no-write-fetch-head" '
+       (
+               cd downstream &&
+               git submodule foreach --recursive \
+               sh -c "cd \"\$(git rev-parse --git-dir)\" && rm -f FETCH_HEAD" &&
+
+               git fetch --recurse-submodules --no-write-fetch-head &&
+
+               git submodule foreach --recursive \
+               sh -c "cd \"\$(git rev-parse --git-dir)\" && ! test -f FETCH_HEAD"
+       )
+'
+
 test_expect_success "submodule.recurse option triggers recursive fetch" '
        add_submodule_commits &&
        (