Skip to content

Commit 06a668c

Browse files
calvin-wan-googlegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 844ede3 commit 06a668c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

builtin/fetch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
22282228
argv++;
22292229
}
22302230
}
2231+
string_list_remove_duplicates(&list, 0);
22312232

22322233
if (negotiate_only) {
22332234
struct oidset acked_commits = OIDSET_INIT;

t/t5506-remote-groups.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,13 @@ test_expect_success 'updating remote name updates that remote' '
9999
! repo_fetched two
100100
'
101101

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+
102111
test_done

0 commit comments

Comments
 (0)