]> source.dussan.org Git - jgit.git/commitdiff
Fix keep pack filename 76/87776/1
authorJames Melvin <jmelvin@codeaurora.org>
Tue, 27 Dec 2016 21:08:56 +0000 (14:08 -0700)
committerJames Melvin <jmelvin@codeaurora.org>
Tue, 27 Dec 2016 21:08:56 +0000 (14:08 -0700)
Previously it was looking for a keep file with the name of a pack file
(extenstion included) appended with a '.keep'. However, the keep file
name should be the pack file name  with a '.keep' extension

Change-Id: I9dc4c7c393ae20aefa0b9507df8df83610ce4d42
Signed-off-by: James Melvin <jmelvin@codeaurora.org>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java

index 9e28298823c4c344ec5b19ed0cf18c0ce387a8a3..1a5084477d23a144cb3c63cf0fa4238e3c540f69 100644 (file)
@@ -73,7 +73,10 @@ public class GcKeepFilesTest extends GcTestCase {
                                .iterator();
                PackFile singlePack = packIt.next();
                assertFalse(packIt.hasNext());
-               File keepFile = new File(singlePack.getPackFile().getPath() + ".keep");
+               String packFileName = singlePack.getPackFile().getPath();
+               String keepFileName = packFileName.substring(0,
+                               packFileName.lastIndexOf('.')) + ".keep";
+               File keepFile = new File(keepFileName);
                assertFalse(keepFile.exists());
                assertTrue(keepFile.createNewFile());
                bb.commit().add("A", "A2").add("B", "B2").create();
index b385b8ab735646a7e7bb19af5b67e53794ad51ed..edf44fb6ecdac4015002b253669aeb3749d68e51 100644 (file)
@@ -46,6 +46,7 @@
 package org.eclipse.jgit.internal.storage.file;
 
 import static org.eclipse.jgit.internal.storage.pack.PackExt.BITMAP_INDEX;
+import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
 import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
 
 import java.io.EOFException;
@@ -241,7 +242,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
         */
        public boolean shouldBeKept() {
                if (keepFile == null)
-                       keepFile = new File(packFile.getPath() + ".keep"); //$NON-NLS-1$
+                       keepFile = extFile(KEEP);
                return keepFile.exists();
        }
 
index 4ee27cc845c389c22e2d885143b52d09e0110690..248692f93fcfba2983ffe15082635f77e9a7c0f3 100644 (file)
@@ -53,6 +53,9 @@ public class PackExt {
        /** A pack index file extension. */
        public static final PackExt INDEX = newPackExt("idx"); //$NON-NLS-1$
 
+       /** A keep pack file extension. */
+       public static final PackExt KEEP = newPackExt("keep"); //$NON-NLS-1$
+
        /** A pack bitmap index file extension. */
        public static final PackExt BITMAP_INDEX = newPackExt("bitmap"); //$NON-NLS-1$