summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2012-04-05 19:29:08 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2012-04-05 19:29:08 -0400
commitb7e881e62571abf56a5c36e9abf459c48e4647a4 (patch)
tree366e279c9faa647edd49ff07f3853f4c16e57dd3 /org.eclipse.jgit.test
parent6a1a80aa4ce54a862056c0379b459115b298409d (diff)
parent3f4725c179c176560937d756682fcd6cfbf685fe (diff)
downloadjgit-b7e881e62571abf56a5c36e9abf459c48e4647a4.tar.gz
jgit-b7e881e62571abf56a5c36e9abf459c48e4647a4.zip
Merge "Handle content length in WorkingTreeIterator"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java68
1 files changed, 30 insertions, 38 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
index d989b63b24..2fb228e01d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
@@ -44,9 +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 static org.junit.Assert.fail;
import java.io.File;
@@ -63,7 +61,6 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -114,7 +111,7 @@ public class AddCommandTest extends RepositoryTestCase {
}
@Test
- public void testAddExistingSingleFileWithNewLine() throws IOException,
+ public void testAddExistingSingleSmallFileWithNewLine() throws IOException,
NoFilepatternException {
File file = new File(db.getWorkTree(), "a.txt");
FileUtils.createNewFile(file);
@@ -138,6 +135,35 @@ public class AddCommandTest extends RepositoryTestCase {
}
@Test
+ public void testAddExistingSingleMediumSizeFileWithNewLine()
+ throws IOException, NoFilepatternException {
+ File file = new File(db.getWorkTree(), "a.txt");
+ FileUtils.createNewFile(file);
+ StringBuilder data = new StringBuilder();
+ for (int i = 0; i < 1000; ++i) {
+ data.append("row1\r\nrow2");
+ }
+ String crData = data.toString();
+ PrintWriter writer = new PrintWriter(file);
+ writer.print(crData);
+ writer.close();
+ String lfData = data.toString().replaceAll("\r", "");
+ Git git = new Git(db);
+ db.getConfig().setString("core", null, "autocrlf", "false");
+ git.add().addFilepattern("a.txt").call();
+ assertEquals("[a.txt, mode:100644, content:" + data + "]",
+ indexState(CONTENT));
+ db.getConfig().setString("core", null, "autocrlf", "true");
+ git.add().addFilepattern("a.txt").call();
+ assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
+ indexState(CONTENT));
+ db.getConfig().setString("core", null, "autocrlf", "input");
+ git.add().addFilepattern("a.txt").call();
+ assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
+ indexState(CONTENT));
+ }
+
+ @Test
public void testAddExistingSingleBinaryFile() throws IOException,
NoFilepatternException {
File file = new File(db.getWorkTree(), "a.txt");
@@ -658,40 +684,6 @@ public class AddCommandTest extends RepositoryTestCase {
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
}
- @Test
- public void testSubmoduleDeleteNotStagedWithUpdate() throws Exception {
- Git git = new Git(db);
- writeTrashFile("file.txt", "content");
- git.add().addFilepattern("file.txt").call();
- assertNotNull(git.commit().setMessage("create file").call());
-
- SubmoduleAddCommand command = new SubmoduleAddCommand(db);
- String path = "sub";
- command.setPath(path);
- String uri = db.getDirectory().toURI().toString();
- command.setURI(uri);
- Repository repo = command.call();
- assertNotNull(repo);
- assertNotNull(git.commit().setMessage("add submodule").call());
-
- assertTrue(git.status().call().isClean());
-
- FileUtils.delete(repo.getWorkTree(), FileUtils.RECURSIVE);
- FileUtils.mkdir(new File(db.getWorkTree(), path), false);
-
- assertNotNull(git.add().addFilepattern(".").setUpdate(true).call());
-
- Status status = git.status().call();
- assertFalse(status.isClean());
- assertTrue(status.getAdded().isEmpty());
- assertTrue(status.getChanged().isEmpty());
- assertTrue(status.getRemoved().isEmpty());
- assertTrue(status.getUntracked().isEmpty());
- assertTrue(status.getModified().isEmpty());
- assertEquals(1, status.getMissing().size());
- assertEquals(path, status.getMissing().iterator().next());
- }
-
private DirCacheEntry addEntryToBuilder(String path, File file,
ObjectInserter newObjectInserter, DirCacheBuilder builder, int stage)
throws IOException {