Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg2011-02-25 18:20:59 -0500
committerMatthias Sohn2011-02-25 18:20:59 -0500
commit230a0af2e169aed34c1ea7f9f1c0d5846a3ca298 (patch)
tree26844c68f79aed19a469a2394e373b641f7de8cb /org.eclipse.egit.core.test
parentdc521fbc2312641b50ad97df891cd10dc370069d (diff)
downloadegit-230a0af2e169aed34c1ea7f9f1c0d5846a3ca298.tar.gz
egit-230a0af2e169aed34c1ea7f9f1c0d5846a3ca298.tar.xz
egit-230a0af2e169aed34c1ea7f9f1c0d5846a3ca298.zip
Fix NPE when comitting file added in index and deleted in worktree
Change-Id: I9d3b54a2eb32b8ad1f579b25dea5d36013322ec1 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
index 9ee73f1c6..1e1405bf1 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/CommitOperationTest.java
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -60,6 +61,37 @@ public class CommitOperationTest extends GitTestCase {
}
@Test
+ public void testCommitAddedToIndexDeletedInWorkspace() throws Exception {
+ testUtils.addFileToProject(project.getProject(), "foo/a.txt", "some text");
+ resources.add(project.getProject().getFolder("foo"));
+ new AddToIndexOperation(resources).execute(null);
+ CommitOperation commitOperation = new CommitOperation(null, null, null, TestUtils.AUTHOR, TestUtils.COMMITTER, "first commit");
+ commitOperation.setCommitAll(true);
+ commitOperation.setRepos(new Repository[] {repository});
+ commitOperation.execute(null);
+
+ testUtils.addFileToProject(project.getProject(), "zar/b.txt", "some text");
+ resources.add(project.getProject().getFolder("zar"));
+ new AddToIndexOperation(resources).execute(null);
+ project.getProject().getFile("zar/b.txt").delete(true, null);
+ assert !project.getProject().getFile("bar/b.txt").exists();
+
+ IFile[] filesToCommit = new IFile[] { project.getProject().getFile("zar/b.txt") };
+ commitOperation = new CommitOperation(filesToCommit, Arrays.asList(filesToCommit), null, TestUtils.AUTHOR, TestUtils.COMMITTER, "first commit");
+ commitOperation.setRepos(new Repository[] {repository});
+ commitOperation.execute(null);
+
+ TreeWalk treeWalk = new TreeWalk(repository);
+ treeWalk.addTree(repository.resolve("HEAD^{tree}"));
+ assertTrue(treeWalk.next());
+ assertEquals("foo", treeWalk.getPathString());
+ treeWalk.enterSubtree();
+ assertTrue(treeWalk.next());
+ assertEquals("foo/a.txt", treeWalk.getPathString());
+ assertFalse(treeWalk.next());
+ }
+
+ @Test
public void testCommitAll() throws Exception {
IFile file1 = testUtils.addFileToProject(project.getProject(),
"sub/a.txt", "some text");

Back to the top