]> source.dussan.org Git - jgit.git/commitdiff
Add setLength(long) to DirCacheEntry 85/1385/1
authorShawn O. Pearce <spearce@spearce.org>
Mon, 23 Aug 2010 17:29:50 +0000 (10:29 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 23 Aug 2010 17:29:50 +0000 (10:29 -0700)
Applications should favor the long style interface, especially when
their source input is a long type, e.g. coming from java.io.File.
This way when the index format is later changed to support a
larger file size than 2 GiB we can handle it by just changing the
entry code, and not need to fix a lot of applications.

Change-Id: I332563caeb110014e2d544dc33050ce67ae9e897
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java

index 681d289c8416888bbe93a2c40b110a6c2713d6c7..58adf332d351693a1b9b5ab75c7016f21d085f7a 100644 (file)
@@ -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.
index 193d7336790a139b1d9ce28fffd0a8ed753a1a6c..f7eea3fe9f3c446521d060bca2e7107277f1bda7 100644 (file)
@@ -387,6 +387,7 @@ public class JGitText extends TranslationBundle {
        /***/ public String shortReadOfOptionalDIRCExtensionExpectedAnotherBytes;
        /***/ public String shortSkipOfBlock;
        /***/ public String similarityScoreMustBeWithinBounds;
+       /***/ public String sizeExceeds2GB;
        /***/ public String smartHTTPPushDisabled;
        /***/ public String sourceDestinationMustMatch;
        /***/ public String sourceIsNotAWildcard;
index 909729d6c641fe9ff11adc659c2436dcd23df3d7..b7fc1c787dd0c329b4370ebad0a2ec3539031ecc 100644 (file)
@@ -486,6 +486,22 @@ public class DirCacheEntry {
                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.
         * <p>