From aa7be667bcca4bdb28b2485e28a05da54c431df7 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 25 Mar 2013 03:39:58 +0100 Subject: [PATCH] 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 --- .../tst/org/eclipse/jgit/pgm/MergeTest.java | 2 +- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java | 2 +- .../src/org/eclipse/jgit/api/CherryPickCommand.java | 2 +- .../src/org/eclipse/jgit/api/MergeCommand.java | 2 +- .../src/org/eclipse/jgit/api/RevertCommand.java | 7 ++++--- .../src/org/eclipse/jgit/api/StashApplyCommand.java | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeTest.java index d0b363baa..8c5066af5 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeTest.java +++ b/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.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]); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java index 0a149016e..24794e75f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java +++ b/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") private boolean noCommit = false; - private MergeStrategy mergeStrategy = MergeStrategy.RESOLVE; + private MergeStrategy mergeStrategy = MergeStrategy.RECURSIVE; @Argument(required = true) private String ref; 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 dca7197d1..d5d955929 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java @@ -150,7 +150,7 @@ public class CherryPickCommand extends GitCommand { String cherryPickName = srcCommit.getId().abbreviate(7).name() + " " + srcCommit.getShortMessage(); //$NON-NLS-1$ - ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE + ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE .newMerger(repo); merger.setWorkingTreeIterator(new FileTreeIterator(repo)); merger.setBase(srcParent.getTree()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index 8f6e9cbb5..509203e52 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/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 { - private MergeStrategy mergeStrategy = MergeStrategy.RESOLVE; + private MergeStrategy mergeStrategy = MergeStrategy.RECURSIVE; private List commits = new LinkedList(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java index be8f66de3..c3922099d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java @@ -160,7 +160,7 @@ public class RevertCommand extends GitCommand { String revertName = srcCommit.getId().abbreviate(7).name() + " " + srcCommit.getShortMessage(); //$NON-NLS-1$ - ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE + ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE .newMerger(repo); merger.setWorkingTreeIterator(new FileTreeIterator(repo)); merger.setBase(srcCommit.getTree()); @@ -194,14 +194,15 @@ public class RevertCommand extends GitCommand { merger.getBaseCommit(0, 1), new ObjectId[] { headCommit.getId(), srcParent.getId() }, - MergeStatus.FAILED, MergeStrategy.RESOLVE, + MergeStatus.FAILED, MergeStrategy.RECURSIVE, merger.getMergeResults(), failingPaths, null); else failingResult = new MergeResult(null, merger.getBaseCommit(0, 1), new ObjectId[] { headCommit.getId(), srcParent.getId() }, - MergeStatus.CONFLICTING, MergeStrategy.RESOLVE, + MergeStatus.CONFLICTING, + MergeStrategy.RECURSIVE, merger.getMergeResults(), failingPaths, null); if (!merger.failed() && !unmergedPaths.isEmpty()) { String message = new MergeMessageFormatter() diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java index f51560908..b1fde1dc4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java @@ -168,7 +168,7 @@ public class StashApplyCommand extends GitCommand { .getParent(1)); ObjectId stashHeadCommit = stashCommit.getParent(0); - ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE + ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE .newMerger(repo); merger.setCommitNames(new String[] { "stashed HEAD", "HEAD", "stash" }); @@ -181,7 +181,7 @@ public class StashApplyCommand extends GitCommand { dco.setFailOnConflict(true); dco.checkout(); // Ignoring failed deletes.... if (applyIndex) { - ResolveMerger ixMerger = (ResolveMerger) MergeStrategy.RESOLVE + ResolveMerger ixMerger = (ResolveMerger) MergeStrategy.RECURSIVE .newMerger(repo, true); ixMerger.setCommitNames(new String[] { "stashed HEAD", "HEAD", "stashed index" });