diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties index 681d289c8..58adf332d 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties @@ -328,6 +328,7 @@ shortReadOfBlock=Short read of block. shortReadOfOptionalDIRCExtensionExpectedAnotherBytes=Short read of optional DIRC extension {0}; expected another {1} bytes within the section. shortSkipOfBlock=Short skip of block. similarityScoreMustBeWithinBounds=Similarity score must be between 0 and 100. +sizeExceeds2GB=Path {0} size {1} exceeds 2 GiB limit. smartHTTPPushDisabled=smart HTTP push disabled sourceDestinationMustMatch=Source/Destination must match. sourceIsNotAWildcard=Source is not a wildcard. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java index 193d73367..f7eea3fe9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java @@ -387,6 +387,7 @@ public static JGitText get() { /***/ public String shortReadOfOptionalDIRCExtensionExpectedAnotherBytes; /***/ public String shortSkipOfBlock; /***/ public String similarityScoreMustBeWithinBounds; + /***/ public String sizeExceeds2GB; /***/ public String smartHTTPPushDisabled; /***/ public String sourceDestinationMustMatch; /***/ public String sourceIsNotAWildcard; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index 909729d6c..b7fc1c787 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -486,6 +486,22 @@ public void setLength(final int sz) { NB.encodeInt32(info, infoOffset + P_SIZE, sz); } + /** + * Set the cached size (in bytes) of this file. + * + * @param sz + * new cached size of the file, as bytes. + * @throws IllegalArgumentException + * if the size exceeds the 2 GiB barrier imposed by current file + * format limitations. + */ + public void setLength(final long sz) { + if (Integer.MAX_VALUE <= sz) + throw new IllegalArgumentException(MessageFormat.format(JGitText + .get().sizeExceeds2GB, getPathString(), sz)); + setLength((int) sz); + } + /** * Obtain the ObjectId for the entry. *