@@ -119,6 +119,38 @@ it.effect("checkpoint capture does not rerun clean filters for unchanged indexed
119119 } ) . pipe ( Effect . scoped , Effect . provide ( GitContractLayer ) ) ,
120120) ;
121121
122+ for ( const timestamp of [ 1_700_000_000 , 1_700_000_000.9999 ] ) {
123+ it . effect (
124+ `checkpoint capture preserves same-size edits with racy index timestamps (${ timestamp } )` ,
125+ ( ) =>
126+ Effect . gen ( function * ( ) {
127+ const fileSystem = yield * FileSystem . FileSystem ;
128+ const path = yield * Path . Path ;
129+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) ;
130+ const cwd = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3-checkpoint-racy-" } ) ;
131+ const { git, checkpointRef } = yield * makeCheckpointFixture ( driver , cwd ) ;
132+ const filePath = path . join ( cwd , "file.txt" ) ;
133+ const indexPath = path . join ( cwd , ".git" , "index" ) ;
134+ yield * git ( [ "config" , "core.trustctime" , "false" ] ) ;
135+ yield * fileSystem . writeFileString ( filePath , "before\n" ) ;
136+ yield * fileSystem . utimes ( filePath , timestamp , timestamp ) ;
137+ yield * git ( [ "add" , "file.txt" ] ) ;
138+ yield * git ( [ "commit" , "-m" , "record racy file" ] ) ;
139+ yield * fileSystem . utimes ( indexPath , timestamp , timestamp ) ;
140+ const originalIndex = yield * fileSystem . readFile ( indexPath ) ;
141+ const originalIndexMtime = ( yield * fileSystem . stat ( indexPath ) ) . mtime ;
142+ yield * fileSystem . writeFileString ( filePath , "after!\n" ) ;
143+ yield * fileSystem . utimes ( filePath , timestamp , timestamp ) ;
144+
145+ yield * driver . checkpoints . captureCheckpoint ( { cwd, checkpointRef } ) ;
146+
147+ assert . strictEqual ( ( yield * git ( [ "show" , `${ checkpointRef } :file.txt` ] ) ) . stdout , "after!\n" ) ;
148+ assert . deepEqual ( yield * fileSystem . readFile ( indexPath ) , originalIndex ) ;
149+ assert . deepEqual ( ( yield * fileSystem . stat ( indexPath ) ) . mtime , originalIndexMtime ) ;
150+ } ) . pipe ( Effect . scoped , Effect . provide ( GitContractLayer ) ) ,
151+ ) ;
152+ }
153+
122154for ( const nested of [ false , true ] ) {
123155 for ( const indexMode of [ "normal" , "flags" , "split" ] as const ) {
124156 it . effect (
0 commit comments