@ -62,6 +62,7 @@ import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason ;
import org.eclipse.jgit.revwalk.RevCommit ;
import org.eclipse.jgit.treewalk.FileTreeIterator ;
import org.eclipse.jgit.util.FS ;
import org.eclipse.jgit.util.FileUtils ;
import org.junit.Assert ;
import org.junit.experimental.theories.DataPoint ;
@ -694,7 +695,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
// Create initial content and remember when the last file was written.
f = writeTrashFiles ( false , "orig" , "orig" , "1\n2\n3" , "orig" , "orig" ) ;
lastTs4 = f . lastModified ( ) ;
lastTs4 = FS . DETECTED . lastModified ( f ) ;
// add all files, commit and check this doesn't update any working tree
// files and that the index is in a new file system timer tick. Make
@ -707,8 +708,8 @@ public class ResolveMergerTest extends RepositoryTestCase {
checkConsistentLastModified ( "0" , "1" , "2" , "3" , "4" ) ;
checkModificationTimeStampOrder ( "1" , "2" , "3" , "4" , "<.git/index" ) ;
assertEquals ( "Commit should not touch working tree file 4" , lastTs4 ,
new File ( db . getWorkTree ( ) , "4" ) . lastModified ( ) ) ;
lastTsIndex = indexFile . lastModified ( ) ;
FS . DETECTED . lastModified ( new File ( db . getWorkTree ( ) , "4" ) ) ) ;
lastTsIndex = FS . DETECTED . lastModified ( indexFile ) ;
// Do modifications on the master branch. Then add and commit. This
// should touch only "0", "2 and "3"
@ -722,7 +723,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
checkConsistentLastModified ( "0" , "1" , "2" , "3" , "4" ) ;
checkModificationTimeStampOrder ( "1" , "4" , "*" + lastTs4 , "<*"
+ lastTsIndex , "<0" , "2" , "3" , "<.git/index" ) ;
lastTsIndex = indexFile . lastModified ( ) ;
lastTsIndex = FS . DETECTED . lastModified ( indexFile ) ;
// Checkout a side branch. This should touch only "0", "2 and "3"
fsTick ( indexFile ) ;
@ -731,7 +732,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
checkConsistentLastModified ( "0" , "1" , "2" , "3" , "4" ) ;
checkModificationTimeStampOrder ( "1" , "4" , "*" + lastTs4 , "<*"
+ lastTsIndex , "<0" , "2" , "3" , ".git/index" ) ;
lastTsIndex = indexFile . lastModified ( ) ;
lastTsIndex = FS . DETECTED . lastModified ( indexFile ) ;
// This checkout may have populated worktree and index so fast that we
// may have smudged entries now. Check that we have the right content
@ -744,13 +745,13 @@ public class ResolveMergerTest extends RepositoryTestCase {
indexState ( CONTENT ) ) ;
fsTick ( indexFile ) ;
f = writeTrashFiles ( false , "orig" , "orig" , "1\n2\n3" , "orig" , "orig" ) ;
lastTs4 = f . lastModified ( ) ;
lastTs4 = FS . DETECTED . lastModified ( f ) ;
fsTick ( f ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
checkConsistentLastModified ( "0" , "1" , "2" , "3" , "4" ) ;
checkModificationTimeStampOrder ( "*" + lastTsIndex , "<0" , "1" , "2" , "3" ,
"4" , "<.git/index" ) ;
lastTsIndex = indexFile . lastModified ( ) ;
lastTsIndex = FS . DETECTED . lastModified ( indexFile ) ;
// Do modifications on the side branch. Touch only "1", "2 and "3"
fsTick ( indexFile ) ;
@ -761,7 +762,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
checkConsistentLastModified ( "0" , "1" , "2" , "3" , "4" ) ;
checkModificationTimeStampOrder ( "0" , "4" , "*" + lastTs4 , "<*"
+ lastTsIndex , "<1" , "2" , "3" , "<.git/index" ) ;
lastTsIndex = indexFile . lastModified ( ) ;
lastTsIndex = FS . DETECTED . lastModified ( indexFile ) ;
// merge master and side. Should only touch "0," "2" and "3"
fsTick ( indexFile ) ;
@ -789,7 +790,7 @@ public class ResolveMergerTest extends RepositoryTestCase {
"IndexEntry with path "
+ path
+ " has lastmodified with is different from the worktree file" ,
new File ( workTree , path ) . lastModified ( ) , dc . getEntry ( path )
FS . DETECTED . lastModified ( new File ( workTree , path ) ) , dc . getEntry ( path )
. getLastModified ( ) ) ;
}
@ -799,14 +800,15 @@ public class ResolveMergerTest extends RepositoryTestCase {
// then this file must be younger then file i. A path "*<modtime>"
// represents a file with a modification time of <modtime>
// E.g. ("a", "b", "<c", "f/a.txt") means: a<=b<c<=f/a.txt
private void checkModificationTimeStampOrder ( String . . . pathes ) {
private void checkModificationTimeStampOrder ( String . . . pathes )
throws IOException {
long lastMod = Long . MIN_VALUE ;
for ( String p : pathes ) {
boolean strong = p . startsWith ( "<" ) ;
boolean fixed = p . charAt ( strong ? 1 : 0 ) = = '*' ;
p = p . substring ( ( strong ? 1 : 0 ) + ( fixed ? 1 : 0 ) ) ;
long curMod = fixed ? Long . valueOf ( p ) . longValue ( ) : new File (
db . getWorkTree ( ) , p ) . lastModified ( ) ;
long curMod = fixed ? Long . valueOf ( p ) . longValue ( )
: FS . DETECTED . lastModified ( new File ( db . getWorkTree ( ) , p ) ) ;
if ( strong )
assertTrue ( "path " + p + " is not younger than predecesssor" ,
curMod > lastMod ) ;