@@ -120,7 +120,13 @@ it.effect("checkpoint capture does not rerun clean filters for unchanged indexed
120120) ;
121121
122122for ( const nested of [ false , true ] ) {
123- for ( const indexState of [ "sparse" , "flags" , "missing" , "non-cone-missing" ] as const ) {
123+ for ( const indexState of [
124+ "sparse" ,
125+ "flags" ,
126+ "manual-skip" ,
127+ "missing" ,
128+ "non-cone-missing" ,
129+ ] as const ) {
124130 it . effect (
125131 `sparse checkpoint preserves two captures (nested=${ nested } , index=${ indexState } )` ,
126132 ( ) =>
@@ -137,7 +143,7 @@ for (const nested of [false, true]) {
137143 for ( const name of [
138144 "scope/in/edit" ,
139145 "scope/in/delete" ,
140- "scope/out/absent" ,
146+ "scope/out/deep/ absent" ,
141147 "scope/out/present" ,
142148 "elsewhere/file" ,
143149 ] ) {
@@ -160,6 +166,8 @@ for (const nested of [false, true]) {
160166 yield * git ( [ "add" , "." ] ) ;
161167 if ( indexState === "flags" )
162168 yield * git ( [ "update-index" , "--assume-unchanged" , "scope/in/delete" ] ) ;
169+ if ( indexState === "manual-skip" )
170+ yield * git ( [ "update-index" , "--skip-worktree" , "scope/in/delete" ] ) ;
163171 yield * git ( [ "config" , "sparse.expectFilesOutsideOfPatterns" , "true" ] ) ;
164172 yield * write ( "scope/in/edit" , "working\n" ) ;
165173 yield * write ( "scope/out/present" , "modified skipped\n" ) ;
@@ -193,7 +201,7 @@ for (const nested of [false, true]) {
193201 }
194202 yield * capture ;
195203 for ( const [ name , content ] of [
196- [ "scope/out/absent" , "original\n" ] ,
204+ [ "scope/out/deep/ absent" , "original\n" ] ,
197205 [ "scope/out/present" , "modified skipped\n" ] ,
198206 [ "scope/in/edit" , turn === 1 ? "working\n" : "second\n" ] ,
199207 [ "elsewhere/file" , nested ? "original\n" : "working outside\n" ] ,
@@ -211,7 +219,7 @@ for (const nested of [false, true]) {
211219 yield * fs . readFile ( indexPath ) . pipe ( Effect . orElseSucceed ( ( ) => null ) ) ,
212220 originalIndex ,
213221 ) ;
214- assert . isFalse ( yield * fs . exists ( path . join ( cwd , "scope/out/absent" ) ) ) ;
222+ assert . isFalse ( yield * fs . exists ( path . join ( cwd , "scope/out/deep/ absent" ) ) ) ;
215223 assert . strictEqual (
216224 yield * fs . readFileString ( path . join ( cwd , "elsewhere/file" ) ) ,
217225 "working outside\n" ,
@@ -222,6 +230,46 @@ for (const nested of [false, true]) {
222230 }
223231}
224232
233+ it . effect ( "checkpoint capture keeps the legacy path when Git lacks add --sparse" , ( ) =>
234+ Effect . gen ( function * ( ) {
235+ const fs = yield * FileSystem . FileSystem ;
236+ const path = yield * Path . Path ;
237+ const liveProcess = yield * VcsProcess . VcsProcess ;
238+ const driver = yield * GitVcsDriver . makeVcsDriverShape ( ) ;
239+ const cwd = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-checkpoint-legacy-" } ) ;
240+ const { git, checkpointRef } = yield * makeCheckpointFixture ( driver , cwd ) ;
241+ yield * git ( [ "sparse-checkout" , "set" , "--cone" , "included" ] ) ;
242+ const originalIndex = yield * fs . readFile ( path . join ( cwd , ".git/index" ) ) ;
243+ const captureDriver = yield * GitVcsDriver . makeVcsDriverShape ( ) . pipe (
244+ Effect . provideService ( VcsProcess . VcsProcess , {
245+ run : ( input ) => {
246+ if ( input . args . includes ( "-h" ) )
247+ return Effect . succeed ( {
248+ exitCode : ChildProcessSpawner . ExitCode ( 129 ) ,
249+ stdout : "usage: git add" ,
250+ stderr : "" ,
251+ stdoutTruncated : false ,
252+ stderrTruncated : false ,
253+ } ) ;
254+ return liveProcess . run (
255+ input . args . includes ( "--sparse" )
256+ ? {
257+ ...input ,
258+ args : input . args . map ( ( arg ) =>
259+ arg === "--sparse" ? "--unsupported-sparse" : arg ,
260+ ) ,
261+ }
262+ : input ,
263+ ) ;
264+ } ,
265+ } ) ,
266+ ) ;
267+ yield * captureDriver . checkpoints . captureCheckpoint ( { cwd, checkpointRef } ) ;
268+ assert . strictEqual ( ( yield * git ( [ "show" , `${ checkpointRef } :file.txt` ] ) ) . stdout , "unstaged\n" ) ;
269+ assert . deepEqual ( yield * fs . readFile ( path . join ( cwd , ".git/index" ) ) , originalIndex ) ;
270+ } ) . pipe ( Effect . scoped , Effect . provide ( GitContractLayer ) ) ,
271+ ) ;
272+
225273for ( const indexMode of [ "normal" , "flags" , "sparse" ] as const ) {
226274 it . effect (
227275 `checkpoint index inspection handles entries beyond the output cap (index=${ indexMode } )` ,
0 commit comments