badObjectType=Bad object type: {0}
badRef=Bad ref: {0}: {1}
badSectionEntry=Bad section entry: {0}
-badShallowLine=Bad shallow line: {0}
+badShallowLine=Shallow file ''{0}'' has bad line: {1}
bareRepositoryNoWorkdirAndIndex=Bare Repository has neither a working tree, nor an index
base85invalidChar=Invalid base-85 character: 0x{0}
base85length=Base-85 encoded data must have a length that is a multiple of 5
pushOptionsNotSupported=Push options not supported; received {0}
rawLogMessageDoesNotParseAsLogEntry=Raw log message does not parse as log entry
readConfigFailed=Reading config file ''{0}'' failed
+readShallowFailed=Reading shallow file ''{0}'' failed
readFileStoreAttributesFailed=Reading FileStore attributes from user config failed
readerIsRequired=Reader is required
readingObjectsFromLocalRepositoryFailed=reading objects from local repository failed: {0}
/***/ public String pushOptionsNotSupported;
/***/ public String rawLogMessageDoesNotParseAsLogEntry;
/***/ public String readConfigFailed;
+ /***/ public String readShallowFailed;
/***/ public String readFileStoreAttributesFailed;
/***/ public String readerIsRequired;
/***/ public String readingObjectsFromLocalRepositoryFailed;
if (shallowFileSnapshot == null
|| shallowFileSnapshot.isModified(shallowFile)) {
- shallowCommitsIds = new HashSet<>();
-
- try (BufferedReader reader = open(shallowFile)) {
- String line;
- while ((line = reader.readLine()) != null) {
- try {
- shallowCommitsIds.add(ObjectId.fromString(line));
- } catch (IllegalArgumentException ex) {
- throw new IOException(MessageFormat
- .format(JGitText.get().badShallowLine, line),
- ex);
- }
- }
+ try {
+ shallowCommitsIds = FileUtils.readWithRetries(shallowFile,
+ f -> {
+ FileSnapshot newSnapshot = FileSnapshot.save(f);
+ HashSet<ObjectId> result = new HashSet<>();
+ try (BufferedReader reader = open(f)) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (!ObjectId.isId(line)) {
+ throw new IOException(
+ MessageFormat.format(JGitText
+ .get().badShallowLine,
+ f.getAbsolutePath(),
+ line));
+
+ }
+ result.add(ObjectId.fromString(line));
+ }
+ }
+ shallowFileSnapshot = newSnapshot;
+ return result;
+ });
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOException(
+ MessageFormat.format(JGitText.get().readShallowFailed,
+ shallowFile.getAbsolutePath()),
+ e);
}
-
- shallowFileSnapshot = FileSnapshot.save(shallowFile);
}
return shallowCommitsIds;