private void Execute(ReceiveCommand cmd) { try { RefUpdate ru = db.UpdateRef(cmd.getRefName()); ru.RefLogIdent = getRefLogIdent(); switch (cmd.getType()) { case ReceiveCommand.Type.DELETE: if (!ObjectId.ZeroId.Equals(cmd.getOldId())) { ru.ExpectedOldObjectId = cmd.getOldId(); } ru.IsForceUpdate = true; Status(cmd, ru.Delete(walk)); break; case ReceiveCommand.Type.CREATE: case ReceiveCommand.Type.UPDATE: case ReceiveCommand.Type.UPDATE_NONFASTFORWARD: ru.IsForceUpdate = isAllowNonFastForwards(); ru.ExpectedOldObjectId = cmd.getOldId(); ru.NewObjectId = cmd.getNewId(); ru.SetRefLogMessage("push", true); Status(cmd, ru.Update(walk)); break; } } catch (IOException err) { cmd.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, "lock error: " + err.Message); } }
private void RecvCommands() { while (true) { string line; try { line = pckIn.ReadStringRaw(); } catch (EndOfStreamException) { if (commands.isEmpty()) { return; } throw; } if (line == PacketLineIn.END) { break; } if (commands.isEmpty()) { int nul = line.IndexOf('\0'); if (nul >= 0) { foreach (string c in line.Substring(nul + 1).Split(' ')) { enabledCapabilities.Add(c); } line = line.Slice(0, nul); } } if (line.Length < 83) { string m = "error: invalid protocol: wanted 'old new ref'"; sendError(m); throw new PackProtocolException(m); } ObjectId oldId = ObjectId.FromString(line.Slice(0, 40)); ObjectId newId = ObjectId.FromString(line.Slice(41, 81)); string name = line.Substring(82); var cmd = new ReceiveCommand(oldId, newId, name); if (name.Equals(Constants.HEAD)) { cmd.setResult(ReceiveCommand.Result.REJECTED_CURRENT_BRANCH); } else { cmd.setRef(refs.get(cmd.getRefName())); } commands.Add(cmd); } }
private void Execute(ReceiveCommand cmd) { try { RefUpdate ru = db.UpdateRef(cmd.getRefName()); ru.setRefLogIdent(getRefLogIdent()); switch (cmd.getType()) { case ReceiveCommand.Type.DELETE: if (!ObjectId.ZeroId.Equals(cmd.getOldId())) { // We can only do a CAS style delete if the client // didn't bork its delete request by sending the // wrong zero id rather than the advertised one. // ru.setExpectedOldObjectId(cmd.getOldId()); } ru.setForceUpdate(true); Status(cmd, ru.delete(walk)); break; case ReceiveCommand.Type.CREATE: case ReceiveCommand.Type.UPDATE: case ReceiveCommand.Type.UPDATE_NONFASTFORWARD: ru.setForceUpdate(isAllowNonFastForwards()); ru.setExpectedOldObjectId(cmd.getOldId()); ru.setNewObjectId(cmd.getNewId()); ru.setRefLogMessage("push", true); Status(cmd, ru.update(walk)); break; } } catch (IOException err) { cmd.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, "lock error: " + err.Message); } }
private void RecvCommands() { while (true) { string line; try { line = pckIn.ReadStringRaw(); } catch (EndOfStreamException) { if (commands.isEmpty()) { return; } throw; } if (commands.isEmpty()) { int nul = line.IndexOf('\0'); if (nul >= 0) { foreach (string c in line.Substring(nul + 1).Split(' ')) { enabledCapabilities.Add(c); } line = line.Slice(0, nul); } } if (line.Length == 0) break; if (line.Length < 83) { string m = "error: invalid protocol: wanted 'old new ref'"; sendError(m); throw new PackProtocolException(m); } ObjectId oldId = ObjectId.FromString(line.Slice(0, 40)); ObjectId newId = ObjectId.FromString(line.Slice(41, 81)); string name = line.Substring(82); var cmd = new ReceiveCommand(oldId, newId, name); cmd.setRef(refs[cmd.getRefName()]); commands.Add(cmd); } }