@ -447,19 +447,9 @@ public class DirCacheCheckout {
removeEmptyParents ( file ) ;
removeEmptyParents ( file ) ;
for ( String path : updated . keySet ( ) ) {
for ( String path : updated . keySet ( ) ) {
// ... create/overwrite this file ...
file = new File ( repo . getWorkTree ( ) , path ) ;
if ( ! file . getParentFile ( ) . mkdirs ( ) ) {
// ignore
}
DirCacheEntry entry = dc . getEntry ( path ) ;
DirCacheEntry entry = dc . getEntry ( path ) ;
if ( ! FileMode . GITLINK . equals ( entry . getRawMode ( ) ) )
// submodules are handled with separate operations
checkoutEntry ( repo , entry , objectReader ) ;
if ( FileMode . GITLINK . equals ( entry . getRawMode ( ) ) )
continue ;
checkoutEntry ( repo , file , entry , objectReader ) ;
}
}
// commit the index builder - a new index is persisted
// commit the index builder - a new index is persisted
@ -1158,8 +1148,7 @@ public class DirCacheCheckout {
*
*
* @param repository
* @param repository
* @param f
* @param f
* the file to be modified . The parent directory for this file
* this parameter is ignored .
* has to exist already
* @param entry
* @param entry
* the entry containing new mode and content
* the entry containing new mode and content
* @throws IOException
* @throws IOException
@ -1190,19 +1179,51 @@ public class DirCacheCheckout {
*
*
* @param repo
* @param repo
* @param f
* @param f
* the file to be modified . The parent directory for this file
* this parameter is ignored .
* has to exist already
* @param entry
* @param entry
* the entry containing new mode and content
* the entry containing new mode and content
* @param or
* @param or
* object reader to use for checkout
* object reader to use for checkout
* @throws IOException
* @throws IOException
* @deprecated Do not pass File object .
* /
* /
@Deprecated
public static void checkoutEntry ( final Repository repo , File f ,
public static void checkoutEntry ( final Repository repo , File f ,
DirCacheEntry entry , ObjectReader or ) throws IOException {
DirCacheEntry entry , ObjectReader or ) throws IOException {
if ( f = = null | | repo . getWorkTree ( ) = = null )
throw new IllegalArgumentException ( ) ;
if ( ! f . equals ( new File ( repo . getWorkTree ( ) , entry . getPathString ( ) ) ) )
throw new IllegalArgumentException ( ) ;
checkoutEntry ( repo , entry , or ) ;
}
/ * *
* Updates the file in the working tree with content and mode from an entry
* in the index . The new content is first written to a new temporary file in
* the same directory as the real file . Then that new file is renamed to the
* final filename .
*
* < p >
* TODO : this method works directly on File IO , we may need another
* abstraction ( like WorkingTreeIterator ) . This way we could tell e . g .
* Eclipse that Files in the workspace got changed
* < / p >
*
* @param repo
* repository managing the destination work tree .
* @param entry
* the entry containing new mode and content
* @param or
* object reader to use for checkout
* @throws IOException
* @since 3 . 6
* /
public static void checkoutEntry ( Repository repo , DirCacheEntry entry ,
ObjectReader or ) throws IOException {
ObjectLoader ol = or . open ( entry . getObjectId ( ) ) ;
ObjectLoader ol = or . open ( entry . getObjectId ( ) ) ;
File f = new File ( repo . getWorkTree ( ) , entry . getPathString ( ) ) ;
File parentDir = f . getParentFile ( ) ;
File parentDir = f . getParentFile ( ) ;
parentDir . mkdirs ( ) ;
FileUtils . mkdirs ( parentDir , true ) ;
FS fs = repo . getFS ( ) ;
FS fs = repo . getFS ( ) ;
WorkingTreeOptions opt = repo . getConfig ( ) . get ( WorkingTreeOptions . KEY ) ;
WorkingTreeOptions opt = repo . getConfig ( ) . get ( WorkingTreeOptions . KEY ) ;
if ( entry . getFileMode ( ) = = FileMode . SYMLINK
if ( entry . getFileMode ( ) = = FileMode . SYMLINK