From 8c5e33ce11603281f8f42e4de5527cf609cf777e Mon Sep 17 00:00:00 2001 From: Gert van Dijk Date: Thu, 19 Oct 2017 22:38:06 +0200 Subject: [PATCH] For deleting a branch, the "Delete Reference" permission is sufficient. Bug: Issue 7490 Change-Id: Ic7f1bb9793ac42de6857da24149f2f3959259754 --- Documentation/access-control.txt | 2 +- Documentation/project-configuration.txt | 9 ++++++++- .../com/google/gerrit/server/git/ReceiveCommits.java | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/access-control.txt b/Documentation/access-control.txt index f64f739b0c..9a849dcc8c 100644 --- a/Documentation/access-control.txt +++ b/Documentation/access-control.txt @@ -602,7 +602,7 @@ safest mode as commits cannot be discarded. * Force option + -Allows an existing branch to be deleted. Since a force push is +Implies <>. Since a force push is effectively a delete immediately followed by a create, but performed atomically on the server and logged, this option also permits forced push updates to branches. Enabling this option allows existing commits diff --git a/Documentation/project-configuration.txt b/Documentation/project-configuration.txt index 54ddcffd71..2d3fd6609b 100644 --- a/Documentation/project-configuration.txt +++ b/Documentation/project-configuration.txt @@ -272,13 +272,20 @@ There are several ways to delete a branch: - in the Web UI under 'Projects' > 'List' > > 'Branches' - via the link:rest-api-projects.html#delete-branch[Delete Branch] REST endpoint -- by using a git client to force push nothing to an existing branch +- by using a git client ++ +---- + $ git push origin --delete refs/heads/ +---- ++ +another method, by force pushing nothing to an existing branch: + ---- $ git push --force origin :refs/heads/ ---- To be able to delete branches, the user must have the +link:access-control.html#category_delete[Delete Reference] or the link:access-control.html#category_push[Push] access right with the `force` option. In addition, project owners and Gerrit administrators can delete branches from the Web UI or via REST even without having the diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java index 399dfc7a7a..f4659d398b 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java @@ -201,7 +201,8 @@ public class ReceiveCommits { UPDATE( "You are not allowed to perform this operation.\n" + "To push into this reference you need 'Push' rights."), - DELETE("You need 'Push' rights with the 'Force Push'\nflag set to delete references."), + DELETE("You need 'Delete Reference' rights or 'Push' rights with the \n" + + "'Force Push' flag set to delete references."), DELETE_CHANGES("Cannot delete from '" + REFS_CHANGES + "'"), CODE_REVIEW( "You need 'Push' rights to upload code review requests.\n"