]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: fix duplicate remote parallel fetch bug
authorCalvin Wan <calvinwan@google.com>
Thu, 19 Jan 2023 22:05:38 +0000 (22:05 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Jan 2023 22:41:48 +0000 (14:41 -0800)
Fetching in parallel from a remote group with a duplicated remote results
in the following:

error: cannot lock ref '<ref>': is at <oid> but expected <oid>

This doesn't happen in serial since fetching from the same remote that
has already been fetched from is a noop. Therefore, remove any duplicated
remotes after remote groups are parsed.

Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5506-remote-groups.sh

index 7378cafeec9fd6ea3edc521646ab7d8f66bcc02a..12978622d512edab47c19e1291cef42353c59e86 100644 (file)
@@ -2228,6 +2228,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                        argv++;
                }
        }
+       string_list_remove_duplicates(&list, 0);
 
        if (negotiate_only) {
                struct oidset acked_commits = OIDSET_INIT;
index 5bac03ede81b4f964a91df275e3620f9da476c46..0e176175a353571428bcf2ca505fa116564f80a3 100755 (executable)
@@ -99,4 +99,13 @@ test_expect_success 'updating remote name updates that remote' '
        ! repo_fetched two
 '
 
+test_expect_success 'updating group in parallel with a duplicate remote does not fail (fetch)' '
+       mark fetch-group-duplicate &&
+       update_repo one &&
+       git config --add remotes.duplicate one &&
+       git config --add remotes.duplicate one &&
+       git -c fetch.parallel=2 remote update duplicate &&
+       repo_fetched one
+'
+
 test_done