瀏覽代碼

Reject non-fast-forwards earlier in BaseReceivePack

If BaseReceivePack has setAllowNonFastForwards(false) configured
(such as by receive.denynonfastforwards), automatically reject
any command that attempts a non-fast-forward update before it goes
further in processing.

This matches with other checks in validateCommands(), such as the
early failure of delete attempts when isAllowDeletes() is false.

Change-Id: I3bb28e4dd6d17cb31ede09eb84ceb67cdb17ea5d
tags/v2.1.0.201209190230-r
Shawn O. Pearce 12 年之前
父節點
當前提交
04fa307a70
共有 1 個檔案被更改,包括 10 行新增2 行删除
  1. 10
    2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

+ 10
- 2
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java 查看文件

} else { } else {
cmd.setType(ReceiveCommand.Type.UPDATE_NONFASTFORWARD); cmd.setType(ReceiveCommand.Type.UPDATE_NONFASTFORWARD);
} }

if (cmd.getType() == ReceiveCommand.Type.UPDATE_NONFASTFORWARD
&& !isAllowNonFastForwards()) {
cmd.setResult(Result.REJECTED_NONFASTFORWARD);
continue;
}
} }


if (!cmd.getRefName().startsWith(Constants.R_REFS) if (!cmd.getRefName().startsWith(Constants.R_REFS)


/** Execute commands to update references. */ /** Execute commands to update references. */
protected void executeCommands() { protected void executeCommands() {
List<ReceiveCommand> toApply = ReceiveCommand.filter(commands,
Result.NOT_ATTEMPTED);
List<ReceiveCommand> toApply = filterCommands(Result.NOT_ATTEMPTED);
if (toApply.isEmpty())
return;

ProgressMonitor updating = NullProgressMonitor.INSTANCE; ProgressMonitor updating = NullProgressMonitor.INSTANCE;
if (sideBand) { if (sideBand) {
SideBandProgressMonitor pm = new SideBandProgressMonitor(msgOut); SideBandProgressMonitor pm = new SideBandProgressMonitor(msgOut);

Loading…
取消
儲存