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>
tags/v4.7.0.201704051617-r
James Melvin 7 years ago
parent
commit
d980a3fa85

+ 4
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcKeepFilesTest.java View 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();

+ 2
- 1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java View 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();
}


+ 3
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java View 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$


Loading…
Cancel
Save