summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-06-14 00:11:37 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2016-06-14 00:11:37 +0200
commit48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17 (patch)
treeed55d9ec704f92778591a1ccf8a2dd6983c61e3f /org.eclipse.jgit.test/tst
parenta418c2eb4d6caf778973557b042f50fb5729df61 (diff)
parent0900dc08f59de482b38862094936e80fca39df2a (diff)
downloadjgit-48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17.tar.gz
jgit-48cb5ffba6d2b11aea407cdd93e5a8ffb7bfec17.zip
Merge branch 'stable-4.4'
* stable-4.4: Prepare 4.4.1-SNAPSHOT builds JGit v4.4.0.201606070830-r Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201606011500-rc2 Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201605250940-rc1 Update Orbit repository for Neon to R20160520211859 Fix computation of id in WorkingTreeIterator with autocrlf and smudging Prepare 4.3.2-SNAPSHOT builds JGit v4.3.1.201605051710-r Prepare 4.4.0-SNAPSHOT builds JGit v4.4.0.201605041135-m1 Run Maven build in release.sh concurrently to speedup release Change-Id: I25ef0497a4455b8229b453e1023abb4631d4b6d3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java56
1 files changed, 49 insertions, 7 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java
index 5dd8da57c2..5f10131750 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java
@@ -51,6 +51,7 @@ import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.attributes.Attribute;
import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheEditor;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.errors.RevisionSyntaxException;
@@ -61,9 +62,11 @@ import org.eclipse.jgit.lib.CoreConfig.AutoCRLF;
import org.eclipse.jgit.lib.CoreConfig.EOL;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectLoader;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.IO;
import org.junit.Assert;
import org.junit.Test;
@@ -83,6 +86,14 @@ public class EolRepositoryTest extends RepositoryTestCase {
private static final FileMode F = FileMode.REGULAR_FILE;
@DataPoint
+ public static boolean doSmudgeEntries = true;
+
+ @DataPoint
+ public static boolean dontSmudgeEntries = false;
+
+ private boolean smudge;
+
+ @DataPoint
public static String smallContents[] = {
generateTestData(3, 1, true, false),
generateTestData(3, 1, false, true),
@@ -117,10 +128,11 @@ public class EolRepositoryTest extends RepositoryTestCase {
return sb.toString();
}
- public EolRepositoryTest(String[] testContent) {
+ public EolRepositoryTest(String[] testContent, boolean smudgeEntries) {
CONTENT_CRLF = testContent[0];
CONTENT_LF = testContent[1];
CONTENT_MIXED = testContent[2];
+ this.smudge = smudgeEntries;
}
protected String CONTENT_CRLF;
@@ -160,7 +172,7 @@ public class EolRepositoryTest extends RepositoryTestCase {
private ActualEntry entryMixed = new ActualEntry();
- private DirCache dc;
+ private DirCache dirCache;
@Test
public void testDefaultSetup() throws Exception {
@@ -177,7 +189,9 @@ public class EolRepositoryTest extends RepositoryTestCase {
String indexContent) {
assertEquals(fileContent, entry.file);
assertEquals(indexContent, entry.index);
- assertEquals(fileContent.length(), entry.indexContentLength);
+ if (entry.indexContentLength != 0) {
+ assertEquals(fileContent.length(), entry.indexContentLength);
+ }
}
@Test
@@ -584,6 +598,14 @@ public class EolRepositoryTest extends RepositoryTestCase {
dotGitattributes = null;
}
+ fileCRLF = createAndAddFile(git, "file1.txt", "a");
+
+ fileLF = createAndAddFile(git, "file2.txt", "a");
+
+ fileMixed = createAndAddFile(git, "file3.txt", "a");
+
+ RevCommit c = gitCommit(git, "create files");
+
fileCRLF = createAndAddFile(git, "file1.txt", CONTENT_CRLF);
fileLF = createAndAddFile(git, "file2.txt", CONTENT_LF);
@@ -593,6 +615,26 @@ public class EolRepositoryTest extends RepositoryTestCase {
gitCommit(git, "addFiles");
recreateWorktree(git);
+
+ if (smudge) {
+ DirCache dc = DirCache.lock(git.getRepository().getIndexFile(),
+ FS.detect());
+ DirCacheEditor editor = dc.editor();
+ for (int i = 0; i < dc.getEntryCount(); i++) {
+ editor.add(new DirCacheEditor.PathEdit(
+ dc.getEntry(i).getPathString()) {
+ public void apply(DirCacheEntry ent) {
+ ent.smudgeRacilyClean();
+ }
+ });
+ }
+ editor.commit();
+ }
+
+ // @TODO: find out why the following assertion would break the tests
+ // assertTrue(git.status().call().isClean());
+ git.checkout().setName(c.getName()).call();
+ git.checkout().setName("master").call();
}
private void recreateWorktree(Git git)
@@ -610,8 +652,8 @@ public class EolRepositoryTest extends RepositoryTestCase {
gitAdd(git, ".");
}
- protected void gitCommit(Git git, String msg) throws GitAPIException {
- git.commit().setMessage(msg).call();
+ protected RevCommit gitCommit(Git git, String msg) throws GitAPIException {
+ return git.commit().setMessage(msg).call();
}
protected void gitAdd(Git git, String path) throws GitAPIException {
@@ -644,7 +686,7 @@ public class EolRepositoryTest extends RepositoryTestCase {
}
private void collectRepositoryState() throws Exception {
- dc = db.readDirCache();
+ dirCache = db.readDirCache();
walk = beginWalk();
if (dotGitattributes != null)
collectEntryContentAndAttributes(F, ".gitattributes", null);
@@ -680,7 +722,7 @@ public class EolRepositoryTest extends RepositoryTestCase {
e.attrs = e.attrs.trim();
e.file = new String(
IO.readFully(new File(db.getWorkTree(), pathName)));
- DirCacheEntry dce = dc.getEntry(pathName);
+ DirCacheEntry dce = dirCache.getEntry(pathName);
ObjectLoader open = walk.getObjectReader().open(dce.getObjectId());
e.index = new String(open.getBytes());
e.indexContentLength = dce.getLength();