diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-11-26 15:37:19 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-11-26 15:37:19 +0100 |
commit | 3f85d3b75c559bd44b333a2ae66ceb6b93022000 (patch) | |
tree | c55f9cce3207e1fc421d18f7446f7923872dfb69 /org.eclipse.jgit | |
parent | 003e4cfc237a2bcf9349665e3578bead06c120c3 (diff) | |
parent | 65598b95161e3766c31bddeb45bc5d628b6d90fd (diff) | |
download | jgit-3f85d3b75c559bd44b333a2ae66ceb6b93022000.tar.gz jgit-3f85d3b75c559bd44b333a2ae66ceb6b93022000.zip |
Merge branch 'stable-5.2' into stable-5.3
* stable-5.2:
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: Id9386846a202b5ae98dd602744963f8897ddaa8c
Diffstat (limited to 'org.eclipse.jgit')
4 files changed, 15 insertions, 7 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 43946265ce..324302c14b 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -204,6 +204,7 @@ deepenNotWithDeepen=Cannot combine deepen with deepen-not deepenSinceWithDeepen=Cannot combine deepen with deepen-since deleteBranchUnexpectedResult=Delete branch returned unexpected result {0} deleteFileFailed=Could not delete file {0} +deletedOrphanInPackDir=Deleted orphaned file {} deleteRequiresZeroNewId=Delete requires new ID to be zero deleteTagUnexpectedResult=Delete tag returned unexpected result {0} deletingNotSupported=Deleting {0} not supported. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index d51e052b03..59e6d24ca2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -265,6 +265,7 @@ public class JGitText extends TranslationBundle { /***/ public String deepenSinceWithDeepen; /***/ public String deleteBranchUnexpectedResult; /***/ public String deleteFileFailed; + /***/ public String deletedOrphanInPackDir; /***/ public String deleteRequiresZeroNewId; /***/ public String deleteTagUnexpectedResult; /***/ public String deletingNotSupported; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 7400308c86..104d8d4364 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -148,6 +148,8 @@ public class GC { 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_AUTOLIMIT = 6700; @@ -978,11 +980,15 @@ public class GC { fileNames = files.map(path -> path.getFileName().toString()) .filter(name -> (name.endsWith(PACK_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()) .collect(Collectors.toList()); - } catch (IOException e1) { - // ignore + } catch (IOException e) { + LOG.error(e.getMessage(), e); + return; } if (fileNames == null) { return; @@ -990,12 +996,14 @@ public class GC { String base = null; for (String n : fileNames) { - if (n.endsWith(PACK_EXT)) { + if (n.endsWith(PACK_EXT) || n.endsWith(KEEP_EXT)) { base = n.substring(0, n.lastIndexOf('.')); } else { if (base == null || !n.startsWith(base)) { try { - Files.delete(packDir.resolve(n)); + Path delete = packDir.resolve(n); + Files.delete(delete); + LOG.warn(JGitText.get().deletedOrphanInPackDir, delete); } catch (IOException e) { LOG.error(e.getMessage(), e); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java index bded527519..4f2e558b26 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java @@ -42,8 +42,6 @@ */ 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. * to access its contents) and the tree where it was found (e.g. to check if it |