Browse Source

Merge branch 'stable-5.1' into stable-5.2

* stable-5.1:
  Prepare 5.1.15-SNAPSHOT builds
  JGit v5.1.14.202011251942-r
  GC#deleteOrphans: log warning for deleted orphaned files
  GC#deleteOrphans: handle failure to list files in pack directory
  Ensure that GC#deleteOrphans respects pack lock
  Update API warning filters
  Remove unused imports

Change-Id: I91cfe2820c40d2d773cbf018cc2a6c36b062801e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v5.3.8.202011260953-r
Matthias Sohn 3 years ago
parent
commit
65598b9516

+ 0
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollectorTest.java View File

import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource; import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
import org.eclipse.jgit.internal.storage.dfs.DfsRefDatabase;
import org.eclipse.jgit.internal.storage.reftable.RefCursor; import org.eclipse.jgit.internal.storage.reftable.RefCursor;
import org.eclipse.jgit.internal.storage.reftable.ReftableConfig; import org.eclipse.jgit.internal.storage.reftable.ReftableConfig;
import org.eclipse.jgit.internal.storage.reftable.ReftableReader; import org.eclipse.jgit.internal.storage.reftable.ReftableReader;

+ 22
- 2
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java View File



private final static String BITMAP_File_1 = PACK + "-1.bitmap"; private final static String BITMAP_File_1 = PACK + "-1.bitmap";


private final static String IDX_File_2 = PACK + "-2.idx";
private static final String BITMAP_File_2 = PACK + "-2.bitmap";

private static final String IDX_File_2 = PACK + "-2.idx";


private final static String IDX_File_malformed = PACK + "-1234idx"; private final static String IDX_File_malformed = PACK + "-1234idx";


private final static String PACK_File_2 = PACK + "-2.pack";
private static final String KEEP_File_2 = PACK + "-2.keep";

private static final String PACK_File_2 = PACK + "-2.pack";


private final static String PACK_File_3 = PACK + "-3.pack"; private final static String PACK_File_3 = PACK + "-3.pack";


assertTrue(new File(packDir, IDX_File_malformed).exists()); assertTrue(new File(packDir, IDX_File_malformed).exists());
} }


@Test
public void keepPreventsDeletionOfIndexFilesForMissingPackFile()
throws Exception {
createFileInPackFolder(BITMAP_File_1);
createFileInPackFolder(IDX_File_2);
createFileInPackFolder(BITMAP_File_2);
createFileInPackFolder(KEEP_File_2);
createFileInPackFolder(PACK_File_3);
gc.gc();
assertFalse(new File(packDir, BITMAP_File_1).exists());
assertTrue(new File(packDir, BITMAP_File_2).exists());
assertTrue(new File(packDir, IDX_File_2).exists());
assertTrue(new File(packDir, KEEP_File_2).exists());
assertTrue(new File(packDir, PACK_File_3).exists());
}

private void createFileInPackFolder(String fileName) throws IOException { private void createFileInPackFolder(String fileName) throws IOException {
if (!packDir.exists() || !packDir.isDirectory()) { if (!packDir.exists() || !packDir.isDirectory()) {
assertTrue(packDir.mkdirs()); assertTrue(packDir.mkdirs());

+ 0
- 1
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StatsTest.java View File

import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


import org.eclipse.jgit.util.Stats;
import org.junit.Test; import org.junit.Test;


public class StatsTest { public class StatsTest {

+ 1
- 0
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties View File

deepenSinceWithDeepen=Cannot combine deepen with deepen-since deepenSinceWithDeepen=Cannot combine deepen with deepen-since
deleteBranchUnexpectedResult=Delete branch returned unexpected result {0} deleteBranchUnexpectedResult=Delete branch returned unexpected result {0}
deleteFileFailed=Could not delete file {0} deleteFileFailed=Could not delete file {0}
deletedOrphanInPackDir=Deleted orphaned file {}
deleteRequiresZeroNewId=Delete requires new ID to be zero deleteRequiresZeroNewId=Delete requires new ID to be zero
deleteTagUnexpectedResult=Delete tag returned unexpected result {0} deleteTagUnexpectedResult=Delete tag returned unexpected result {0}
deletingNotSupported=Deleting {0} not supported. deletingNotSupported=Deleting {0} not supported.

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java View File

/***/ public String deepenSinceWithDeepen; /***/ public String deepenSinceWithDeepen;
/***/ public String deleteBranchUnexpectedResult; /***/ public String deleteBranchUnexpectedResult;
/***/ public String deleteFileFailed; /***/ public String deleteFileFailed;
/***/ public String deletedOrphanInPackDir;
/***/ public String deleteRequiresZeroNewId; /***/ public String deleteRequiresZeroNewId;
/***/ public String deleteTagUnexpectedResult; /***/ public String deleteTagUnexpectedResult;
/***/ public String deletingNotSupported; /***/ public String deletingNotSupported;

+ 13
- 5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java View File



private static final String INDEX_EXT = "." + PackExt.INDEX.getExtension(); //$NON-NLS-1$ private static final String INDEX_EXT = "." + PackExt.INDEX.getExtension(); //$NON-NLS-1$


private static final String KEEP_EXT = "." + PackExt.KEEP.getExtension(); //$NON-NLS-1$

private static final int DEFAULT_AUTOPACKLIMIT = 50; private static final int DEFAULT_AUTOPACKLIMIT = 50;


private static final int DEFAULT_AUTOLIMIT = 6700; private static final int DEFAULT_AUTOLIMIT = 6700;
fileNames = files.map(path -> path.getFileName().toString()) fileNames = files.map(path -> path.getFileName().toString())
.filter(name -> (name.endsWith(PACK_EXT) .filter(name -> (name.endsWith(PACK_EXT)
|| name.endsWith(BITMAP_EXT) || name.endsWith(BITMAP_EXT)
|| name.endsWith(INDEX_EXT)))
|| name.endsWith(INDEX_EXT)
|| name.endsWith(KEEP_EXT)))
// sort files with same base name in the order:
// .pack, .keep, .index, .bitmap to avoid look ahead
.sorted(Collections.reverseOrder()) .sorted(Collections.reverseOrder())
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (IOException e1) {
// ignore
} catch (IOException e) {
LOG.error(e.getMessage(), e);
return;
} }
if (fileNames == null) { if (fileNames == null) {
return; return;


String base = null; String base = null;
for (String n : fileNames) { for (String n : fileNames) {
if (n.endsWith(PACK_EXT)) {
if (n.endsWith(PACK_EXT) || n.endsWith(KEEP_EXT)) {
base = n.substring(0, n.lastIndexOf('.')); base = n.substring(0, n.lastIndexOf('.'));
} else { } else {
if (base == null || !n.startsWith(base)) { if (base == null || !n.startsWith(base)) {
try { try {
Files.delete(packDir.resolve(n));
Path delete = packDir.resolve(n);
Files.delete(delete);
LOG.warn(JGitText.get().deletedOrphanInPackDir, delete);
} catch (IOException e) { } catch (IOException e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }

+ 0
- 2
org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java View File

*/ */
package org.eclipse.jgit.lib; package org.eclipse.jgit.lib;


import org.eclipse.jgit.lib.AnyObjectId;

/** /**
* A .gitmodules file found in the pack. Store the blob of the file itself (e.g. * A .gitmodules file found in the pack. Store the blob of the file itself (e.g.
* to access its contents) and the tree where it was found (e.g. to check if it * to access its contents) and the tree where it was found (e.g. to check if it

Loading…
Cancel
Save