aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-04-28 15:22:52 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2023-04-28 15:22:52 -0400
commit2277f130416bb2a551ce77f36f062bc8145e617c (patch)
tree28a2cb9b509cb0cb74a8f3fc16c11b93bc643483 /org.eclipse.jgit.test
parenta4891f9f4991a7b9d006e0eb30bea783dd978d2e (diff)
parent4d9db14a5e31cd87128a059d96408062c0289040 (diff)
downloadjgit-2277f130416bb2a551ce77f36f062bc8145e617c.tar.gz
jgit-2277f130416bb2a551ce77f36f062bc8145e617c.zip
Merge "Merge branch 'stable-6.5'"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/BUILD17
-rw-r--r--org.eclipse.jgit.test/tests.bzl6
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java15
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java45
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java69
5 files changed, 151 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/BUILD b/org.eclipse.jgit.test/BUILD
index 258e84551a..5066808f6a 100644
--- a/org.eclipse.jgit.test/BUILD
+++ b/org.eclipse.jgit.test/BUILD
@@ -52,6 +52,23 @@ tests(tests = glob(
exclude = HELPERS + DATA + EXCLUDED,
))
+# Non abstract base classes used for tests by other test classes
+BASE = [
+ PKG + "internal/storage/file/FileRepositoryBuilderTest.java",
+ PKG + "internal/storage/file/RefDirectoryTest.java",
+]
+
+java_library(
+ name = "base",
+ testonly = 1,
+ srcs = BASE,
+ deps = [
+ "//lib:junit",
+ "//org.eclipse.jgit:jgit",
+ "//org.eclipse.jgit.junit:junit",
+ ],
+)
+
java_library(
name = "helpers",
testonly = 1,
diff --git a/org.eclipse.jgit.test/tests.bzl b/org.eclipse.jgit.test/tests.bzl
index e201bdbcb3..170bf0c460 100644
--- a/org.eclipse.jgit.test/tests.bzl
+++ b/org.eclipse.jgit.test/tests.bzl
@@ -52,6 +52,12 @@ def tests(tests):
"//lib:xz",
"//org.eclipse.jgit.archive:jgit-archive",
]
+ if src.endswith("FileRepositoryBuilderAfterOpenConfigTest.java") or \
+ src.endswith("RefDirectoryAfterOpenConfigTest.java") or \
+ src.endswith("SnapshottingRefDirectoryTest.java"):
+ additional_deps = [
+ ":base",
+ ]
heap_size = "-Xmx256m"
if src.endswith("HugeCommitMessageTest.java"):
heap_size = "-Xmx512m"
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
index 7a0ffdbeca..12300b3390 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
@@ -394,6 +394,21 @@ public class PullCommandTest extends RepositoryTestCase {
}
@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
/** the branch-local config should win over the global config */
public void testPullWithRebaseMergesConfig2() throws Exception {
Callable<PullResult> setup = () -> {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java
index 1374ea2619..2c9097f377 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/BranchConfigTest.java
@@ -14,9 +14,11 @@ package org.eclipse.jgit.lib;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode;
import org.junit.Test;
public class BranchConfigTest {
@@ -114,17 +116,58 @@ public class BranchConfigTest {
}
@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
public void isRebase() {
Config c = parse("" //
+ "[branch \"undefined\"]\n"
+ "[branch \"false\"]\n"
+ " rebase = false\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, "false").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) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index 901b9de86d..9755ed1b69 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -2819,6 +2819,75 @@ public class UploadPackTest {
}
@Test
+ public void testSingleBranchShallowCloneTagChainWithReflessTag() throws Exception {
+ RevCommit one = remote.commit().message("1").create();
+ remote.update("master", one);
+ RevTag tag1 = remote.tag("t1", one);
+ remote.lightweightTag("t1", tag1);
+ RevTag tag2 = remote.tag("t2", tag1);
+ RevTag tag3 = remote.tag("t3", tag2);
+ remote.lightweightTag("t3", tag3);
+
+ UploadPack uploadPack = new UploadPack(remote.getRepository());
+
+ ByteArrayOutputStream cli = new ByteArrayOutputStream();
+ PacketLineOut clientWant = new PacketLineOut(cli);
+ clientWant.writeString("want " + one.name() + " include-tag");
+ clientWant.writeString("deepen 1\n");
+ clientWant.end();
+ clientWant.writeString("done\n");
+
+ try (ByteArrayOutputStream serverResponse = new ByteArrayOutputStream()) {
+
+ uploadPack.setPreUploadHook(new PreUploadHook() {
+ @Override
+ public void onBeginNegotiateRound(UploadPack up,
+ Collection<? extends ObjectId> wants, int cntOffered)
+ throws ServiceMayNotContinueException {
+ // Do nothing.
+ }
+
+ @Override
+ public void onEndNegotiateRound(UploadPack up,
+ Collection<? extends ObjectId> wants, int cntCommon,
+ int cntNotFound, boolean ready)
+ throws ServiceMayNotContinueException {
+ // Do nothing.
+ }
+
+ @Override
+ public void onSendPack(UploadPack up,
+ Collection<? extends ObjectId> wants,
+ Collection<? extends ObjectId> haves)
+ throws ServiceMayNotContinueException {
+ // collect pack data
+ serverResponse.reset();
+ }
+ });
+ uploadPack.upload(new ByteArrayInputStream(cli.toByteArray()),
+ serverResponse, System.err);
+ ByteArrayInputStream packReceived = new ByteArrayInputStream(
+ serverResponse.toByteArray());
+ PackLock lock = null;
+ try (ObjectInserter ins = client.newObjectInserter()) {
+ PackParser parser = ins.newPackParser(packReceived);
+ parser.setAllowThin(true);
+ parser.setLockMessage("receive-tag-chain");
+ ProgressMonitor mlc = NullProgressMonitor.INSTANCE;
+ lock = parser.parse(mlc, mlc);
+ ins.flush();
+ } finally {
+ if (lock != null) {
+ lock.unlock();
+ }
+ }
+ InMemoryRepository.MemObjDatabase objDb = client
+ .getObjectDatabase();
+ assertTrue(objDb.has(one.toObjectId()));
+ }
+ }
+
+ @Test
public void testSafeToClearRefsInFetchV0() throws Exception {
server =
new RefCallsCountingRepository(