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 5f420ab18..399436dfa 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -465,6 +465,7 @@ packDoesNotMatchIndex=Pack {0} does not match index packedRefsHandleIsStale=packed-refs handle is stale, {0}. retry packetSizeMustBeAtLeast=packet size {0} must be >= {1} packetSizeMustBeAtMost=packet size {0} must be <= {1} +packedRefsCorruptionDetected=packed-refs corruption detected: {0} packfileCorruptionDetected=Packfile corruption detected: {0} packFileInvalid=Pack file invalid: {0} packfileIsTruncated=Packfile {0} is truncated. 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 e920554a4..00d019184 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -524,6 +524,7 @@ public class JGitText extends TranslationBundle { /***/ public String packedRefsHandleIsStale; /***/ public String packetSizeMustBeAtLeast; /***/ public String packetSizeMustBeAtMost; + /***/ public String packedRefsCorruptionDetected; /***/ public String packfileCorruptionDetected; /***/ public String packFileInvalid; /***/ public String packfileIsTruncated; 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 108065913..e3d0d6162 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 @@ -843,6 +843,11 @@ public class RefDirectory extends RefDatabase { } int sp = p.indexOf(' '); + if (sp < 0) { + throw new IOException(MessageFormat.format( + JGitText.get().packedRefsCorruptionDetected, + packedRefsFile.getAbsolutePath())); + } ObjectId id = ObjectId.fromString(p.substring(0, sp)); String name = copy(p, sp + 1, p.length()); ObjectIdRef cur;