@@ -597,7 +597,17 @@ it.effect.each(
597597 Effect . gen ( function * ( ) {
598598 const fs = yield * FileSystem . FileSystem ;
599599 const path = yield * Path . Path ;
600- const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) ;
600+ const liveProcess = yield * VcsProcess . VcsProcess ;
601+ let freshReadTrees = 0 ;
602+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) . pipe (
603+ Effect . provideService ( VcsProcess . VcsProcess , {
604+ run : ( input ) => {
605+ if ( input . args . includes ( "read-tree" ) && input . args . includes ( "index.sparse=true" ) )
606+ freshReadTrees ++ ;
607+ return liveProcess . run ( input ) ;
608+ } ,
609+ } ) ,
610+ ) ;
601611 const cwd = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-checkpoint-sparse-" } ) ;
602612 const { git } = yield * makeCheckpointFixture ( driver , cwd ) ;
603613 const write = Effect . fn ( function * ( name : string , contents : string ) {
@@ -680,11 +690,12 @@ it.effect.each(
680690 "working outside\n" ,
681691 ) ;
682692 }
693+ assert . strictEqual ( freshReadTrees , indexState === "missing" ? 2 : 0 ) ;
683694 } ) . pipe ( Effect . scoped , Effect . provide ( layerGitContract ) ) ,
684695) ;
685696
686697it . effect . each (
687- ( [ "normal" , "flags " , "sparse" ] as const ) . flatMap ( ( indexMode ) =>
698+ ( [ "normal" , "skip-worktree" , "assume-unchanged ", "sparse" ] as const ) . flatMap ( ( indexMode ) =>
688699 [ 1 , 3 , 4096 ] . map ( ( chunkSize ) => ( { indexMode, chunkSize } ) ) ,
689700 ) ,
690701) (
@@ -700,26 +711,39 @@ it.effect.each(
700711 yield * fs . writeFileString ( path . join ( cwd , ".gitattributes" ) , "stable filter=probe\n" ) ;
701712 yield * fs . writeFileString ( path . join ( cwd , "stable" ) , "unchanged\n" ) ;
702713 yield * fs . writeFileString ( path . join ( cwd , "z-skipped" ) , "original\n" ) ;
714+ yield * fs . writeFileString ( path . join ( cwd , "z-deleted" ) , "original\n" ) ;
703715 yield * fs . makeDirectory ( path . join ( cwd , "excluded" ) ) ;
704716 yield * fs . writeFileString ( path . join ( cwd , "excluded/file" ) , "absent\n" ) ;
705717 yield * fs . writeFileString (
706718 path . join ( cwd , ".git/filter.cjs" ) ,
707719 'require("node:fs").appendFileSync(".git/reads", "read\\n"); process.stdin.pipe(process.stdout);' ,
708720 ) ;
709721 yield * git ( [ "config" , "filter.probe.clean" , "node .git/filter.cjs" ] ) ;
722+ yield * git ( [ "config" , "core.trustctime" , "false" ] ) ;
710723 yield * fs . utimes ( path . join ( cwd , "stable" ) , 1_700_000_000 , 1_700_000_000 ) ;
724+ yield * fs . utimes ( path . join ( cwd , "z-skipped" ) , 1_700_000_000 , 1_700_000_000 ) ;
711725 yield * git ( [ "add" , "." ] ) ;
712726 yield * git ( [ "commit" , "-m" , "inspection fixture" ] ) ;
713- if ( indexMode === "flags" ) yield * git ( [ "update-index" , "--skip-worktree" , "z-skipped" ] ) ;
727+ const flagged = indexMode === "skip-worktree" || indexMode === "assume-unchanged" ;
728+ if ( flagged ) {
729+ yield * git ( [ "update-index" , `--${ indexMode } ` , "z-skipped" , "z-deleted" ] ) ;
730+ yield * git ( [ "config" , "core.ignorestat" , "true" ] ) ;
731+ yield * fs . remove ( path . join ( cwd , "z-deleted" ) ) ;
732+ }
714733 if ( indexMode === "sparse" )
715734 yield * git ( [ "sparse-checkout" , "set" , "--cone" , "--sparse-index" , "included" ] ) ;
716735 yield * fs . writeFileString ( path . join ( cwd , "z-skipped" ) , "modified\n" ) ;
736+ // A flagged edit with the indexed size and mtime is invisible to Git's stat check.
737+ if ( flagged ) yield * fs . utimes ( path . join ( cwd , "z-skipped" ) , 1_700_000_000 , 1_700_000_000 ) ;
717738 yield * fs . writeFileString ( path . join ( cwd , ".git/reads" ) , "" ) ;
718739 const originalIndex = yield * fs . readFile ( path . join ( cwd , ".git/index" ) ) ;
740+ let freshReadTrees = 0 ;
719741 const captureDriver = yield * GitVcsDriver . makeVcsDriverShape ( ) . pipe (
720742 Effect . provideService ( VcsProcess . VcsProcess , {
721- run : ( input ) =>
722- liveProcess . run (
743+ run : ( input ) => {
744+ if ( input . args . includes ( "read-tree" ) && ! input . args . includes ( "--reset" ) )
745+ freshReadTrees ++ ;
746+ return liveProcess . run (
723747 input . args . includes ( "ls-files" )
724748 ? {
725749 ...input ,
@@ -730,13 +754,19 @@ it.effect.each(
730754 } ,
731755 }
732756 : input ,
733- ) ,
757+ ) ;
758+ } ,
734759 } ) ,
735760 ) ;
736761 yield * captureDriver . checkpoints . captureCheckpoint ( { cwd, checkpointRef } ) ;
737762 assert . strictEqual ( ( yield * git ( [ "show" , `${ checkpointRef } :z-skipped` ] ) ) . stdout , "modified\n" ) ;
738- if ( indexMode !== "flags" )
739- assert . strictEqual ( yield * fs . readFileString ( path . join ( cwd , ".git/reads" ) ) , "" ) ;
763+ const files = ( yield * git ( [ "ls-tree" , "-z" , "--name-only" , checkpointRef ] ) ) . stdout . split (
764+ "\0" ,
765+ ) ;
766+ if ( flagged ) assert . notInclude ( files , "z-deleted" ) ;
767+ else assert . include ( files , "z-deleted" ) ;
768+ assert . strictEqual ( freshReadTrees , 0 ) ;
769+ assert . strictEqual ( yield * fs . readFileString ( path . join ( cwd , ".git/reads" ) ) , "" ) ;
740770 assert . deepEqual ( yield * fs . readFile ( path . join ( cwd , ".git/index" ) ) , originalIndex ) ;
741771 } ) . pipe ( Effect . scoped , Effect . provide ( layerGitContract ) ) ,
742772) ;
0 commit comments