Change config pull.rebase=preserve to pull.rebase=merges

The native git option to preserve merge commits during rebase
has been changed from pull.rebase=preserve to pull.rebase=merges.

This changeset in jgit makes the same config change. The old "preserve"
option is no longer recognized and is replaced by new option called
"merges".

This makes jgit's rebase configuration compatible with native git
versions 2.34 and newer where the old "preserve" option has been
removed.

Change-Id: Ic07ff954e258115e76465a1593ef3259f4c418a3
This commit is contained in:
Pavel Salamon 2023-01-12 16:39:07 +01:00 committed by Matthias Sohn
parent 2d0b908048
commit 0518a6b0c1
4 changed files with 23 additions and 19 deletions

View File

@ -378,44 +378,44 @@ public void testPullMergeProgrammaticConfigurationImpliedTargetBranch()
}
private enum TestPullMode {
MERGE, REBASE, REBASE_PREASERVE
MERGE, REBASE, REBASE_MERGES
}
@Test
/** global rebase config should be respected */
public void testPullWithRebasePreserve1Config() throws Exception {
public void testPullWithRebaseMerges1Config() throws Exception {
Callable<PullResult> setup = () -> {
StoredConfig config = dbTarget.getConfig();
config.setString("pull", null, "rebase", "preserve");
config.setString("pull", null, "rebase", "merges");
config.save();
return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
}
@Test
/** the branch-local config should win over the global config */
public void testPullWithRebasePreserveConfig2() throws Exception {
public void testPullWithRebaseMergesConfig2() throws Exception {
Callable<PullResult> setup = () -> {
StoredConfig config = dbTarget.getConfig();
config.setString("pull", null, "rebase", "false");
config.setString("branch", "master", "rebase", "preserve");
config.setString("branch", "master", "rebase", "merges");
config.save();
return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
}
@Test
/** the branch-local config should be respected */
public void testPullWithRebasePreserveConfig3() throws Exception {
public void testPullWithRebaseMergesConfig3() throws Exception {
Callable<PullResult> setup = () -> {
StoredConfig config = dbTarget.getConfig();
config.setString("branch", "master", "rebase", "preserve");
config.setString("branch", "master", "rebase", "merges");
config.save();
return target.pull().call();
};
doTestPullWithRebase(setup, TestPullMode.REBASE_PREASERVE);
doTestPullWithRebase(setup, TestPullMode.REBASE_MERGES);
}
@Test
@ -435,7 +435,7 @@ public void testPullWithRebaseConfig1() throws Exception {
public void testPullWithRebaseConfig2() throws Exception {
Callable<PullResult> setup = () -> {
StoredConfig config = dbTarget.getConfig();
config.setString("pull", null, "rebase", "preserve");
config.setString("pull", null, "rebase", "merges");
config.setString("branch", "master", "rebase", "true");
config.save();
return target.pull().call();
@ -543,7 +543,7 @@ private void doTestPullWithRebase(Callable<PullResult> pullSetup,
assertEquals(sourceCommit, next.getParent(1));
// since both parents are known do no further checks here
} else {
if (expectedPullMode == TestPullMode.REBASE_PREASERVE) {
if (expectedPullMode == TestPullMode.REBASE_MERGES) {
next = rw.next();
assertEquals(2, next.getParentCount());
}

View File

@ -137,8 +137,8 @@ public PullCommand setRebase(boolean useRebase) {
* <dt>BranchRebaseMode.REBASE</dt>
* <dd>Equivalent to {@code --rebase} on the command line: use rebase
* instead of merge after fetching.</dd>
* <dt>BranchRebaseMode.PRESERVE</dt>
* <dd>Equivalent to {@code --preserve-merges} on the command line: rebase
* <dt>BranchRebaseMode.MERGES</dt>
* <dd>Equivalent to {@code --rebase-merges} on the command line: rebase
* preserving local merge commits.</dd>
* <dt>BranchRebaseMode.INTERACTIVE</dt>
* <dd>Equivalent to {@code --interactive} on the command line: use
@ -362,7 +362,7 @@ public PullResult call() throws GitAPIException,
.setStrategy(strategy)
.setContentMergeStrategy(contentStrategy)
.setPreserveMerges(
pullRebaseMode == BranchRebaseMode.PRESERVE)
pullRebaseMode == BranchRebaseMode.MERGES)
.call();
result = new PullResult(fetchRes, remote, rebaseRes);
} else {

View File

@ -151,7 +151,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
/**
* The folder containing the hashes of (potentially) rewritten commits when
* --preserve-merges is used.
* --rebase-merges is used.
* <p>
* Native git rebase --merge uses a <em>file</em> of that name to record
* commits to copy notes at the end of the whole rebase.
@ -160,7 +160,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
private static final String REWRITTEN = "rewritten"; //$NON-NLS-1$
/**
* File containing the current commit(s) to cherry pick when --preserve-merges
* File containing the current commit(s) to cherry pick when --rebase-merges
* is used.
*/
private static final String CURRENT_COMMIT = "current-commit"; //$NON-NLS-1$

View File

@ -30,8 +30,12 @@ public enum BranchRebaseMode implements Config.ConfigEnum {
/** Value for rebasing */
REBASE("true"), //$NON-NLS-1$
/** Value for rebasing preserving local merge commits */
PRESERVE("preserve"), //$NON-NLS-1$
/**
* Value for rebasing preserving local merge commits
*
* @since 6.5 used instead of deprecated "preserve" option
*/
MERGES("merges"), //$NON-NLS-1$
/** Value for rebasing interactively */
INTERACTIVE("interactive"), //$NON-NLS-1$
/** Value for not rebasing at all but merging */