Skip to content

Commit

Permalink
fetch: fix duplicate remote parallel fetch bug
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
calvin-wan-google authored and gitster committed Jan 19, 2023
1 parent 844ede3 commit 06a668c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions t/t5506-remote-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 06a668c

Please sign in to comment.