fetch: fix duplicate remote parallel fetch bug

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>

Calvin Wan committed Jan 19, 2023 at 22:05 UTC 06a668cb90a6e8628f295adb6177855bb0a85a4a
2 files changed +10
builtin/fetch.c
+1
@@ -2228,6 +2228,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2228 argv++;
2229 }
2230 }
2231 + string_list_remove_duplicates(&list, 0);
2232
2233 if (negotiate_only) {
2234 struct oidset acked_commits = OIDSET_INIT;
t/t5506-remote-groups.sh
+9
@@ -99,4 +99,13 @@ test_expect_success 'updating remote name updates that remote' '
99 ! repo_fetched two
100 '
101
102 +test_expect_success 'updating group in parallel with a duplicate remote does not fail (fetch)' '
103 + mark fetch-group-duplicate &&
104 + update_repo one &&
105 + git config --add remotes.duplicate one &&
106 + git config --add remotes.duplicate one &&
107 + git -c fetch.parallel=2 remote update duplicate &&
108 + repo_fetched one
109 +'
110 +
111 test_done