diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-11-17 23:50:41 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-11-17 23:50:41 -0500 |
commit | 216d9981f51ca4b68eef4ed6d465745f5d10190c (patch) | |
tree | 146f74a9df5a3b28163946d710dd3ee47ff9b721 /org.eclipse.jgit.test | |
parent | 97b8115be4fd5c8901ce39e53e11b3b425697574 (diff) | |
parent | 8da939221c2e244fe0ba979fa8419a90bf618315 (diff) | |
download | jgit-216d9981f51ca4b68eef4ed6d465745f5d10190c.tar.gz jgit-216d9981f51ca4b68eef4ed6d465745f5d10190c.zip |
Merge "Don't delete .idx file if .pack file can't be deleted"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java index 9d2a03b097..35455f48a9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GCTest.java @@ -49,6 +49,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -66,6 +67,7 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.storage.file.GC.RepoStatistics; import org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry; +import org.eclipse.jgit.internal.storage.pack.PackExt; import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.junit.TestRepository; @@ -621,6 +623,40 @@ public class GCTest extends LocalDiskRepositoryTestCase { } @Test + public void testPruneOldPacksWithOpenHandleOnPack() throws Exception { + gc.setExpireAgeMillis(0); + + BranchBuilder bb = tr.branch("refs/heads/master"); + bb.commit().add("A", "A").add("B", "B").create(); + fsTick(); + gc.gc(); + + Collection<PackFile> packs = repo.getObjectDatabase().getPacks(); + assertEquals(1, packs.size()); + PackFile pack = packs.iterator().next(); + File packFile = pack.getPackFile(); + File indexFile = new File(packFile.getParentFile(), "pack-" + + pack.getPackName() + + "." + + PackExt.INDEX.getExtension()); + FileInputStream fis = new FileInputStream(packFile); + try { + bb.commit().add("A", "A2").add("B", "B2").create(); + fsTick(); + gc.gc(); + if (packFile.exists()) { + assertTrue( + "The pack was present but the index file was missing.", + indexFile.exists()); + } + + } finally { + fis.close(); + } + + } + + @Test public void testPackCommitsAndLooseOneWithPruneNowNoReflog() throws Exception { BranchBuilder bb = tr.branch("refs/heads/master"); |