patchsetRefCmd.setResult(Result.OK);\r
\r
// update the ticket branch ref\r
- RefUpdate ru = updateRef(patchsetCmd.getTicketBranch(), patchsetCmd.getNewId());\r
+ RefUpdate ru = updateRef(\r
+ patchsetCmd.getTicketBranch(),\r
+ patchsetCmd.getNewId(),\r
+ patchsetCmd.getPatchsetType());\r
updateReflog(ru);\r
\r
TicketModel ticket = processPatchset(patchsetCmd);\r
psCmd.updateTicket(c, mergeTo, ticket, null);\r
\r
// create a ticket patchset ref\r
- updateRef(psCmd.getPatchsetBranch(), c.getId());\r
- RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId());\r
+ updateRef(psCmd.getPatchsetBranch(), c.getId(), patchset.type);\r
+ RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId(), patchset.type);\r
updateReflog(ru);\r
\r
// create a change from the patchset command\r
return newPatchset;\r
}\r
\r
- private RefUpdate updateRef(String ref, ObjectId newId) {\r
+ private RefUpdate updateRef(String ref, ObjectId newId, PatchsetType type) {\r
ObjectId ticketRefId = ObjectId.zeroId();\r
try {\r
ticketRefId = getRepository().resolve(ref);\r
try {\r
RefUpdate ru = getRepository().updateRef(ref, false);\r
ru.setRefLogIdent(getRefLogIdent());\r
- ru.setForceUpdate(true);\r
+ switch (type) {\r
+ case Amend:\r
+ case Rebase:\r
+ case Rebase_Squash:\r
+ case Squash:\r
+ ru.setForceUpdate(true);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
ru.setExpectedOldObjectId(ticketRefId);\r
ru.setNewObjectId(newId);\r
RefUpdate.Result result = ru.update(getRevWalk());\r