Browse Source

Make recursive merge strategy the default merge strategy

Use recursive merge as the default strategy since it can successfully
merge more cases than the resolve strategy can. This is also the default
in native Git.

Change-Id: I38fd522edb2791f15d83e99038185edb09fed8e1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-3.0
Matthias Sohn 12 years ago
parent
commit
aa7be667bc
  1. 2
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeTest.java
  2. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  5. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
  6. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java

2
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeTest.java

@ -97,7 +97,7 @@ public class MergeTest extends CLIRepositoryTestCase {
git.add().addFilepattern("side").call(); git.add().addFilepattern("side").call();
git.commit().setMessage("side commit").call(); git.commit().setMessage("side commit").call();
assertEquals("Merge made by the '" + MergeStrategy.RESOLVE.getName() assertEquals("Merge made by the '" + MergeStrategy.RECURSIVE.getName()
+ "' strategy.", execute("git merge master")[0]); + "' strategy.", execute("git merge master")[0]);
} }

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java

@ -75,7 +75,7 @@ class Merge extends TextBuiltin {
@Option(name = "--no-commit", usage = "usage_noCommit") @Option(name = "--no-commit", usage = "usage_noCommit")
private boolean noCommit = false; private boolean noCommit = false;
private MergeStrategy mergeStrategy = MergeStrategy.RESOLVE; private MergeStrategy mergeStrategy = MergeStrategy.RECURSIVE;
@Argument(required = true) @Argument(required = true)
private String ref; private String ref;

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

@ -150,7 +150,7 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
String cherryPickName = srcCommit.getId().abbreviate(7).name() String cherryPickName = srcCommit.getId().abbreviate(7).name()
+ " " + srcCommit.getShortMessage(); //$NON-NLS-1$ + " " + srcCommit.getShortMessage(); //$NON-NLS-1$
ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE
.newMerger(repo); .newMerger(repo);
merger.setWorkingTreeIterator(new FileTreeIterator(repo)); merger.setWorkingTreeIterator(new FileTreeIterator(repo));
merger.setBase(srcParent.getTree()); merger.setBase(srcParent.getTree());

2
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java

@ -95,7 +95,7 @@ import org.eclipse.jgit.util.StringUtils;
*/ */
public class MergeCommand extends GitCommand<MergeResult> { public class MergeCommand extends GitCommand<MergeResult> {
private MergeStrategy mergeStrategy = MergeStrategy.RESOLVE; private MergeStrategy mergeStrategy = MergeStrategy.RECURSIVE;
private List<Ref> commits = new LinkedList<Ref>(); private List<Ref> commits = new LinkedList<Ref>();

7
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java

@ -160,7 +160,7 @@ public class RevertCommand extends GitCommand<RevCommit> {
String revertName = srcCommit.getId().abbreviate(7).name() String revertName = srcCommit.getId().abbreviate(7).name()
+ " " + srcCommit.getShortMessage(); //$NON-NLS-1$ + " " + srcCommit.getShortMessage(); //$NON-NLS-1$
ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE
.newMerger(repo); .newMerger(repo);
merger.setWorkingTreeIterator(new FileTreeIterator(repo)); merger.setWorkingTreeIterator(new FileTreeIterator(repo));
merger.setBase(srcCommit.getTree()); merger.setBase(srcCommit.getTree());
@ -194,14 +194,15 @@ public class RevertCommand extends GitCommand<RevCommit> {
merger.getBaseCommit(0, 1), merger.getBaseCommit(0, 1),
new ObjectId[] { headCommit.getId(), new ObjectId[] { headCommit.getId(),
srcParent.getId() }, srcParent.getId() },
MergeStatus.FAILED, MergeStrategy.RESOLVE, MergeStatus.FAILED, MergeStrategy.RECURSIVE,
merger.getMergeResults(), failingPaths, null); merger.getMergeResults(), failingPaths, null);
else else
failingResult = new MergeResult(null, failingResult = new MergeResult(null,
merger.getBaseCommit(0, 1), merger.getBaseCommit(0, 1),
new ObjectId[] { headCommit.getId(), new ObjectId[] { headCommit.getId(),
srcParent.getId() }, srcParent.getId() },
MergeStatus.CONFLICTING, MergeStrategy.RESOLVE, MergeStatus.CONFLICTING,
MergeStrategy.RECURSIVE,
merger.getMergeResults(), failingPaths, null); merger.getMergeResults(), failingPaths, null);
if (!merger.failed() && !unmergedPaths.isEmpty()) { if (!merger.failed() && !unmergedPaths.isEmpty()) {
String message = new MergeMessageFormatter() String message = new MergeMessageFormatter()

4
org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java

@ -168,7 +168,7 @@ public class StashApplyCommand extends GitCommand<ObjectId> {
.getParent(1)); .getParent(1));
ObjectId stashHeadCommit = stashCommit.getParent(0); ObjectId stashHeadCommit = stashCommit.getParent(0);
ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE
.newMerger(repo); .newMerger(repo);
merger.setCommitNames(new String[] { "stashed HEAD", "HEAD", merger.setCommitNames(new String[] { "stashed HEAD", "HEAD",
"stash" }); "stash" });
@ -181,7 +181,7 @@ public class StashApplyCommand extends GitCommand<ObjectId> {
dco.setFailOnConflict(true); dco.setFailOnConflict(true);
dco.checkout(); // Ignoring failed deletes.... dco.checkout(); // Ignoring failed deletes....
if (applyIndex) { if (applyIndex) {
ResolveMerger ixMerger = (ResolveMerger) MergeStrategy.RESOLVE ResolveMerger ixMerger = (ResolveMerger) MergeStrategy.RECURSIVE
.newMerger(repo, true); .newMerger(repo, true);
ixMerger.setCommitNames(new String[] { "stashed HEAD", ixMerger.setCommitNames(new String[] { "stashed HEAD",
"HEAD", "stashed index" }); "HEAD", "stashed index" });

Loading…
Cancel
Save