@@ -1449,6 +1449,51 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
14491449 } ) ,
14501450 ) ;
14511451
1452+ for ( const [ timestamp , splitIndex ] of [
1453+ [ 1_700_000_000 , false ] ,
1454+ [ 1_700_000_000.9999 , false ] ,
1455+ [ 1_700_000_000 , true ] ,
1456+ [ 1_700_000_000.9999 , true ] ,
1457+ ] as const ) {
1458+ it . effect (
1459+ `preserves same-size edits with a racy review index (${ timestamp } , split: ${ splitIndex } )` ,
1460+ ( ) =>
1461+ Effect . gen ( function * ( ) {
1462+ const cwd = yield * makeTmpDir ( ) ;
1463+ yield * initRepoWithCommit ( cwd ) ;
1464+ const driver = yield * GitVcsDriver . GitVcsDriver ;
1465+ const fileSystem = yield * FileSystem . FileSystem ;
1466+ const path = yield * Path . Path ;
1467+ const filePath = path . join ( cwd , "tracked.txt" ) ;
1468+ const indexPath = path . join ( cwd , ".git" , "index" ) ;
1469+ // Reproduce a same-timestamp edit without relying on filesystem clock resolution.
1470+ yield * git ( cwd , [ "config" , "core.trustctime" , "false" ] ) ;
1471+ yield * writeTextFile ( cwd , "tracked.txt" , "before\n" ) ;
1472+ yield * fileSystem . utimes ( filePath , timestamp , timestamp ) ;
1473+ yield * git ( cwd , [ "add" , "tracked.txt" ] ) ;
1474+ yield * git ( cwd , [ "commit" , "-m" , "record racy file" ] ) ;
1475+ if ( splitIndex ) yield * git ( cwd , [ "update-index" , "--split-index" ] ) ;
1476+ yield * fileSystem . utimes ( indexPath , timestamp , timestamp ) ;
1477+ const originalIndex = yield * fileSystem . readFile ( indexPath ) ;
1478+ const originalIndexMtime = ( yield * fileSystem . stat ( indexPath ) ) . mtime ;
1479+ yield * writeTextFile ( cwd , "tracked.txt" , "after!\n" ) ;
1480+ yield * fileSystem . utimes ( filePath , timestamp , timestamp ) ;
1481+ yield * writeTextFile ( cwd , "untracked.txt" , "new\n" ) ;
1482+
1483+ const preview = yield * driver . getReviewDiffPreview ( { cwd } ) ;
1484+ const dirty = preview . sources . find ( ( source ) => source . kind === "working-tree" ) ! ;
1485+ assert . deepStrictEqual ( dirty . files , [
1486+ { path : "tracked.txt" , previousPath : null , additions : 1 , deletions : 1 } ,
1487+ { path : "untracked.txt" , previousPath : null , additions : 1 , deletions : 0 } ,
1488+ ] ) ;
1489+ assert . include ( dirty . diff , "-before" ) ;
1490+ assert . include ( dirty . diff , "+after!" ) ;
1491+ assert . deepStrictEqual ( yield * fileSystem . readFile ( indexPath ) , originalIndex ) ;
1492+ assert . deepStrictEqual ( ( yield * fileSystem . stat ( indexPath ) ) . mtime , originalIndexMtime ) ;
1493+ } ) ,
1494+ ) ;
1495+ }
1496+
14521497 it . effect ( "keeps complete stats for files beyond the combined patch limit" , ( ) =>
14531498 Effect . gen ( function * ( ) {
14541499 const cwd = yield * makeTmpDir ( ) ;
0 commit comments