Log loose ref deletion during ref cleanup Add log messages when loose refs are deleted while deleting refs or packing refs. These messages make it easier to investigate unexpected loose ref deletions by recording which loose ref file was removed and from which cleanup path the deletion originated. Change-Id: I8a114404200934189bc1098757b1ce854b4e59ee
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 e24cba6..dffb849 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -259,6 +259,7 @@ deepenSinceWithDeepen=Cannot combine deepen with deepen-since deleteBranchUnexpectedResult=Delete branch returned unexpected result {0} deleteFileFailed=Could not delete file {0} +deleteLooseRef=Deleted loose ref {}, object Id {} deletedOrphanInPackDir=Deleted orphaned file {} deleteRequiresZeroNewId=Delete requires new ID to be zero deleteTagUnexpectedResult=Delete tag returned unexpected result {0}
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 8928f47..10c2b29 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -289,6 +289,7 @@ public static JGitText get() { /***/ public String deepenSinceWithDeepen; /***/ public String deleteBranchUnexpectedResult; /***/ public String deleteFileFailed; + /***/ public String deleteLooseRef; /***/ public String deletedOrphanInPackDir; /***/ public String deleteRequiresZeroNewId; /***/ public String deleteTagUnexpectedResult;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 8548271..91f7b24 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
@@ -740,7 +740,11 @@ void delete(RefDirectoryUpdate update) throws IOException { int levels = levelsIn(name) - 2; delete(logFor(name), levels); if (dst.getStorage().isLoose()) { - deleteAndUnlock(fileFor(name), levels, update); + File refFile = fileFor(name); + ObjectId refObjectId = dst.getObjectId(); + deleteAndUnlock(refFile, levels, update); + LOG.debug(JGitText.get().deleteLooseRef, + refFile, refObjectId); } } finally { lck.unlock(); @@ -866,6 +870,7 @@ private void pack(Collection<String> refs, } while (!looseRefs.compareAndSet(curLoose, newLoose)); int levels = levelsIn(refName) - 2; deleteAndUnlock(refFile, levels, rLck); + LOG.debug(JGitText.get().deleteLooseRef, refFile, clr_oid); } } finally { if (shouldUnlock) {