Parse pull.rebase=preserve as alias for pull.rebase=merges
This ensures backwards compatibility to the old config value which was removed in git 2.34 which JGit followed in Ic07ff954e2. Change-Id: I2b4e27fd71898b6e0e227e406c40682bd9786cd4
This commit is contained in:
parent
06b40b95c2
commit
032eef5b12
|
@ -393,6 +393,21 @@ public void testPullWithRebaseMerges1Config() throws Exception {
|
||||||
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
|
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
/**
|
||||||
|
* global rebase config using old "preserve" value which was renamed to
|
||||||
|
* "merges" should be respected to ensure backwards compatibility
|
||||||
|
*/
|
||||||
|
public void testPullWithRebaseMerges1ConfigAlias() throws Exception {
|
||||||
|
Callable<PullResult> setup = () -> {
|
||||||
|
StoredConfig config = dbTarget.getConfig();
|
||||||
|
config.setString("pull", null, "rebase", "preserve");
|
||||||
|
config.save();
|
||||||
|
return target.pull().call();
|
||||||
|
};
|
||||||
|
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
/** the branch-local config should win over the global config */
|
/** the branch-local config should win over the global config */
|
||||||
public void testPullWithRebaseMergesConfig2() throws Exception {
|
public void testPullWithRebaseMergesConfig2() throws Exception {
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
|
import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BranchConfigTest {
|
public class BranchConfigTest {
|
||||||
|
@ -113,6 +115,38 @@ public void getTrackingBranchShouldHandleNormalCaseForRemoteTrackingBranch() {
|
||||||
branchConfig.getTrackingBranch());
|
branchConfig.getTrackingBranch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRebaseMode() {
|
||||||
|
Config c = parse("" //
|
||||||
|
+ "[branch \"undefined\"]\n"
|
||||||
|
+ "[branch \"false\"]\n"
|
||||||
|
+ " rebase = false\n"
|
||||||
|
+ "[branch \"true\"]\n"
|
||||||
|
+ " rebase = true\n"
|
||||||
|
+ "[branch \"interactive\"]\n"
|
||||||
|
+ " rebase = interactive\n"
|
||||||
|
+ "[branch \"merges\"]\n"
|
||||||
|
+ " rebase = merges\n"
|
||||||
|
+ "[branch \"preserve\"]\n"
|
||||||
|
+ " rebase = preserve\n"
|
||||||
|
+ "[branch \"illegal\"]\n"
|
||||||
|
+ " rebase = illegal\n");
|
||||||
|
assertEquals(BranchRebaseMode.NONE,
|
||||||
|
new BranchConfig(c, " undefined").getRebaseMode());
|
||||||
|
assertEquals(BranchRebaseMode.NONE,
|
||||||
|
new BranchConfig(c, "false").getRebaseMode());
|
||||||
|
assertEquals(BranchRebaseMode.REBASE,
|
||||||
|
new BranchConfig(c, "true").getRebaseMode());
|
||||||
|
assertEquals(BranchRebaseMode.INTERACTIVE,
|
||||||
|
new BranchConfig(c, "interactive").getRebaseMode());
|
||||||
|
assertEquals(BranchRebaseMode.MERGES,
|
||||||
|
new BranchConfig(c, "merges").getRebaseMode());
|
||||||
|
assertEquals(BranchRebaseMode.MERGES,
|
||||||
|
new BranchConfig(c, "preserve").getRebaseMode());
|
||||||
|
assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> new BranchConfig(c, "illegal").getRebaseMode());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isRebase() {
|
public void isRebase() {
|
||||||
Config c = parse("" //
|
Config c = parse("" //
|
||||||
|
@ -120,11 +154,20 @@ public void isRebase() {
|
||||||
+ "[branch \"false\"]\n"
|
+ "[branch \"false\"]\n"
|
||||||
+ " rebase = false\n"
|
+ " rebase = false\n"
|
||||||
+ "[branch \"true\"]\n"
|
+ "[branch \"true\"]\n"
|
||||||
+ " rebase = true\n");
|
+ " rebase = true\n"
|
||||||
|
+ "[branch \"interactive\"]\n"
|
||||||
|
+ " rebase = interactive\n"
|
||||||
|
+ "[branch \"merges\"]\n"
|
||||||
|
+ " rebase = merges\n"
|
||||||
|
+ "[branch \"preserve\"]\n"
|
||||||
|
+ " rebase = preserve\n");
|
||||||
|
|
||||||
assertFalse(new BranchConfig(c, "undefined").isRebase());
|
assertFalse(new BranchConfig(c, "undefined").isRebase());
|
||||||
assertFalse(new BranchConfig(c, "false").isRebase());
|
assertFalse(new BranchConfig(c, "false").isRebase());
|
||||||
assertTrue(new BranchConfig(c, "true").isRebase());
|
assertTrue(new BranchConfig(c, "true").isRebase());
|
||||||
|
assertTrue(new BranchConfig(c, "interactive").isRebase());
|
||||||
|
assertTrue(new BranchConfig(c, "merges").isRebase());
|
||||||
|
assertTrue(new BranchConfig(c, "preserve").isRebase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Config parse(String content) {
|
private static Config parse(String content) {
|
||||||
|
|
|
@ -35,7 +35,12 @@ public enum BranchRebaseMode implements Config.ConfigEnum {
|
||||||
*
|
*
|
||||||
* @since 6.5 used instead of deprecated "preserve" option
|
* @since 6.5 used instead of deprecated "preserve" option
|
||||||
*/
|
*/
|
||||||
MERGES("merges"), //$NON-NLS-1$
|
MERGES("merges"){ //$NON-NLS-1$
|
||||||
|
@Override
|
||||||
|
public boolean matchConfigValue(String s) {
|
||||||
|
return super.matchConfigValue(s) || "preserve".equals(s); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
},
|
||||||
/** Value for rebasing interactively */
|
/** Value for rebasing interactively */
|
||||||
INTERACTIVE("interactive"), //$NON-NLS-1$
|
INTERACTIVE("interactive"), //$NON-NLS-1$
|
||||||
/** Value for not rebasing at all but merging */
|
/** Value for not rebasing at all but merging */
|
||||||
|
|
Loading…
Reference in New Issue