@@ -5929,6 +5929,60 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
59295929 } ) ;
59305930
59315931 describe ( "commit context" , ( ) => {
5932+ it . effect ( "reads history through a chain of shared clones" , ( ) =>
5933+ Effect . gen ( function * ( ) {
5934+ const root = yield * makeTmpDir ( ) ;
5935+ const fileSystem = yield * FileSystem . FileSystem ;
5936+ const driver = yield * GitVcsDriver . GitVcsDriver ;
5937+ const seed = `${ root } /clone-0` ;
5938+ yield * fileSystem . makeDirectory ( seed ) ;
5939+ yield * initRepoWithCommit ( seed ) ;
5940+ let previous = seed ;
5941+ for ( let index = 1 ; index <= 6 ; index += 1 ) {
5942+ const next = `${ root } /clone-${ index } ` ;
5943+ yield * git ( root , [ "clone" , "--quiet" , "--shared" , previous , next ] ) ;
5944+ previous = next ;
5945+ }
5946+ // Six shared clones deep is within Git's alternate limit, not one level deeper.
5947+ yield * writeTextFile ( previous , "README.md" , "changed\n" ) ;
5948+ const chained = yield * driver . prepareCommitContext ( previous , [ "README.md" ] ) ;
5949+ assert . include ( chained ?. stagedSummary ?? "" , "M\tREADME.md" ) ;
5950+ assert . include ( chained ?. stagedPatch ?? "" , "-# test" ) ;
5951+ } ) ,
5952+ ) ;
5953+
5954+ it . effect ( "leaves no objects behind when no commit follows, in a linked worktree too" , ( ) =>
5955+ Effect . gen ( function * ( ) {
5956+ const repo = yield * makeTmpDir ( ) ;
5957+ yield * initRepoWithCommit ( repo ) ;
5958+ const linked = `${ repo } /linked` ;
5959+ yield * git ( repo , [ "worktree" , "add" , "--quiet" , linked ] ) ;
5960+ const driver = yield * GitVcsDriver . GitVcsDriver ;
5961+
5962+ for ( const cwd of [ repo , linked ] ) {
5963+ yield * writeTextFile ( cwd , "README.md" , `changed in ${ cwd } \n` ) ;
5964+ yield * writeTextFile ( cwd , "draft.txt" , `drafted in ${ cwd } \n` ) ;
5965+ const blobs = [
5966+ yield * git ( cwd , [ "hash-object" , "draft.txt" ] ) ,
5967+ yield * git ( cwd , [ "hash-object" , "README.md" ] ) ,
5968+ ] ;
5969+ const context = yield * driver . prepareCommitContext ( cwd ) ;
5970+ assert . include ( context ?. stagedPatch ?? "" , `+drafted in ${ cwd } ` ) ;
5971+ assert . include ( context ?. stagedPatch ?? "" , "-# test" ) ;
5972+ for ( const blob of blobs ) {
5973+ const probe = yield * driver . execute ( {
5974+ operation : "GitVcsDriver.test.git" ,
5975+ cwd,
5976+ args : [ "cat-file" , "-e" , blob ] ,
5977+ allowNonZeroExit : true ,
5978+ timeoutMs : 10_000 ,
5979+ } ) ;
5980+ assert . notEqual ( probe . exitCode , 0 , `${ blob } stayed in the repository` ) ;
5981+ }
5982+ }
5983+ } ) ,
5984+ ) ;
5985+
59325986 it . effect ( "prepares source patches without running textconv" , ( ) =>
59335987 Effect . gen ( function * ( ) {
59345988 const cwd = yield * makeTmpDir ( ) ;
0 commit comments