Browse Source

Fix keep pack filename

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>
stable-4.7
James Melvin 8 years ago
parent
commit
d980a3fa85
  1. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  3. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java

@ -73,7 +73,10 @@ public class GcKeepFilesTest extends GcTestCase {
.iterator(); .iterator();
PackFile singlePack = packIt.next(); PackFile singlePack = packIt.next();
assertFalse(packIt.hasNext()); 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()); assertFalse(keepFile.exists());
assertTrue(keepFile.createNewFile()); assertTrue(keepFile.createNewFile());
bb.commit().add("A", "A2").add("B", "B2").create(); bb.commit().add("A", "A2").add("B", "B2").create();

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -46,6 +46,7 @@
package org.eclipse.jgit.internal.storage.file; 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.BITMAP_INDEX;
import static org.eclipse.jgit.internal.storage.pack.PackExt.KEEP;
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX; import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
import java.io.EOFException; import java.io.EOFException;
@ -241,7 +242,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
*/ */
public boolean shouldBeKept() { public boolean shouldBeKept() {
if (keepFile == null) if (keepFile == null)
keepFile = new File(packFile.getPath() + ".keep"); //$NON-NLS-1$ keepFile = extFile(KEEP);
return keepFile.exists(); return keepFile.exists();
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java

@ -53,6 +53,9 @@ public class PackExt {
/** A pack index file extension. */ /** A pack index file extension. */
public static final PackExt INDEX = newPackExt("idx"); //$NON-NLS-1$ 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. */ /** A pack bitmap index file extension. */
public static final PackExt BITMAP_INDEX = newPackExt("bitmap"); //$NON-NLS-1$ public static final PackExt BITMAP_INDEX = newPackExt("bitmap"); //$NON-NLS-1$

Loading…
Cancel
Save