@ -65,6 +65,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.util.IO ;
import org.eclipse.jgit.util.IO ;
import org.eclipse.jgit.util.MutableInteger ;
import org.eclipse.jgit.util.MutableInteger ;
import org.eclipse.jgit.util.NB ;
import org.eclipse.jgit.util.NB ;
import org.eclipse.jgit.util.SystemReader ;
/ * *
/ * *
* A single file ( or stage of a file ) in a { @link DirCache } .
* A single file ( or stage of a file ) in a { @link DirCache } .
@ -191,7 +192,7 @@ public class DirCacheEntry {
}
}
try {
try {
DirCa cheChe ckout . checkValid Path( toString ( path ) ) ;
checkPath ( path ) ;
} catch ( InvalidPathException e ) {
} catch ( InvalidPathException e ) {
CorruptObjectException p =
CorruptObjectException p =
new CorruptObjectException ( e . getMessage ( ) ) ;
new CorruptObjectException ( e . getMessage ( ) ) ;
@ -263,7 +264,7 @@ public class DirCacheEntry {
/ * *
/ * *
* Create an empty entry at the specified stage .
* Create an empty entry at the specified stage .
*
*
* @param newP ath
* @param p ath
* name of the cache entry , in the standard encoding .
* name of the cache entry , in the standard encoding .
* @param stage
* @param stage
* the stage index of the new entry .
* the stage index of the new entry .
@ -274,16 +275,16 @@ public class DirCacheEntry {
* range 0 . . 3 , inclusive .
* range 0 . . 3 , inclusive .
* /
* /
@SuppressWarnings ( "boxing" )
@SuppressWarnings ( "boxing" )
public DirCacheEntry ( final byte [ ] newP ath, final int stage ) {
public DirCacheEntry ( byte [ ] p ath, final int stage ) {
DirCa cheChe ckout . checkValid Path( toString ( newPa th) ) ;
checkPath ( pa th) ;
if ( stage < 0 | | 3 < stage )
if ( stage < 0 | | 3 < stage )
throw new IllegalArgumentException ( MessageFormat . format (
throw new IllegalArgumentException ( MessageFormat . format (
JGitText . get ( ) . invalidStageForPath ,
JGitText . get ( ) . invalidStageForPath ,
stage , toString ( newP ath) ) ) ;
stage , toString ( p ath) ) ) ;
info = new byte [ INFO_LEN ] ;
info = new byte [ INFO_LEN ] ;
infoOffset = 0 ;
infoOffset = 0 ;
path = newP ath;
this . path = p ath;
int flags = ( ( stage & 0x3 ) < < 12 ) ;
int flags = ( ( stage & 0x3 ) < < 12 ) ;
if ( path . length < NAME_MASK )
if ( path . length < NAME_MASK )
@ -730,6 +731,16 @@ public class DirCacheEntry {
return 0 ;
return 0 ;
}
}
private static void checkPath ( byte [ ] path ) {
try {
SystemReader . getInstance ( ) . checkPath ( path ) ;
} catch ( CorruptObjectException e ) {
InvalidPathException p = new InvalidPathException ( toString ( path ) ) ;
p . initCause ( e ) ;
throw p ;
}
}
private static String toString ( final byte [ ] path ) {
private static String toString ( final byte [ ] path ) {
return Constants . CHARSET . decode ( ByteBuffer . wrap ( path ) ) . toString ( ) ;
return Constants . CHARSET . decode ( ByteBuffer . wrap ( path ) ) . toString ( ) ;
}
}