Skip to content

Fix various UpdateRemoteMirror bugs

Sami Hiltunen requested to merge smh-fix-update-remote-mirror-bugs into master

While porting UpdateRemoteMirror to Go, we came across several existing bugs in the implementation. Now that we have removed the feature flag and we don't have to maintain compatibility between the two implementations in the tests, this MR contains fixes for the various bugs we encountered. I've bundled them all here since the actual fixes are fairly small.

  • Pushing a branch called tag failed. This caused the mirroring to fail when attempting to push the tag with git push <remote> tag as command expected the tags name to follow. The Go port using fully qualified ref names avoids the problem. Closes #3502 (closed).

  • If a branch and tag had the same name, the resulting git push command would be git push <remote> <name> <name>. Git doesn't allow for this and fails with 'src refspec master matches more than one'. This is fixed as the Go Port uses fully qualified reference names. Closes #3504 (closed).

  • Mirroring an empty repository was not possible, as the Ruby implementation didn't handle the case when there are no branches in the repo and would fail with NoMethodError called on a nil object from root_ref. The Go port handles mirroring repository without branches fine. Closes #3503 (closed).

  • Fix a race that leads to diverged refs being force pushed to even with KeepDivergentRefs option set. The RPC compares the refs on the source and the mirror repo, and then force pushed to them. If the refs diverged between the push and the check, they diverged refs would be force pushed over. This is fixed by force pushing only when KeepDivergentRefs is not set. Closes #3505 (closed).

  • The mirroring logic would stumble over symbolic refs in various ways as they were not handled in any special manner. Pushing from/to symbolic refs works fairly weird, and in general there should be no symbolic refs in refs/heads/ or refs/tags/. As such, this MR will ignore symbolic refs in either of the repos. Closes #3508 (closed).

Merge request reports