Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2015-01-21 21:27:46 +0000
committerMatthias Sohn2015-01-21 21:27:46 +0000
commite7f153bf3a28139a40faf5dde5270da0ce50aa4b (patch)
tree4e1b535bf931164a22084f6512b28beb8a00d4a7
parente09e7c064e93684aa1ce8f67186e0613bc432d18 (diff)
parent58f3ecea9b7779b349964fa12fb1d47cbd77540d (diff)
downloadjgit-e7f153bf3a28139a40faf5dde5270da0ce50aa4b.tar.gz
jgit-e7f153bf3a28139a40faf5dde5270da0ce50aa4b.tar.xz
jgit-e7f153bf3a28139a40faf5dde5270da0ce50aa4b.zip
Merge remote-tracking branch 'origin/stable-3.6'
* origin/stable-3.6: Prepare 3.6.3-SNAPSHOT builds JGit v3.6.2.201501210735-r Don't remove pack from pack list for problems which could be transient Log reason for ignoring pack when IOException occurred Change-Id: I61141b52839511d58e5a5b193bfde31e9f444a6c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java40
3 files changed, 34 insertions, 10 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 a753188e88..55cf3ea71e 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -145,6 +145,7 @@ couldNotRenameTemporaryIndexFileToIndex=Could not rename temporary index file to
couldNotURLEncodeToUTF8=Could not URL encode to UTF-8
couldNotWriteFile=Could not write file {0}
countingObjects=Counting objects
+corruptPack=Pack file {0} is corrupt
createBranchFailedUnknownReason=Create branch failed for unknown reason
createBranchUnexpectedResult=Create branch returned unexpected result {0}
createNewFileFailed=Could not create new file {0}
@@ -207,6 +208,7 @@ exceptionCaughtDuringExecutionOfRmCommand=Exception caught during execution of r
exceptionCaughtDuringExecutionOfTagCommand=Exception caught during execution of tag command
exceptionOccurredDuringAddingOfOptionToALogCommand=Exception occurred during adding of {0} as option to a Log command
exceptionOccurredDuringReadingOfGIT_DIR=Exception occurred during reading of $GIT_DIR/{0}. {1}
+exceptionWhileReadingPack=ERROR: Exception caught while accessing pack file {0}, the pack file might be corrupt
expectedACKNAKFoundEOF=Expected ACK/NAK, found EOF
expectedACKNAKGot=Expected ACK/NAK, got: {0}
expectedBooleanStringValue=Expected boolean string value
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 65272fb0bd..fd38dc1491 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -190,6 +190,7 @@ public class JGitText extends TranslationBundle {
/***/ public String corruptObjectNotree;
/***/ public String corruptObjectNoType;
/***/ public String corruptObjectPackfileChecksumIncorrect;
+ /***/ public String corruptPack;
/***/ public String couldNotCheckOutBecauseOfConflicts;
/***/ public String couldNotDeleteLockFileShouldNotHappen;
/***/ public String couldNotDeleteTemporaryIndexFileShouldNotHappen;
@@ -266,6 +267,7 @@ public class JGitText extends TranslationBundle {
/***/ public String exceptionCaughtDuringExecutionOfTagCommand;
/***/ public String exceptionOccurredDuringAddingOfOptionToALogCommand;
/***/ public String exceptionOccurredDuringReadingOfGIT_DIR;
+ /***/ public String exceptionWhileReadingPack;
/***/ public String expectedACKNAKFoundEOF;
/***/ public String expectedACKNAKGot;
/***/ public String expectedBooleanStringValue;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 58276051ea..76fadefe53 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -52,6 +52,8 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -64,6 +66,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.jgit.errors.CorruptObjectException;
+import org.eclipse.jgit.errors.PackInvalidException;
import org.eclipse.jgit.errors.PackMismatchException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
@@ -328,9 +332,7 @@ public class ObjectDirectory extends FileObjectDatabase {
try {
p.resolve(matches, id, RESOLVE_ABBREV_LIMIT);
} catch (IOException e) {
- // Assume the pack is corrupted.
- //
- removePack(p);
+ handlePackError(e, p);
}
if (matches.size() > RESOLVE_ABBREV_LIMIT)
return;
@@ -417,8 +419,7 @@ public class ObjectDirectory extends FileObjectDatabase {
if (searchPacksAgain(pList))
continue SEARCH;
} catch (IOException e) {
- // Assume the pack is corrupted.
- removePack(p);
+ handlePackError(e, p);
}
}
break SEARCH;
@@ -498,8 +499,7 @@ public class ObjectDirectory extends FileObjectDatabase {
if (searchPacksAgain(pList))
continue SEARCH;
} catch (IOException e) {
- // Assume the pack is corrupted.
- removePack(p);
+ handlePackError(e, p);
}
}
break SEARCH;
@@ -540,9 +540,7 @@ public class ObjectDirectory extends FileObjectDatabase {
pList = scanPacks(pList);
continue SEARCH;
} catch (IOException e) {
- // Assume the pack is corrupted.
- //
- removePack(p);
+ handlePackError(e, p);
}
}
break SEARCH;
@@ -552,6 +550,28 @@ public class ObjectDirectory extends FileObjectDatabase {
h.db.selectObjectRepresentation(packer, otp, curs);
}
+ private void handlePackError(IOException e, PackFile p) {
+ String tmpl;
+ if ((e instanceof CorruptObjectException)
+ || (e instanceof PackInvalidException)) {
+ tmpl = JGitText.get().corruptPack;
+ // Assume the pack is corrupted, and remove it from the list.
+ removePack(p);
+ } else {
+ tmpl = JGitText.get().exceptionWhileReadingPack;
+ // Don't remove the pack from the list, as the error may be
+ // transient.
+ }
+ StringBuilder buf = new StringBuilder(MessageFormat.format(tmpl,
+ p.getPackFile().getAbsolutePath()));
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ buf.append('\n');
+ buf.append(sw.toString());
+ // TODO instead of syserr we should use a logging framework
+ System.err.println(buf.toString());
+ }
+
@Override
InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId id,
boolean createDuplicate) throws IOException {

Back to the top