diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-07-23 15:30:06 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2014-07-25 03:31:31 -0400 |
commit | cf9b01b09a320de4afb8da8f2ec5002fd0441831 (patch) | |
tree | e0f106a5012fb71b332b6d5c9ee8f3a7f2f0fd68 /org.eclipse.jgit.test | |
parent | f3fc3797579ac0bf55648bad560e7daa5e6df9b5 (diff) | |
download | jgit-cf9b01b09a320de4afb8da8f2ec5002fd0441831.tar.gz jgit-cf9b01b09a320de4afb8da8f2ec5002fd0441831.zip |
Handle initial checkout correctly
As described in native gits file "git-read-tree.txt" git has in a
special mode when doing the "initial" checkout. "Initial" means that the
index is empty before the checkout. This was not handled correctly in
JGit and is fixed in this commit. Also see
https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L181
Change-Id: I9b9d1bd9ebf349cfca420c891c7b099a18d07ba4
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java index afbad6ab2c..f7e6fa9b79 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java @@ -72,6 +72,8 @@ import org.eclipse.jgit.errors.CheckoutConflictException; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.junit.TestRepository; +import org.eclipse.jgit.junit.TestRepository.BranchBuilder; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; @@ -213,6 +215,23 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { assertIndex(mkmap("x", "x")); } + /** + * Test first checkout in a repo + * + * @throws Exception + */ + @Test + public void testInitialCheckout() throws Exception { + Git git = new Git(db); + + TestRepository<Repository> db_t = new TestRepository<Repository>(db); + BranchBuilder master = db_t.branch("master"); + master.commit().add("f", "1").message("m0").create(); + assertFalse(new File(db.getWorkTree(), "f").exists()); + git.checkout().setName("master").call(); + assertTrue(new File(db.getWorkTree(), "f").exists()); + } + private DirCacheCheckout resetHard(RevCommit commit) throws NoWorkTreeException, CorruptObjectException, IOException { |