summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-04-28 19:51:01 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-04-28 19:51:01 +0200
commit4d9db14a5e31cd87128a059d96408062c0289040 (patch)
treeb2bf109013f2a516375d77b9daff77d3663a0cd3
parentf9f3389847c46b6d6df946814db796b4480970b5 (diff)
parent34a81889b8d8a6e84ffaf86deca8eb15bfb250ab (diff)
downloadjgit-4d9db14a5e31cd87128a059d96408062c0289040.tar.gz
jgit-4d9db14a5e31cd87128a059d96408062c0289040.zip
Merge branch 'stable-6.5'
* stable-6.5: [bazel] Move ToolTestCase to src folder (6.2) GcConcurrentTest: @Ignore flaky testInterruptGc Fix CommitTemplateConfigTest Fix after_open config and Snapshotting RefDir tests to work with bazel [bazel] Skip ConfigTest#testCommitTemplatePathInHomeDirecory Demote severity of some error prone bug patterns to warnings Parse pull.rebase=preserve as alias for pull.rebase=merges UploadPack: Fix NPE when traversing a tag chain Change-Id: I16e8553d187a8ef541f578291f47fc39c3da4ac0
-rw-r--r--org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/ToolTestCase.java (renamed from org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ToolTestCase.java)0
-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
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java27
-rw-r--r--tools/BUILD6
9 files changed, 174 insertions, 18 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ToolTestCase.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/ToolTestCase.java
index 55db1a12d9..55db1a12d9 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ToolTestCase.java
+++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/ToolTestCase.java
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(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
index 19495dff1f..e15c7af932 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
@@ -35,7 +35,12 @@ public class BranchConfig {
*
* @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 */
INTERACTIVE("interactive"), //$NON-NLS-1$
/** Value for not rebasing at all but merging */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index b648706475..f245eae39f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -2444,11 +2444,11 @@ public class UploadPack implements Closeable {
if (peeledId == null || objectId == null)
continue;
- objectId = ref.getObjectId();
- if (pw.willInclude(peeledId) && !pw.willInclude(objectId)) {
- RevObject o = rw.parseAny(objectId);
- addTagChain(o, pw);
- pw.addObject(o);
+ if (pw.willInclude(peeledId)) {
+ // We don't need to handle parseTag throwing an
+ // IncorrectObjectTypeException as we only reach
+ // here when ref is an annotated tag
+ addTagChain(rw.parseTag(objectId), pw);
}
}
}
@@ -2498,15 +2498,16 @@ public class UploadPack implements Closeable {
}
private void addTagChain(
- RevObject o, PackWriter pw) throws IOException {
- while (Constants.OBJ_TAG == o.getType()) {
- RevTag t = (RevTag) o;
- o = t.getObject();
- if (o.getType() == Constants.OBJ_TAG && !pw.willInclude(o.getId())) {
- walk.parseBody(o);
- pw.addObject(o);
+ RevTag tag, PackWriter pw) throws IOException {
+ RevObject o = tag;
+ do {
+ tag = (RevTag) o;
+ walk.parseBody(tag);
+ if (!pw.willInclude(tag.getId())) {
+ pw.addObject(tag);
}
- }
+ o = tag.getObject();
+ } while (Constants.OBJ_TAG == o.getType());
}
private List<ObjectId> parseDeepenNots(List<String> deepenNots)
diff --git a/tools/BUILD b/tools/BUILD
index a10901982f..1e671087d6 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -45,7 +45,7 @@ java_package_configuration(
"-Xep:CannotMockFinalClass:ERROR",
"-Xep:ClassCanBeStatic:ERROR",
"-Xep:ClassNewInstance:ERROR",
- "-Xep:DefaultCharset:ERROR",
+ "-Xep:DefaultCharset:WARN",
"-Xep:DoubleCheckedLocking:ERROR",
"-Xep:ElementsCountedInLoop:ERROR",
"-Xep:EqualsHashCode:ERROR",
@@ -55,7 +55,7 @@ java_package_configuration(
"-Xep:FragmentInjection:ERROR",
"-Xep:FragmentNotInstantiable:ERROR",
"-Xep:FunctionalInterfaceClash:ERROR",
- "-Xep:FutureReturnValueIgnored:ERROR",
+ "-Xep:FutureReturnValueIgnored:WARN",
"-Xep:GetClassOnEnum:ERROR",
"-Xep:ImmutableAnnotationChecker:ERROR",
"-Xep:ImmutableEnumChecker:ERROR",
@@ -89,7 +89,7 @@ java_package_configuration(
"-Xep:TypeParameterShadowing:ERROR",
"-Xep:TypeParameterUnusedInFormals:WARN",
"-Xep:URLEqualsHashCode:ERROR",
- "-Xep:UnusedException:ERROR",
+ "-Xep:UnusedException:WARN",
"-Xep:UnsynchronizedOverridesSynchronized:ERROR",
"-Xep:WaitNotInLoop:ERROR",
],