aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2012-06-07 11:37:11 -0700
committerShawn O. Pearce <spearce@spearce.org>2012-06-07 11:38:23 -0700
commit65f6e06b8d70e9e0975b6621eed2cdf7c16a763f (patch)
tree7136dd603743461ae265b3e47006594ce0adf4e1 /org.eclipse.jgit.test
parent8672c43ae368a014b1fd7d3c108fd41b2fa7ea9e (diff)
parentf2d9a5ed31380470aa2b708afc5d1711aa086ca7 (diff)
downloadjgit-65f6e06b8d70e9e0975b6621eed2cdf7c16a763f.tar.gz
jgit-65f6e06b8d70e9e0975b6621eed2cdf7c16a763f.zip
Merge branch 'stable-2.0'
By Robin Rosenberg (6) and others via Gerrit Code Review @ Eclipse.org (2) and Matthias Sohn (1) * stable-2.0: Prepare next 2.0.0-SNAPSHOT builds JGit v2.0.0.201206060730-rc3 Remove Jetty p2 repository from Maven build Get rid of warnings about empty statments Removed unused parameters from private methods cleanup: Remove unused declarations Make FS OS X detection work for OpenJDK Use working tree iterator to compare file modes Further cleanup of exceptions in Git API Update build to use Tycho 0.15.0 Throw formal CheckoutConflictException on hard reset Configure maven-source-plugin execution in parent POM Support gitdir: refs in BaseRepositoryBuilder.findGitDir Relax RevisionSyntaxException to an IllegalArgumentException Change-Id: I05727693e0c9e762d4fc220ceadcd5a5bfb11d0d
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java40
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java57
2 files changed, 97 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java
index 9f92c045c0..469739c57c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java
@@ -44,6 +44,7 @@ package org.eclipse.jgit.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -54,7 +55,10 @@ import org.eclipse.jgit.api.CherryPickResult.CherryPickStatus;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
@@ -183,6 +187,42 @@ public class CherryPickCommandTest extends RepositoryTestCase {
.exists());
}
+ @Test
+ public void testCherryPickOverExecutableChangeOnNonExectuableFileSystem()
+ throws Exception {
+ Git git = new Git(db);
+ File file = writeTrashFile("test.txt", "a");
+ assertNotNull(git.add().addFilepattern("test.txt").call());
+ assertNotNull(git.commit().setMessage("commit1").call());
+
+ assertNotNull(git.checkout().setCreateBranch(true).setName("a").call());
+
+ writeTrashFile("test.txt", "b");
+ assertNotNull(git.add().addFilepattern("test.txt").call());
+ RevCommit commit2 = git.commit().setMessage("commit2").call();
+ assertNotNull(commit2);
+
+ assertNotNull(git.checkout().setName(Constants.MASTER).call());
+
+ DirCache cache = db.lockDirCache();
+ cache.getEntry("test.txt").setFileMode(FileMode.EXECUTABLE_FILE);
+ cache.write();
+ assertTrue(cache.commit());
+ cache.unlock();
+
+ assertNotNull(git.commit().setMessage("commit3").call());
+
+ db.getFS().setExecute(file, false);
+ git.getRepository()
+ .getConfig()
+ .setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_FILEMODE, false);
+
+ CherryPickResult result = git.cherryPick().include(commit2).call();
+ assertNotNull(result);
+ assertEquals(CherryPickStatus.OK, result.getStatus());
+ }
+
private RevCommit prepareCherryPick(final Git git) throws Exception {
// create, add and commit file a
writeTrashFile("a", "a");
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
index aed48aa5fb..b6377482dc 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
@@ -45,13 +45,16 @@ package org.eclipse.jgit.storage.file;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
@@ -108,4 +111,58 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
assertNotNull(e.getMessage());
}
}
+
+ @Test
+ public void absoluteGitDirRef() throws Exception {
+ FileRepository repo1 = createWorkRepository();
+ File dir = createTempDirectory("dir");
+ File dotGit = new File(dir, Constants.DOT_GIT);
+ new FileWriter(dotGit).append(
+ "gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+
+ builder.setWorkTree(dir);
+ builder.setMustExist(true);
+ FileRepository repo2 = builder.build();
+
+ assertEquals(repo1.getDirectory(), repo2.getDirectory());
+ assertEquals(dir, repo2.getWorkTree());
+ }
+
+ @Test
+ public void relativeGitDirRef() throws Exception {
+ FileRepository repo1 = createWorkRepository();
+ File dir = new File(repo1.getWorkTree(), "dir");
+ assertTrue(dir.mkdir());
+ File dotGit = new File(dir, Constants.DOT_GIT);
+ new FileWriter(dotGit).append("gitdir: ../" + Constants.DOT_GIT)
+ .close();
+
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+ builder.setWorkTree(dir);
+ builder.setMustExist(true);
+ FileRepository repo2 = builder.build();
+
+ assertEquals(repo1.getDirectory(), repo2.getDirectory());
+ assertEquals(dir, repo2.getWorkTree());
+ }
+
+ @Test
+ public void scanWithGitDirRef() throws Exception {
+ FileRepository repo1 = createWorkRepository();
+ File dir = createTempDirectory("dir");
+ File dotGit = new File(dir, Constants.DOT_GIT);
+ new FileWriter(dotGit).append(
+ "gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+
+ builder.setWorkTree(dir);
+ builder.findGitDir(dir);
+ assertEquals(repo1.getDirectory(), builder.getGitDir());
+ builder.setMustExist(true);
+ FileRepository repo2 = builder.build();
+
+ assertEquals(repo1.getDirectory(), repo2.getDirectory());
+ assertEquals(dir, repo2.getWorkTree());
+ }
}