@ -61,7 +61,6 @@ import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectLoader ;
import org.eclipse.jgit.lib.Repository ;
import org.eclipse.jgit.lib.StoredConfig ;
import org.eclipse.jgit.treewalk.AbstractTreeIterator ;
import org.eclipse.jgit.treewalk.CanonicalTreeParser ;
import org.eclipse.jgit.treewalk.EmptyTreeIterator ;
@ -184,9 +183,7 @@ public class DirCacheCheckout {
* /
public DirCacheCheckout ( Repository repo , ObjectId headCommitTree ,
DirCache dc , ObjectId mergeCommitTree ) throws IOException {
this ( repo , headCommitTree , dc , mergeCommitTree , new FileTreeIterator (
repo . getWorkTree ( ) , repo . getFS ( ) ,
WorkingTreeOptions . createDefaultInstance ( ) ) ) ;
this ( repo , headCommitTree , dc , mergeCommitTree , new FileTreeIterator ( repo ) ) ;
}
/ * *
@ -224,9 +221,7 @@ public class DirCacheCheckout {
* /
public DirCacheCheckout ( Repository repo , DirCache dc ,
ObjectId mergeCommitTree ) throws IOException {
this ( repo , null , dc , mergeCommitTree , new FileTreeIterator (
repo . getWorkTree ( ) , repo . getFS ( ) ,
WorkingTreeOptions . createDefaultInstance ( ) ) ) ;
this ( repo , null , dc , mergeCommitTree , new FileTreeIterator ( repo ) ) ;
}
/ * *
@ -311,7 +306,7 @@ public class DirCacheCheckout {
if ( m ! = null ) {
if ( i = = null | | f = = null | | ! m . idEqual ( i )
| | ( i . getDirCacheEntry ( ) ! = null & & ( f . isModified (
i . getDirCacheEntry ( ) , true , config_filemode ( ) ) | |
i . getDirCacheEntry ( ) , true ) | |
i . getDirCacheEntry ( ) . getStage ( ) ! = 0 ) ) ) {
update ( m . getEntryPathString ( ) , m . getEntryObjectId ( ) ,
m . getEntryFileMode ( ) ) ;
@ -391,7 +386,7 @@ public class DirCacheCheckout {
file . getParentFile ( ) . mkdirs ( ) ;
file . createNewFile ( ) ;
DirCacheEntry entry = dc . getEntry ( path ) ;
checkoutEntry ( repo , file , entry , config_filemode ( ) ) ;
checkoutEntry ( repo , file , entry ) ;
}
@ -575,7 +570,7 @@ public class DirCacheCheckout {
case 0xFFD : // 12 13 14
if ( hId . equals ( iId ) ) {
dce = i . getDirCacheEntry ( ) ;
if ( f = = null | | f . isModified ( dce , true , config_filemode ( ) ) )
if ( f = = null | | f . isModified ( dce , true ) )
conflict ( name , i . getDirCacheEntry ( ) , h , m ) ;
else
remove ( name ) ;
@ -641,8 +636,7 @@ public class DirCacheCheckout {
if ( m = = null | | mId . equals ( iId ) ) {
if ( m = = null & & walk . isDirectoryFileConflict ( ) ) {
if ( dce ! = null
& & ( f = = null | | f . isModified ( dce , true ,
config_filemode ( ) ) ) )
& & ( f = = null | | f . isModified ( dce , true ) ) )
conflict ( name , i . getDirCacheEntry ( ) , h , m ) ;
else
remove ( name ) ;
@ -664,7 +658,7 @@ public class DirCacheCheckout {
* /
if ( hId . equals ( iId ) ) {
if ( f = = null | | f . isModified ( dce , true , config_filemode ( ) ) )
if ( f = = null | | f . isModified ( dce , true ) )
conflict ( name , i . getDirCacheEntry ( ) , h , m ) ;
else
remove ( name ) ;
@ -674,9 +668,7 @@ public class DirCacheCheckout {
if ( ! hId . equals ( mId ) & & ! hId . equals ( iId ) & & ! mId . equals ( iId ) )
conflict ( name , i . getDirCacheEntry ( ) , h , m ) ;
else if ( hId . equals ( iId ) & & ! mId . equals ( iId ) ) {
if ( dce ! = null
& & ( f = = null | | f . isModified ( dce , true ,
config_filemode ( ) ) ) )
if ( dce ! = null & & ( f = = null | | f . isModified ( dce , true ) ) )
conflict ( name , i . getDirCacheEntry ( ) , h , m ) ;
else
update ( name , mId , m . getEntryFileMode ( ) ) ;
@ -738,19 +730,6 @@ public class DirCacheCheckout {
}
}
private Boolean filemode ;
private boolean config_filemode ( ) {
// TODO: temporary till we can actually set parameters. We need to be
// able to change this for testing.
if ( filemode = = null ) {
StoredConfig config = repo . getConfig ( ) ;
filemode = Boolean . valueOf ( config . getBoolean ( "core" , null ,
"filemode" , true ) ) ;
}
return filemode . booleanValue ( ) ;
}
/ * *
* If < code > true < / code > , will scan first to see if it ' s possible to check
* out , otherwise throw { @link CheckoutConflictException } . If
@ -790,8 +769,7 @@ public class DirCacheCheckout {
private boolean isModified ( String path ) throws CorruptObjectException , IOException {
NameConflictTreeWalk tw = new NameConflictTreeWalk ( repo ) ;
tw . addTree ( new DirCacheIterator ( dc ) ) ;
tw . addTree ( new FileTreeIterator ( repo . getWorkTree ( ) , repo . getFS ( ) ,
WorkingTreeOptions . createDefaultInstance ( ) ) ) ;
tw . addTree ( new FileTreeIterator ( repo ) ) ;
tw . setRecursive ( true ) ;
tw . setFilter ( PathFilter . create ( path ) ) ;
DirCacheIterator dcIt ;
@ -801,8 +779,7 @@ public class DirCacheCheckout {
wtIt = tw . getTree ( 1 , WorkingTreeIterator . class ) ;
if ( dcIt = = null | | wtIt = = null )
return true ;
if ( wtIt . isModified ( dcIt . getDirCacheEntry ( ) , true ,
config_filemode ( ) ) ) {
if ( wtIt . isModified ( dcIt . getDirCacheEntry ( ) , true ) ) {
return true ;
}
}
@ -824,12 +801,10 @@ public class DirCacheCheckout {
* has to exist already
* @param entry
* the entry containing new mode and content
* @param config_filemode
* whether the mode bits should be handled at all .
* @throws IOException
* /
public static void checkoutEntry ( final Repository repo , File f , DirCacheEntry entry ,
boolean config_filemode ) throws IOException {
public static void checkoutEntry ( final Repository repo , File f ,
DirCacheEntry entry ) throws IOException {
ObjectLoader ol = repo . open ( entry . getObjectId ( ) ) ;
File parentDir = f . getParentFile ( ) ;
File tmpFile = File . createTempFile ( "._" + f . getName ( ) , null , parentDir ) ;
@ -840,7 +815,8 @@ public class DirCacheCheckout {
channel . close ( ) ;
}
FS fs = repo . getFS ( ) ;
if ( config_filemode & & fs . supportsExecute ( ) ) {
WorkingTreeOptions opt = repo . getConfig ( ) . get ( WorkingTreeOptions . KEY ) ;
if ( opt . isFileMode ( ) & & fs . supportsExecute ( ) ) {
if ( FileMode . EXECUTABLE_FILE . equals ( entry . getRawMode ( ) ) ) {
if ( ! fs . canExecute ( tmpFile ) )
fs . setExecute ( tmpFile , true ) ;