Fix error message for rejecting a push to a change of another project

Users can still upload a new patch set by explicitly pushing a commit
to a change by specifying it as target ref. E.g.:
git push origin HEAD:refs/changes/711

If the specified change belongs to another project, Gerrit rejects
the push with the error message "change ... not found". This error
message is incorrect since the change actually exists in Gerrit.

This change now provides a better error message for this case:
"change ... does not belong to project ...".
In addition it adds a documentation page that explains this error.

Change-Id: I806acba774f8a1c6c0a6439e92314993f0ab4289
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2011-03-17 15:22:50 +01:00
parent 78ea8756d3
commit 3fc69ca36a
3 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,16 @@
change ... does not belong to project ...
=========================================
With this error message Gerrit rejects to push a commit to a change
that belongs to another project.
This error message means that the user explicitly pushed a commit to
a change that belongs to another project by specifying it as target
ref. This way of adding a new patch set to a change is deprecated as
explained link:user-upload.html#manual_replacement_mapping[here]. It is recommended to only rely on Change-ID's for
link:user-upload.html#push_replace[replacing changes].
GERRIT
------
Part of link:error-messages.html[Gerrit Error Messages]

View File

@ -11,6 +11,7 @@ Error Messages
* link:error-branch-not-found.html[branch ... not found]
* link:error-change-closed.html[change ... closed]
* link:error-change-does-not-belong-to-project.html[change ... does not belong to project ...]
* link:error-change-not-found.html[change ... not found]
* link:error-invalid-changeid.html[invalid Change-Id line format in commit message]
* link:error-missing-changeid.html[missing Change-Id in commit message]

View File

@ -774,7 +774,7 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
return;
}
if (!project.getNameKey().equals(changeEnt.getProject())) {
reject(cmd, "change " + changeId + " not found");
reject(cmd, "change " + changeId + " does not belong to project " + project.getName());
return;
}