From e7a48bce3fb0aba2861e59f5fb5eb0e017162275 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Tue, 24 Sep 2019 00:16:32 +0200 Subject: [PATCH] Add missing braces in CherryPickCommand Change-Id: I4b038ba7f86a45eb52422d3c2b4c4fc30ea16362 Signed-off-by: Matthias Sohn --- .../eclipse/jgit/api/CherryPickCommand.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java index 15352ec73..9573d2e21 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java @@ -130,9 +130,10 @@ public class CherryPickCommand extends GitCommand { // get the head commit Ref headRef = repo.exactRef(Constants.HEAD); - if (headRef == null) + if (headRef == null) { throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); + } newHead = revWalk.parseCommit(headRef.getObjectId()); @@ -141,8 +142,9 @@ public class CherryPickCommand extends GitCommand { // get the commit to be cherry-picked // handle annotated tags ObjectId srcObjectId = src.getPeeledObjectId(); - if (srcObjectId == null) + if (srcObjectId == null) { srcObjectId = src.getObjectId(); + } RevCommit srcCommit = revWalk.parseCommit(srcObjectId); // get the parent of the commit to cherry-pick @@ -159,25 +161,28 @@ public class CherryPickCommand extends GitCommand { cherryPickName }); if (merger.merge(newHead, srcCommit)) { if (AnyObjectId.isEqual(newHead.getTree().getId(), - merger.getResultTreeId())) + merger.getResultTreeId())) { continue; + } DirCacheCheckout dco = new DirCacheCheckout(repo, newHead.getTree(), repo.lockDirCache(), merger.getResultTreeId()); dco.setFailOnConflict(true); dco.setProgressMonitor(monitor); dco.checkout(); - if (!noCommit) + if (!noCommit) { newHead = new Git(getRepository()).commit() .setMessage(srcCommit.getFullMessage()) .setReflogComment(reflogPrefix + " " //$NON-NLS-1$ + srcCommit.getShortMessage()) .setAuthor(srcCommit.getAuthorIdent()) .setNoVerify(true).call(); + } cherryPickedRefs.add(src); } else { - if (merger.failed()) + if (merger.failed()) { return new CherryPickResult(merger.getFailingPaths()); + } // there are merge conflicts @@ -185,8 +190,9 @@ public class CherryPickCommand extends GitCommand { .formatWithConflicts(srcCommit.getFullMessage(), merger.getUnmergedPaths()); - if (!noCommit) + if (!noCommit) { repo.writeCherryPickHead(srcCommit.getId()); + } repo.writeMergeCommitMsg(message); repo.fireEvent(new WorkingTreeModifiedEvent( @@ -217,10 +223,11 @@ public class CherryPickCommand extends GitCommand { Integer.valueOf(srcCommit.getParentCount()))); srcParent = srcCommit.getParent(0); } else { - if (mainlineParentNumber.intValue() > srcCommit.getParentCount()) + if (mainlineParentNumber.intValue() > srcCommit.getParentCount()) { throw new JGitInternalException(MessageFormat.format( JGitText.get().commitDoesNotHaveGivenParent, srcCommit, mainlineParentNumber)); + } srcParent = srcCommit .getParent(mainlineParentNumber.intValue() - 1); }