|
|
@ -140,7 +140,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testResetHard() throws IOException, NoFilepatternException, |
|
|
|
public void testResetHard() throws IOException, NoFilepatternException, |
|
|
|
GitAPIException { |
|
|
|
GitAPIException { |
|
|
|
Git git = new Git(db); |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
writeTrashFile("f", "f()"); |
|
|
|
writeTrashFile("f", "f()"); |
|
|
|
writeTrashFile("D/g", "g()"); |
|
|
|
writeTrashFile("D/g", "g()"); |
|
|
|
git.add().addFilepattern(".").call(); |
|
|
|
git.add().addFilepattern(".").call(); |
|
|
@ -187,6 +187,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
assertWorkDir(mkmap("f", "f()\nmaster", "D/g", "g()\ng2()", "E/h", |
|
|
|
assertWorkDir(mkmap("f", "f()\nmaster", "D/g", "g()\ng2()", "E/h", |
|
|
|
"h()", "untracked", "untracked")); |
|
|
|
"h()", "untracked", "untracked")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Reset hard from unclean condition. |
|
|
|
* Reset hard from unclean condition. |
|
|
@ -200,7 +201,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testResetHardFromIndexEntryWithoutFileToTreeWithoutFile() |
|
|
|
public void testResetHardFromIndexEntryWithoutFileToTreeWithoutFile() |
|
|
|
throws Exception { |
|
|
|
throws Exception { |
|
|
|
Git git = new Git(db); |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
writeTrashFile("x", "x"); |
|
|
|
writeTrashFile("x", "x"); |
|
|
|
git.add().addFilepattern("x").call(); |
|
|
|
git.add().addFilepattern("x").call(); |
|
|
|
RevCommit id1 = git.commit().setMessage("c1").call(); |
|
|
|
RevCommit id1 = git.commit().setMessage("c1").call(); |
|
|
@ -216,6 +217,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
git.reset().setMode(ResetType.HARD).setRef(id1.getName()).call(); |
|
|
|
git.reset().setMode(ResetType.HARD).setRef(id1.getName()).call(); |
|
|
|
assertIndex(mkmap("x", "x")); |
|
|
|
assertIndex(mkmap("x", "x")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Test first checkout in a repo |
|
|
|
* Test first checkout in a repo |
|
|
@ -224,8 +226,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testInitialCheckout() throws Exception { |
|
|
|
public void testInitialCheckout() throws Exception { |
|
|
|
Git git = new Git(db); |
|
|
|
try (Git git = new Git(db)) { |
|
|
|
|
|
|
|
|
|
|
|
TestRepository<Repository> db_t = new TestRepository<Repository>(db); |
|
|
|
TestRepository<Repository> db_t = new TestRepository<Repository>(db); |
|
|
|
BranchBuilder master = db_t.branch("master"); |
|
|
|
BranchBuilder master = db_t.branch("master"); |
|
|
|
master.commit().add("f", "1").message("m0").create(); |
|
|
|
master.commit().add("f", "1").message("m0").create(); |
|
|
@ -233,6 +234,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
git.checkout().setName("master").call(); |
|
|
|
git.checkout().setName("master").call(); |
|
|
|
assertTrue(new File(db.getWorkTree(), "f").exists()); |
|
|
|
assertTrue(new File(db.getWorkTree(), "f").exists()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private DirCacheCheckout resetHard(RevCommit commit) |
|
|
|
private DirCacheCheckout resetHard(RevCommit commit) |
|
|
|
throws NoWorkTreeException, |
|
|
|
throws NoWorkTreeException, |
|
|
@ -1612,7 +1614,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
public void assertWorkDir(Map<String, String> i) |
|
|
|
public void assertWorkDir(Map<String, String> i) |
|
|
|
throws CorruptObjectException, |
|
|
|
throws CorruptObjectException, |
|
|
|
IOException { |
|
|
|
IOException { |
|
|
|
TreeWalk walk = new TreeWalk(db); |
|
|
|
try (TreeWalk walk = new TreeWalk(db)) { |
|
|
|
walk.setRecursive(false); |
|
|
|
walk.setRecursive(false); |
|
|
|
walk.addTree(new FileTreeIterator(db)); |
|
|
|
walk.addTree(new FileTreeIterator(db)); |
|
|
|
String expectedValue; |
|
|
|
String expectedValue; |
|
|
@ -1655,3 +1657,4 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { |
|
|
|
assertEquals("WorkDir has not the right size.", i.size(), nrFiles); |
|
|
|
assertEquals("WorkDir has not the right size.", i.size(), nrFiles); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|