Fix: 'internal server error' when pushing the same commit twice

On the second push of the same commit to 'refs/for/<branch name>', Gerrit
returns 'no new changes'.

However if the user pushes to 'refs/changes/<change id>', Gerrit returns
'internal server error'.

The reason is ReceiveCommits$ReplaceRequest.validate() checks
'squash commits first' ahead of 'commit already exists' and
ReceiveCommits.insertChangesAndPatchSets() replaces the error message
with 'internal server error' without any checking.

Bug: Issue 1702
Change-Id: I18ee961b289b2f8eaca17db58432eb7d57b90e76
1 file changed