From: James Moger Date: Tue, 8 Apr 2014 03:32:48 +0000 (-0400) Subject: Fix incorrect REWIND labeling in reflog on all ticket pushes X-Git-Tag: v1.5.0~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2dcec50d93913957798c5808f584277b29972b3c;p=gitblit.git Fix incorrect REWIND labeling in reflog on all ticket pushes --- diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java index 64a739e5..2c3b957b 100644 --- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java +++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java @@ -437,7 +437,10 @@ public class PatchsetReceivePack extends GitblitReceivePack { patchsetRefCmd.setResult(Result.OK); // update the ticket branch ref - RefUpdate ru = updateRef(patchsetCmd.getTicketBranch(), patchsetCmd.getNewId()); + RefUpdate ru = updateRef( + patchsetCmd.getTicketBranch(), + patchsetCmd.getNewId(), + patchsetCmd.getPatchsetType()); updateReflog(ru); TicketModel ticket = processPatchset(patchsetCmd); @@ -835,8 +838,8 @@ public class PatchsetReceivePack extends GitblitReceivePack { psCmd.updateTicket(c, mergeTo, ticket, null); // create a ticket patchset ref - updateRef(psCmd.getPatchsetBranch(), c.getId()); - RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId()); + updateRef(psCmd.getPatchsetBranch(), c.getId(), patchset.type); + RefUpdate ru = updateRef(psCmd.getTicketBranch(), c.getId(), patchset.type); updateReflog(ru); // create a change from the patchset command @@ -1052,7 +1055,7 @@ public class PatchsetReceivePack extends GitblitReceivePack { return newPatchset; } - private RefUpdate updateRef(String ref, ObjectId newId) { + private RefUpdate updateRef(String ref, ObjectId newId, PatchsetType type) { ObjectId ticketRefId = ObjectId.zeroId(); try { ticketRefId = getRepository().resolve(ref); @@ -1063,7 +1066,17 @@ public class PatchsetReceivePack extends GitblitReceivePack { try { RefUpdate ru = getRepository().updateRef(ref, false); ru.setRefLogIdent(getRefLogIdent()); - ru.setForceUpdate(true); + switch (type) { + case Amend: + case Rebase: + case Rebase_Squash: + case Squash: + ru.setForceUpdate(true); + break; + default: + break; + } + ru.setExpectedOldObjectId(ticketRefId); ru.setNewObjectId(newId); RefUpdate.Result result = ru.update(getRevWalk());