aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-02-25 10:29:07 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-02-28 00:58:04 +0100
commitf6597971991e3350df568b0cde05c014dcd69c47 (patch)
treecb61592af3f53da45174beed517b3284d7bd55c6 /org.eclipse.jgit.pgm.test
parent286ad23cb56ffeac77d4bfd03be575358fd5217c (diff)
parent789c0479a9294417db0375cce9f1949fe9052d8c (diff)
downloadjgit-f6597971991e3350df568b0cde05c014dcd69c47.tar.gz
jgit-f6597971991e3350df568b0cde05c014dcd69c47.zip
Merge branch 'master' into next
* master: (143 commits) Prepare 5.11.0-SNAPSHOT builds JGit v5.11.0.202102240950-m3 [releng] japicmp: update last release version IgnoreNode: include path to file for invalid .gitignore patterns FastIgnoreRule: include bad pattern in log message init: add config option to set default for the initial branch name init: allow specifying the initial branch name for the new repository Fail clone if initial branch doesn't exist in remote repository GPG: fix reading unprotected old-format secret keys Update Orbit to S20210216215844 Add missing bazel dependency for o.e.j.gpg.bc.test GPG: handle extended private key format dfs: handle short copies [GPG] Provide a factory for the BouncyCastleGpgSigner Fix boxing warnings GPG: compute the keygrip to find a secret key GPG signature verification via BouncyCastle Post commit hook failure should not cause commit failure Allow to define additional Hook classes outside JGit GitHook: use default charset for output and error streams ... Change-Id: I689f4070e79f4a0ac1c02b35698ccaab68ad2f34
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r--org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java42
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/InitTest.java21
3 files changed, 65 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
index 3dd5840397..b853c6a7ed 100644
--- a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
@@ -51,8 +51,8 @@ org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java
index 2f09b7f122..4cbd61c692 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CloneTest.java
@@ -11,7 +11,9 @@ package org.eclipse.jgit.pgm;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -25,6 +27,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
+import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.RefSpec;
@@ -64,6 +67,45 @@ public class CloneTest extends CLIRepositoryTestCase {
assertEquals("expected 1 branch", 1, branches.size());
}
+ @Test
+ public void testCloneInitialBranch() throws Exception {
+ createInitialCommit();
+
+ File gitDir = db.getDirectory();
+ String sourceURI = gitDir.toURI().toString();
+ File target = createTempDirectory("target");
+ String cmd = "git clone --branch master " + sourceURI + " "
+ + shellQuote(target.getPath());
+ String[] result = execute(cmd);
+ assertArrayEquals(new String[] {
+ "Cloning into '" + target.getPath() + "'...", "", "" }, result);
+
+ Git git2 = Git.open(target);
+ List<Ref> branches = git2.branchList().call();
+ assertEquals("expected 1 branch", 1, branches.size());
+
+ Repository db2 = git2.getRepository();
+ ObjectId head = db2.resolve("HEAD");
+ assertNotNull(head);
+ assertNotEquals(ObjectId.zeroId(), head);
+ ObjectId master = db2.resolve("master");
+ assertEquals(head, master);
+ }
+
+ @Test
+ public void testCloneInitialBranchMissing() throws Exception {
+ createInitialCommit();
+
+ File gitDir = db.getDirectory();
+ String sourceURI = gitDir.toURI().toString();
+ File target = createTempDirectory("target");
+ String cmd = "git clone --branch foo " + sourceURI + " "
+ + shellQuote(target.getPath());
+ Die e = assertThrows(Die.class, () -> execute(cmd));
+ assertEquals("Remote branch 'foo' not found in upstream origin",
+ e.getMessage());
+ }
+
private RevCommit createInitialCommit() throws Exception {
JGitTestUtil.writeTrashFile(db, "hello.txt", "world");
git.add().addFilepattern("hello.txt").call();
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/InitTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/InitTest.java
index 84474e33cd..88789d3383 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/InitTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/InitTest.java
@@ -11,11 +11,14 @@
package org.eclipse.jgit.pgm;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import java.io.File;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -54,4 +57,22 @@ public class InitTest extends CLIRepositoryTestCase {
assertArrayEquals(expecteds, result);
}
+ @Test
+ public void testInitDirectoryInitialBranch() throws Exception {
+ File workDirectory = tempFolder.getRoot();
+ File gitDirectory = new File(workDirectory, Constants.DOT_GIT);
+
+ String[] result = execute(
+ "git init -b main '" + workDirectory.getCanonicalPath() + "'");
+
+ String[] expecteds = new String[] {
+ "Initialized empty Git repository in "
+ + gitDirectory.getCanonicalPath(),
+ "" };
+ assertArrayEquals(expecteds, result);
+
+ try (Repository repo = new FileRepository(gitDirectory)) {
+ assertEquals("refs/heads/main", repo.getFullBranch());
+ }
+ }
}