@ -67,6 +67,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectInserter ;
import org.eclipse.jgit.storage.file.LockFile ;
import org.eclipse.jgit.util.FS ;
import org.eclipse.jgit.util.IO ;
import org.eclipse.jgit.util.MutableInteger ;
import org.eclipse.jgit.util.NB ;
@ -129,7 +130,7 @@ public class DirCache {
* memory ) .
* /
public static DirCache newInCore ( ) {
return new DirCache ( null ) ;
return new DirCache ( null , null ) ;
}
/ * *
@ -141,6 +142,9 @@ public class DirCache {
*
* @param indexLocation
* location of the index file on disk .
* @param fs
* the file system abstraction which will be necessary to perform
* certain file system operations .
* @return a cache representing the contents of the specified index file ( if
* it exists ) or an empty cache if the file does not exist .
* @throws IOException
@ -149,9 +153,9 @@ public class DirCache {
* the index file is using a format or extension that this
* library does not support .
* /
public static DirCache read ( final File indexLocation )
public static DirCache read ( final File indexLocation , final FS fs )
throws CorruptObjectException , IOException {
final DirCache c = new DirCache ( indexLocation ) ;
final DirCache c = new DirCache ( indexLocation , fs ) ;
c . read ( ) ;
return c ;
}
@ -166,6 +170,9 @@ public class DirCache {
*
* @param indexLocation
* location of the index file on disk .
* @param fs
* the file system abstraction which will be necessary to perform
* certain file system operations .
* @return a cache representing the contents of the specified index file ( if
* it exists ) or an empty cache if the file does not exist .
* @throws IOException
@ -175,9 +182,9 @@ public class DirCache {
* the index file is using a format or extension that this
* library does not support .
* /
public static DirCache lock ( final File indexLocation )
public static DirCache lock ( final File indexLocation , final FS fs )
throws CorruptObjectException , IOException {
final DirCache c = new DirCache ( indexLocation ) ;
final DirCache c = new DirCache ( indexLocation , fs ) ;
if ( ! c . lock ( ) )
throw new IOException ( MessageFormat . format ( JGitText . get ( ) . cannotLock , indexLocation ) ) ;
@ -215,6 +222,9 @@ public class DirCache {
/** Our active lock (if we hold it); null if we don't have it locked. */
private LockFile myLock ;
/** file system abstraction **/
private final FS fs ;
/ * *
* Create a new in - core index representation .
* < p >
@ -223,9 +233,13 @@ public class DirCache {
*
* @param indexLocation
* location of the index file on disk .
* @param fs
* the file system abstraction which will be necessary to perform
* certain file system operations .
* /
public DirCache ( final File indexLocation ) {
public DirCache ( final File indexLocation , final FS fs ) {
liveFile = indexLocation ;
this . fs = fs ;
clear ( ) ;
}
@ -429,7 +443,7 @@ public class DirCache {
public boolean lock ( ) throws IOException {
if ( liveFile = = null )
throw new IOException ( JGitText . get ( ) . dirCacheDoesNotHaveABackingFile ) ;
final LockFile tmp = new LockFile ( liveFile ) ;
final LockFile tmp = new LockFile ( liveFile , fs ) ;
if ( tmp . lock ( ) ) {
tmp . setNeedStatInformation ( true ) ;
myLock = tmp ;