You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MergeCommand.java 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * Copyright (C) 2010, Christian Halstrick <christian.halstrick@sap.com>
  3. * Copyright (C) 2010-2012, Stefan Lay <stefan.lay@sap.com>
  4. * and other copyright owners as documented in the project's IP log.
  5. *
  6. * This program and the accompanying materials are made available
  7. * under the terms of the Eclipse Distribution License v1.0 which
  8. * accompanies this distribution, is reproduced below, and is
  9. * available at http://www.eclipse.org/org/documents/edl-v10.php
  10. *
  11. * All rights reserved.
  12. *
  13. * Redistribution and use in source and binary forms, with or
  14. * without modification, are permitted provided that the following
  15. * conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials provided
  23. * with the distribution.
  24. *
  25. * - Neither the name of the Eclipse Foundation, Inc. nor the
  26. * names of its contributors may be used to endorse or promote
  27. * products derived from this software without specific prior
  28. * written permission.
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  31. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  32. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  33. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  34. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  35. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  36. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  37. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  38. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  39. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  42. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43. */
  44. package org.eclipse.jgit.api;
  45. import java.io.IOException;
  46. import java.text.MessageFormat;
  47. import java.util.Arrays;
  48. import java.util.Collections;
  49. import java.util.LinkedList;
  50. import java.util.List;
  51. import java.util.Map;
  52. import org.eclipse.jgit.api.MergeResult.MergeStatus;
  53. import org.eclipse.jgit.api.errors.CheckoutConflictException;
  54. import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
  55. import org.eclipse.jgit.api.errors.GitAPIException;
  56. import org.eclipse.jgit.api.errors.InvalidMergeHeadsException;
  57. import org.eclipse.jgit.api.errors.JGitInternalException;
  58. import org.eclipse.jgit.api.errors.NoHeadException;
  59. import org.eclipse.jgit.api.errors.NoMessageException;
  60. import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
  61. import org.eclipse.jgit.dircache.DirCacheCheckout;
  62. import org.eclipse.jgit.internal.JGitText;
  63. import org.eclipse.jgit.lib.AnyObjectId;
  64. import org.eclipse.jgit.lib.Config.ConfigEnum;
  65. import org.eclipse.jgit.lib.Constants;
  66. import org.eclipse.jgit.lib.ObjectId;
  67. import org.eclipse.jgit.lib.ObjectIdRef;
  68. import org.eclipse.jgit.lib.Ref;
  69. import org.eclipse.jgit.lib.Ref.Storage;
  70. import org.eclipse.jgit.lib.RefUpdate;
  71. import org.eclipse.jgit.lib.RefUpdate.Result;
  72. import org.eclipse.jgit.lib.Repository;
  73. import org.eclipse.jgit.merge.MergeConfig;
  74. import org.eclipse.jgit.merge.MergeMessageFormatter;
  75. import org.eclipse.jgit.merge.MergeStrategy;
  76. import org.eclipse.jgit.merge.Merger;
  77. import org.eclipse.jgit.merge.ResolveMerger;
  78. import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
  79. import org.eclipse.jgit.merge.SquashMessageFormatter;
  80. import org.eclipse.jgit.revwalk.RevCommit;
  81. import org.eclipse.jgit.revwalk.RevWalk;
  82. import org.eclipse.jgit.revwalk.RevWalkUtils;
  83. import org.eclipse.jgit.treewalk.FileTreeIterator;
  84. import org.eclipse.jgit.util.StringUtils;
  85. /**
  86. * A class used to execute a {@code Merge} command. It has setters for all
  87. * supported options and arguments of this command and a {@link #call()} method
  88. * to finally execute the command. Each instance of this class should only be
  89. * used for one invocation of the command (means: one call to {@link #call()})
  90. *
  91. * @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html"
  92. * >Git documentation about Merge</a>
  93. */
  94. public class MergeCommand extends GitCommand<MergeResult> {
  95. private MergeStrategy mergeStrategy = MergeStrategy.RECURSIVE;
  96. private List<Ref> commits = new LinkedList<Ref>();
  97. private Boolean squash;
  98. private FastForwardMode fastForwardMode;
  99. /**
  100. * The modes available for fast forward merges corresponding to the
  101. * <code>--ff</code>, <code>--no-ff</code> and <code>--ff-only</code>
  102. * options under <code>branch.&lt;name&gt;.mergeoptions</code>.
  103. */
  104. public enum FastForwardMode implements ConfigEnum {
  105. /**
  106. * Corresponds to the default --ff option (for a fast forward update the
  107. * branch pointer only).
  108. */
  109. FF,
  110. /**
  111. * Corresponds to the --no-ff option (create a merge commit even for a
  112. * fast forward).
  113. */
  114. NO_FF,
  115. /**
  116. * Corresponds to the --ff-only option (abort unless the merge is a fast
  117. * forward).
  118. */
  119. FF_ONLY;
  120. public String toConfigValue() {
  121. return "--" + name().toLowerCase().replace('_', '-'); //$NON-NLS-1$
  122. }
  123. public boolean matchConfigValue(String in) {
  124. if (StringUtils.isEmptyOrNull(in))
  125. return false;
  126. if (!in.startsWith("--")) //$NON-NLS-1$
  127. return false;
  128. return name().equalsIgnoreCase(in.substring(2).replace('-', '_'));
  129. }
  130. /**
  131. * The modes available for fast forward merges corresponding to the
  132. * options under <code>merge.ff</code>.
  133. */
  134. public enum Merge {
  135. /**
  136. * {@link FastForwardMode#FF}.
  137. */
  138. TRUE,
  139. /**
  140. * {@link FastForwardMode#NO_FF}.
  141. */
  142. FALSE,
  143. /**
  144. * {@link FastForwardMode#FF_ONLY}.
  145. */
  146. ONLY;
  147. /**
  148. * Map from <code>FastForwardMode</code> to
  149. * <code>FastForwardMode.Merge</code>.
  150. *
  151. * @param ffMode
  152. * the <code>FastForwardMode</code> value to be mapped
  153. * @return the mapped <code>FastForwardMode.Merge</code> value
  154. */
  155. public static Merge valueOf(FastForwardMode ffMode) {
  156. switch (ffMode) {
  157. case NO_FF:
  158. return FALSE;
  159. case FF_ONLY:
  160. return ONLY;
  161. default:
  162. return TRUE;
  163. }
  164. }
  165. }
  166. /**
  167. * Map from <code>FastForwardMode.Merge</code> to
  168. * <code>FastForwardMode</code>.
  169. *
  170. * @param ffMode
  171. * the <code>FastForwardMode.Merge</code> value to be mapped
  172. * @return the mapped <code>FastForwardMode</code> value
  173. */
  174. public static FastForwardMode valueOf(FastForwardMode.Merge ffMode) {
  175. switch (ffMode) {
  176. case FALSE:
  177. return NO_FF;
  178. case ONLY:
  179. return FF_ONLY;
  180. default:
  181. return FF;
  182. }
  183. }
  184. }
  185. private Boolean commit;
  186. /**
  187. * @param repo
  188. */
  189. protected MergeCommand(Repository repo) {
  190. super(repo);
  191. }
  192. /**
  193. * Executes the {@code Merge} command with all the options and parameters
  194. * collected by the setter methods (e.g. {@link #include(Ref)}) of this
  195. * class. Each instance of this class should only be used for one invocation
  196. * of the command. Don't call this method twice on an instance.
  197. *
  198. * @return the result of the merge
  199. */
  200. @SuppressWarnings("boxing")
  201. public MergeResult call() throws GitAPIException, NoHeadException,
  202. ConcurrentRefUpdateException, CheckoutConflictException,
  203. InvalidMergeHeadsException, WrongRepositoryStateException, NoMessageException {
  204. checkCallable();
  205. fallBackToConfiguration();
  206. checkParameters();
  207. RevWalk revWalk = null;
  208. DirCacheCheckout dco = null;
  209. try {
  210. Ref head = repo.getRef(Constants.HEAD);
  211. if (head == null)
  212. throw new NoHeadException(
  213. JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
  214. StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$
  215. // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
  216. revWalk = new RevWalk(repo);
  217. // we know for now there is only one commit
  218. Ref ref = commits.get(0);
  219. refLogMessage.append(ref.getName());
  220. // handle annotated tags
  221. ref = repo.peel(ref);
  222. ObjectId objectId = ref.getPeeledObjectId();
  223. if (objectId == null)
  224. objectId = ref.getObjectId();
  225. RevCommit srcCommit = revWalk.lookupCommit(objectId);
  226. ObjectId headId = head.getObjectId();
  227. if (headId == null) {
  228. revWalk.parseHeaders(srcCommit);
  229. dco = new DirCacheCheckout(repo,
  230. repo.lockDirCache(), srcCommit.getTree());
  231. dco.setFailOnConflict(true);
  232. dco.checkout();
  233. RefUpdate refUpdate = repo
  234. .updateRef(head.getTarget().getName());
  235. refUpdate.setNewObjectId(objectId);
  236. refUpdate.setExpectedOldObjectId(null);
  237. refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
  238. if (refUpdate.update() != Result.NEW)
  239. throw new NoHeadException(
  240. JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
  241. setCallable(false);
  242. return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
  243. null, srcCommit }, MergeStatus.FAST_FORWARD,
  244. mergeStrategy, null, null);
  245. }
  246. RevCommit headCommit = revWalk.lookupCommit(headId);
  247. if (revWalk.isMergedInto(srcCommit, headCommit)) {
  248. setCallable(false);
  249. return new MergeResult(headCommit, srcCommit, new ObjectId[] {
  250. headCommit, srcCommit },
  251. MergeStatus.ALREADY_UP_TO_DATE, mergeStrategy, null, null);
  252. } else if (revWalk.isMergedInto(headCommit, srcCommit)
  253. && fastForwardMode != FastForwardMode.NO_FF) {
  254. // FAST_FORWARD detected: skip doing a real merge but only
  255. // update HEAD
  256. refLogMessage.append(": " + MergeStatus.FAST_FORWARD); //$NON-NLS-1$
  257. dco = new DirCacheCheckout(repo,
  258. headCommit.getTree(), repo.lockDirCache(),
  259. srcCommit.getTree());
  260. dco.setFailOnConflict(true);
  261. dco.checkout();
  262. String msg = null;
  263. ObjectId newHead, base = null;
  264. MergeStatus mergeStatus = null;
  265. if (!squash) {
  266. updateHead(refLogMessage, srcCommit, headId);
  267. newHead = base = srcCommit;
  268. mergeStatus = MergeStatus.FAST_FORWARD;
  269. } else {
  270. msg = JGitText.get().squashCommitNotUpdatingHEAD;
  271. newHead = base = headId;
  272. mergeStatus = MergeStatus.FAST_FORWARD_SQUASHED;
  273. List<RevCommit> squashedCommits = RevWalkUtils.find(
  274. revWalk, srcCommit, headCommit);
  275. String squashMessage = new SquashMessageFormatter().format(
  276. squashedCommits, head);
  277. repo.writeSquashCommitMsg(squashMessage);
  278. }
  279. setCallable(false);
  280. return new MergeResult(newHead, base, new ObjectId[] {
  281. headCommit, srcCommit }, mergeStatus, mergeStrategy,
  282. null, msg);
  283. } else {
  284. if (fastForwardMode == FastForwardMode.FF_ONLY) {
  285. return new MergeResult(headCommit, srcCommit,
  286. new ObjectId[] { headCommit, srcCommit },
  287. MergeStatus.ABORTED, mergeStrategy, null, null);
  288. }
  289. String mergeMessage = ""; //$NON-NLS-1$
  290. if (!squash) {
  291. mergeMessage = new MergeMessageFormatter().format(
  292. commits, head);
  293. repo.writeMergeCommitMsg(mergeMessage);
  294. repo.writeMergeHeads(Arrays.asList(ref.getObjectId()));
  295. } else {
  296. List<RevCommit> squashedCommits = RevWalkUtils.find(
  297. revWalk, srcCommit, headCommit);
  298. String squashMessage = new SquashMessageFormatter().format(
  299. squashedCommits, head);
  300. repo.writeSquashCommitMsg(squashMessage);
  301. }
  302. Merger merger = mergeStrategy.newMerger(repo);
  303. boolean noProblems;
  304. Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
  305. Map<String, MergeFailureReason> failingPaths = null;
  306. List<String> unmergedPaths = null;
  307. if (merger instanceof ResolveMerger) {
  308. ResolveMerger resolveMerger = (ResolveMerger) merger;
  309. resolveMerger.setCommitNames(new String[] {
  310. "BASE", "HEAD", ref.getName() }); //$NON-NLS-1$ //$NON-NLS-2$
  311. resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
  312. noProblems = merger.merge(headCommit, srcCommit);
  313. lowLevelResults = resolveMerger
  314. .getMergeResults();
  315. failingPaths = resolveMerger.getFailingPaths();
  316. unmergedPaths = resolveMerger.getUnmergedPaths();
  317. } else
  318. noProblems = merger.merge(headCommit, srcCommit);
  319. refLogMessage.append(": Merge made by "); //$NON-NLS-1$
  320. if (!revWalk.isMergedInto(headCommit, srcCommit))
  321. refLogMessage.append(mergeStrategy.getName());
  322. else
  323. refLogMessage.append("recursive"); //$NON-NLS-1$
  324. refLogMessage.append('.');
  325. if (noProblems) {
  326. dco = new DirCacheCheckout(repo,
  327. headCommit.getTree(), repo.lockDirCache(),
  328. merger.getResultTreeId());
  329. dco.setFailOnConflict(true);
  330. dco.checkout();
  331. String msg = null;
  332. ObjectId newHeadId = null;
  333. MergeStatus mergeStatus = null;
  334. if (!commit && squash) {
  335. mergeStatus = MergeStatus.MERGED_SQUASHED_NOT_COMMITTED;
  336. }
  337. if (!commit && !squash) {
  338. mergeStatus = MergeStatus.MERGED_NOT_COMMITTED;
  339. }
  340. if (commit && !squash) {
  341. newHeadId = new Git(getRepository()).commit()
  342. .setReflogComment(refLogMessage.toString())
  343. .call().getId();
  344. mergeStatus = MergeStatus.MERGED;
  345. }
  346. if (commit && squash) {
  347. msg = JGitText.get().squashCommitNotUpdatingHEAD;
  348. newHeadId = headCommit.getId();
  349. mergeStatus = MergeStatus.MERGED_SQUASHED;
  350. }
  351. return new MergeResult(newHeadId, null,
  352. new ObjectId[] { headCommit.getId(),
  353. srcCommit.getId() }, mergeStatus,
  354. mergeStrategy, null, msg);
  355. } else {
  356. if (failingPaths != null) {
  357. repo.writeMergeCommitMsg(null);
  358. repo.writeMergeHeads(null);
  359. return new MergeResult(null, merger.getBaseCommitId(),
  360. new ObjectId[] {
  361. headCommit.getId(), srcCommit.getId() },
  362. MergeStatus.FAILED, mergeStrategy,
  363. lowLevelResults, failingPaths, null);
  364. } else {
  365. String mergeMessageWithConflicts = new MergeMessageFormatter()
  366. .formatWithConflicts(mergeMessage,
  367. unmergedPaths);
  368. repo.writeMergeCommitMsg(mergeMessageWithConflicts);
  369. return new MergeResult(null, merger.getBaseCommitId(),
  370. new ObjectId[] { headCommit.getId(),
  371. srcCommit.getId() },
  372. MergeStatus.CONFLICTING, mergeStrategy,
  373. lowLevelResults, null);
  374. }
  375. }
  376. }
  377. } catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
  378. List<String> conflicts = (dco == null) ? Collections
  379. .<String> emptyList() : dco.getConflicts();
  380. throw new CheckoutConflictException(conflicts, e);
  381. } catch (IOException e) {
  382. throw new JGitInternalException(
  383. MessageFormat.format(
  384. JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand,
  385. e), e);
  386. } finally {
  387. if (revWalk != null)
  388. revWalk.release();
  389. }
  390. }
  391. private void checkParameters() throws InvalidMergeHeadsException {
  392. if (squash.booleanValue() && fastForwardMode == FastForwardMode.NO_FF) {
  393. throw new JGitInternalException(
  394. JGitText.get().cannotCombineSquashWithNoff);
  395. }
  396. if (commits.size() != 1)
  397. throw new InvalidMergeHeadsException(
  398. commits.isEmpty() ? JGitText.get().noMergeHeadSpecified
  399. : MessageFormat.format(
  400. JGitText.get().mergeStrategyDoesNotSupportHeads,
  401. mergeStrategy.getName(),
  402. Integer.valueOf(commits.size())));
  403. }
  404. /**
  405. * Use values from the configuation if they have not been explicitly defined
  406. * via the setters
  407. */
  408. private void fallBackToConfiguration() {
  409. MergeConfig config = MergeConfig.getConfigForCurrentBranch(repo);
  410. if (squash == null)
  411. squash = Boolean.valueOf(config.isSquash());
  412. if (commit == null)
  413. commit = Boolean.valueOf(config.isCommit());
  414. if (fastForwardMode == null)
  415. fastForwardMode = config.getFastForwardMode();
  416. }
  417. private void updateHead(StringBuilder refLogMessage, ObjectId newHeadId,
  418. ObjectId oldHeadID) throws IOException,
  419. ConcurrentRefUpdateException {
  420. RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
  421. refUpdate.setNewObjectId(newHeadId);
  422. refUpdate.setRefLogMessage(refLogMessage.toString(), false);
  423. refUpdate.setExpectedOldObjectId(oldHeadID);
  424. Result rc = refUpdate.update();
  425. switch (rc) {
  426. case NEW:
  427. case FAST_FORWARD:
  428. return;
  429. case REJECTED:
  430. case LOCK_FAILURE:
  431. throw new ConcurrentRefUpdateException(
  432. JGitText.get().couldNotLockHEAD, refUpdate.getRef(), rc);
  433. default:
  434. throw new JGitInternalException(MessageFormat.format(
  435. JGitText.get().updatingRefFailed, Constants.HEAD,
  436. newHeadId.toString(), rc));
  437. }
  438. }
  439. /**
  440. *
  441. * @param mergeStrategy
  442. * the {@link MergeStrategy} to be used
  443. * @return {@code this}
  444. */
  445. public MergeCommand setStrategy(MergeStrategy mergeStrategy) {
  446. checkCallable();
  447. this.mergeStrategy = mergeStrategy;
  448. return this;
  449. }
  450. /**
  451. * @param commit
  452. * a reference to a commit which is merged with the current head
  453. * @return {@code this}
  454. */
  455. public MergeCommand include(Ref commit) {
  456. checkCallable();
  457. commits.add(commit);
  458. return this;
  459. }
  460. /**
  461. * @param commit
  462. * the Id of a commit which is merged with the current head
  463. * @return {@code this}
  464. */
  465. public MergeCommand include(AnyObjectId commit) {
  466. return include(commit.getName(), commit);
  467. }
  468. /**
  469. * @param name
  470. * a name given to the commit
  471. * @param commit
  472. * the Id of a commit which is merged with the current head
  473. * @return {@code this}
  474. */
  475. public MergeCommand include(String name, AnyObjectId commit) {
  476. return include(new ObjectIdRef.Unpeeled(Storage.LOOSE, name,
  477. commit.copy()));
  478. }
  479. /**
  480. * If <code>true</code>, will prepare the next commit in working tree and
  481. * index as if a real merge happened, but do not make the commit or move the
  482. * HEAD. Otherwise, perform the merge and commit the result.
  483. * <p>
  484. * In case the merge was successful but this flag was set to
  485. * <code>true</code> a {@link MergeResult} with status
  486. * {@link MergeStatus#MERGED_SQUASHED} or
  487. * {@link MergeStatus#FAST_FORWARD_SQUASHED} is returned.
  488. *
  489. * @param squash
  490. * whether to squash commits or not
  491. * @return {@code this}
  492. * @since 2.0
  493. */
  494. public MergeCommand setSquash(boolean squash) {
  495. checkCallable();
  496. this.squash = Boolean.valueOf(squash);
  497. return this;
  498. }
  499. /**
  500. * Sets the fast forward mode.
  501. *
  502. * @param fastForwardMode
  503. * corresponds to the --ff/--no-ff/--ff-only options. --ff is the
  504. * default option.
  505. * @return {@code this}
  506. * @since 2.2
  507. */
  508. public MergeCommand setFastForward(FastForwardMode fastForwardMode) {
  509. checkCallable();
  510. this.fastForwardMode = fastForwardMode;
  511. return this;
  512. }
  513. /**
  514. * Controls whether the merge command should automatically commit after a
  515. * successful merge
  516. *
  517. * @param commit
  518. * <code>true</code> if this command should commit (this is the
  519. * default behavior). <code>false</code> if this command should
  520. * not commit. In case the merge was successful but this flag was
  521. * set to <code>false</code> a {@link MergeResult} with type
  522. * {@link MergeResult} with status
  523. * {@link MergeStatus#MERGED_NOT_COMMITTED} is returned
  524. * @return {@code this}
  525. * @since 3.0
  526. */
  527. public MergeCommand setCommit(boolean commit) {
  528. this.commit = Boolean.valueOf(commit);
  529. return this;
  530. }
  531. }