From 2dcec50d93913957798c5808f584277b29972b3c Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 7 Apr 2014 23:32:48 -0400 Subject: [PATCH] Fix incorrect REWIND labeling in reflog on all ticket pushes --- .../com/gitblit/git/PatchsetReceivePack.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) 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()); -- 2.39.5