Browse Source

Add missing braces in CherryPickCommand

Change-Id: I4b038ba7f86a45eb52422d3c2b4c4fc30ea16362
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
next
Matthias Sohn 5 years ago
parent
commit
e7a48bce3f
  1. 21
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

21
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

@ -130,9 +130,10 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
// get the head commit // get the head commit
Ref headRef = repo.exactRef(Constants.HEAD); Ref headRef = repo.exactRef(Constants.HEAD);
if (headRef == null) if (headRef == null) {
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
}
newHead = revWalk.parseCommit(headRef.getObjectId()); newHead = revWalk.parseCommit(headRef.getObjectId());
@ -141,8 +142,9 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
// get the commit to be cherry-picked // get the commit to be cherry-picked
// handle annotated tags // handle annotated tags
ObjectId srcObjectId = src.getPeeledObjectId(); ObjectId srcObjectId = src.getPeeledObjectId();
if (srcObjectId == null) if (srcObjectId == null) {
srcObjectId = src.getObjectId(); srcObjectId = src.getObjectId();
}
RevCommit srcCommit = revWalk.parseCommit(srcObjectId); RevCommit srcCommit = revWalk.parseCommit(srcObjectId);
// get the parent of the commit to cherry-pick // get the parent of the commit to cherry-pick
@ -159,25 +161,28 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
cherryPickName }); cherryPickName });
if (merger.merge(newHead, srcCommit)) { if (merger.merge(newHead, srcCommit)) {
if (AnyObjectId.isEqual(newHead.getTree().getId(), if (AnyObjectId.isEqual(newHead.getTree().getId(),
merger.getResultTreeId())) merger.getResultTreeId())) {
continue; continue;
}
DirCacheCheckout dco = new DirCacheCheckout(repo, DirCacheCheckout dco = new DirCacheCheckout(repo,
newHead.getTree(), repo.lockDirCache(), newHead.getTree(), repo.lockDirCache(),
merger.getResultTreeId()); merger.getResultTreeId());
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
dco.setProgressMonitor(monitor); dco.setProgressMonitor(monitor);
dco.checkout(); dco.checkout();
if (!noCommit) if (!noCommit) {
newHead = new Git(getRepository()).commit() newHead = new Git(getRepository()).commit()
.setMessage(srcCommit.getFullMessage()) .setMessage(srcCommit.getFullMessage())
.setReflogComment(reflogPrefix + " " //$NON-NLS-1$ .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
+ srcCommit.getShortMessage()) + srcCommit.getShortMessage())
.setAuthor(srcCommit.getAuthorIdent()) .setAuthor(srcCommit.getAuthorIdent())
.setNoVerify(true).call(); .setNoVerify(true).call();
}
cherryPickedRefs.add(src); cherryPickedRefs.add(src);
} else { } else {
if (merger.failed()) if (merger.failed()) {
return new CherryPickResult(merger.getFailingPaths()); return new CherryPickResult(merger.getFailingPaths());
}
// there are merge conflicts // there are merge conflicts
@ -185,8 +190,9 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
.formatWithConflicts(srcCommit.getFullMessage(), .formatWithConflicts(srcCommit.getFullMessage(),
merger.getUnmergedPaths()); merger.getUnmergedPaths());
if (!noCommit) if (!noCommit) {
repo.writeCherryPickHead(srcCommit.getId()); repo.writeCherryPickHead(srcCommit.getId());
}
repo.writeMergeCommitMsg(message); repo.writeMergeCommitMsg(message);
repo.fireEvent(new WorkingTreeModifiedEvent( repo.fireEvent(new WorkingTreeModifiedEvent(
@ -217,10 +223,11 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
Integer.valueOf(srcCommit.getParentCount()))); Integer.valueOf(srcCommit.getParentCount())));
srcParent = srcCommit.getParent(0); srcParent = srcCommit.getParent(0);
} else { } else {
if (mainlineParentNumber.intValue() > srcCommit.getParentCount()) if (mainlineParentNumber.intValue() > srcCommit.getParentCount()) {
throw new JGitInternalException(MessageFormat.format( throw new JGitInternalException(MessageFormat.format(
JGitText.get().commitDoesNotHaveGivenParent, srcCommit, JGitText.get().commitDoesNotHaveGivenParent, srcCommit,
mainlineParentNumber)); mainlineParentNumber));
}
srcParent = srcCommit srcParent = srcCommit
.getParent(mainlineParentNumber.intValue() - 1); .getParent(mainlineParentNumber.intValue() - 1);
} }

Loading…
Cancel
Save