diff options
author | Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> | 2014-01-18 13:00:08 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-02-14 00:34:01 +0100 |
commit | 48e36d8cb335382b99ec829d0dfe34be71ed49bb (patch) | |
tree | 5f5a90e82b460c6d10d30330354fde59ca04229c /org.eclipse.jgit.test | |
parent | 2b722815c9b6e3f8e50a081404265fb5b56b60e8 (diff) | |
download | jgit-48e36d8cb335382b99ec829d0dfe34be71ed49bb.tar.gz jgit-48e36d8cb335382b99ec829d0dfe34be71ed49bb.zip |
Use branch.<x>.mergeoptions and merge.ff as defaults for merging
Read options that control squashing, whether or not to commit the merge
and regarding fast forwarding from the configuration and use them if no
explicit values for these options have been provided to MergeCommand.
Change-Id: Ifdaed4b5e4adc142657c03c8e78b709a99eeddbd
Signed-off-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index 630bd7dc0d..d30c1911de 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -66,6 +66,7 @@ import java.util.Set; import org.eclipse.jgit.api.MergeCommand.FastForwardMode; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.junit.MockSystemReader; +import org.eclipse.jgit.merge.MergeConfig; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.SystemReader; import org.junit.After; @@ -334,19 +335,27 @@ public class ConfigTest { assertSame(FastForwardMode.FF, c.getEnum( ConfigConstants.CONFIG_BRANCH_SECTION, "side", ConfigConstants.CONFIG_KEY_MERGEOPTIONS, FastForwardMode.FF)); + MergeConfig mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF, mergeConfig.getFastForwardMode()); c = parse("[branch \"side\"]\n\tmergeoptions = --ff-only\n"); assertSame(FastForwardMode.FF_ONLY, c.getEnum( ConfigConstants.CONFIG_BRANCH_SECTION, "side", ConfigConstants.CONFIG_KEY_MERGEOPTIONS, FastForwardMode.FF_ONLY)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF_ONLY, mergeConfig.getFastForwardMode()); c = parse("[branch \"side\"]\n\tmergeoptions = --ff\n"); assertSame(FastForwardMode.FF, c.getEnum( ConfigConstants.CONFIG_BRANCH_SECTION, "side", ConfigConstants.CONFIG_KEY_MERGEOPTIONS, FastForwardMode.FF)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF, mergeConfig.getFastForwardMode()); c = parse("[branch \"side\"]\n\tmergeoptions = --no-ff\n"); assertSame(FastForwardMode.NO_FF, c.getEnum( ConfigConstants.CONFIG_BRANCH_SECTION, "side", ConfigConstants.CONFIG_KEY_MERGEOPTIONS, FastForwardMode.NO_FF)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.NO_FF, mergeConfig.getFastForwardMode()); } @Test @@ -368,18 +377,56 @@ public class ConfigTest { assertSame(FastForwardMode.Merge.TRUE, c.getEnum( ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.TRUE)); + MergeConfig mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF, mergeConfig.getFastForwardMode()); c = parse("[merge]\n\tff = only\n"); assertSame(FastForwardMode.Merge.ONLY, c.getEnum( ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.ONLY)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF_ONLY, mergeConfig.getFastForwardMode()); c = parse("[merge]\n\tff = true\n"); assertSame(FastForwardMode.Merge.TRUE, c.getEnum( ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.TRUE)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF, mergeConfig.getFastForwardMode()); c = parse("[merge]\n\tff = false\n"); assertSame(FastForwardMode.Merge.FALSE, c.getEnum( ConfigConstants.CONFIG_KEY_MERGE, null, ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.FALSE)); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.NO_FF, mergeConfig.getFastForwardMode()); + } + + @Test + public void testCombinedMergeOptions() throws ConfigInvalidException { + Config c = new Config(null); // not set + MergeConfig mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF, mergeConfig.getFastForwardMode()); + assertTrue(mergeConfig.isCommit()); + assertFalse(mergeConfig.isSquash()); + // branch..mergeoptions should win over merge.ff + c = parse("[merge]\n\tff = false\n" + + "[branch \"side\"]\n\tmergeoptions = --ff-only\n"); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF_ONLY, mergeConfig.getFastForwardMode()); + assertTrue(mergeConfig.isCommit()); + assertFalse(mergeConfig.isSquash()); + // merge.ff used for ff setting if not set via mergeoptions + c = parse("[merge]\n\tff = only\n" + + "[branch \"side\"]\n\tmergeoptions = --squash\n"); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF_ONLY, mergeConfig.getFastForwardMode()); + assertTrue(mergeConfig.isCommit()); + assertTrue(mergeConfig.isSquash()); + // mergeoptions wins if it has ff options amongst other options + c = parse("[merge]\n\tff = false\n" + + "[branch \"side\"]\n\tmergeoptions = --ff-only --no-commit\n"); + mergeConfig = c.get(MergeConfig.getParser("side")); + assertSame(FastForwardMode.FF_ONLY, mergeConfig.getFastForwardMode()); + assertFalse(mergeConfig.isCommit()); + assertFalse(mergeConfig.isSquash()); } @Test |