Merge "Honor git-core meaning of receive.denyDeletes allowing tag deletion"
This commit is contained in:
commit
c9a5fdb3cd
|
@ -168,7 +168,8 @@ public Set<String> getCapabilities() {
|
||||||
private boolean allowCreates;
|
private boolean allowCreates;
|
||||||
|
|
||||||
/** Should an incoming transfer permit delete requests? */
|
/** Should an incoming transfer permit delete requests? */
|
||||||
private boolean allowDeletes;
|
private boolean allowAnyDeletes;
|
||||||
|
private boolean allowBranchDeletes;
|
||||||
|
|
||||||
/** Should an incoming transfer permit non-fast-forward requests? */
|
/** Should an incoming transfer permit non-fast-forward requests? */
|
||||||
private boolean allowNonFastForwards;
|
private boolean allowNonFastForwards;
|
||||||
|
@ -258,7 +259,8 @@ protected BaseReceivePack(final Repository into) {
|
||||||
final ReceiveConfig cfg = db.getConfig().get(ReceiveConfig.KEY);
|
final ReceiveConfig cfg = db.getConfig().get(ReceiveConfig.KEY);
|
||||||
objectChecker = cfg.newObjectChecker();
|
objectChecker = cfg.newObjectChecker();
|
||||||
allowCreates = cfg.allowCreates;
|
allowCreates = cfg.allowCreates;
|
||||||
allowDeletes = cfg.allowDeletes;
|
allowAnyDeletes = true;
|
||||||
|
allowBranchDeletes = cfg.allowDeletes;
|
||||||
allowNonFastForwards = cfg.allowNonFastForwards;
|
allowNonFastForwards = cfg.allowNonFastForwards;
|
||||||
allowOfsDelta = cfg.allowOfsDelta;
|
allowOfsDelta = cfg.allowOfsDelta;
|
||||||
advertiseRefsHook = AdvertiseRefsHook.DEFAULT;
|
advertiseRefsHook = AdvertiseRefsHook.DEFAULT;
|
||||||
|
@ -541,7 +543,7 @@ public void setAllowCreates(final boolean canCreate) {
|
||||||
|
|
||||||
/** @return true if the client can request refs to be deleted. */
|
/** @return true if the client can request refs to be deleted. */
|
||||||
public boolean isAllowDeletes() {
|
public boolean isAllowDeletes() {
|
||||||
return allowDeletes;
|
return allowAnyDeletes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,7 +551,25 @@ public boolean isAllowDeletes() {
|
||||||
* true to permit delete ref commands to be processed.
|
* true to permit delete ref commands to be processed.
|
||||||
*/
|
*/
|
||||||
public void setAllowDeletes(final boolean canDelete) {
|
public void setAllowDeletes(final boolean canDelete) {
|
||||||
allowDeletes = canDelete;
|
allowAnyDeletes = canDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the client can delete from {@code refs/heads/}.
|
||||||
|
* @since 3.6
|
||||||
|
*/
|
||||||
|
public boolean isAllowBranchDeletes() {
|
||||||
|
return allowBranchDeletes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param canDelete
|
||||||
|
* true to permit deletion of branches from the
|
||||||
|
* {@code refs/heads/} namespace.
|
||||||
|
* @since 3.6
|
||||||
|
*/
|
||||||
|
public void setAllowBranchDeletes(boolean canDelete) {
|
||||||
|
allowBranchDeletes = canDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1143,12 +1163,18 @@ protected void validateCommands() {
|
||||||
if (cmd.getResult() != Result.NOT_ATTEMPTED)
|
if (cmd.getResult() != Result.NOT_ATTEMPTED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cmd.getType() == ReceiveCommand.Type.DELETE
|
if (cmd.getType() == ReceiveCommand.Type.DELETE) {
|
||||||
&& !isAllowDeletes()) {
|
if (!isAllowDeletes()) {
|
||||||
// Deletes are not supported on this repository.
|
// Deletes are not supported on this repository.
|
||||||
//
|
cmd.setResult(Result.REJECTED_NODELETE);
|
||||||
cmd.setResult(Result.REJECTED_NODELETE);
|
continue;
|
||||||
continue;
|
}
|
||||||
|
if (!isAllowBranchDeletes()
|
||||||
|
&& ref.getName().startsWith(Constants.R_HEADS)) {
|
||||||
|
// Branches cannot be deleted, but other refs can.
|
||||||
|
cmd.setResult(Result.REJECTED_NODELETE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.getType() == ReceiveCommand.Type.CREATE) {
|
if (cmd.getType() == ReceiveCommand.Type.CREATE) {
|
||||||
|
|
Loading…
Reference in New Issue