@@ -3838,6 +3838,33 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
38383838 } ) ,
38393839 ) ;
38403840
3841+ it . effect ( "leaves a folder alone that only shares the worktree's short name" , ( ) =>
3842+ Effect . gen ( function * ( ) {
3843+ const cwd = yield * makeTmpDir ( ) ;
3844+ const { initialBranch } = yield * initRepoWithCommit ( cwd ) ;
3845+ const pathService = yield * Path . Path ;
3846+ const fileSystem = yield * FileSystem . FileSystem ;
3847+ const driver = yield * GitVcsDriver . GitVcsDriver ;
3848+ const worktreePath = pathService . join ( yield * makeTmpDir ( "git-worktrees-" ) , "short" ) ;
3849+ yield * driver . createWorktree ( {
3850+ cwd,
3851+ path : worktreePath ,
3852+ refName : initialBranch ,
3853+ newRefName : "feature/short" ,
3854+ } ) ;
3855+ // Unrelated to the worktree, but resolving "short" against cwd lands here.
3856+ const outside = yield * makeTmpDir ( "git-worktree-link-target-" ) ;
3857+ const unrelated = pathService . join ( cwd , "short" ) ;
3858+ NodeFS . mkdirSync ( unrelated ) ;
3859+ NodeFS . symlinkSync ( outside , pathService . join ( unrelated , "linked" ) , "junction" ) ;
3860+
3861+ yield * Effect . result ( driver . removeWorktree ( { cwd, path : "short" } ) ) ;
3862+
3863+ assert . isTrue ( NodeFS . lstatSync ( pathService . join ( unrelated , "linked" ) ) . isSymbolicLink ( ) ) ;
3864+ assert . equal ( yield * fileSystem . exists ( worktreePath ) , true ) ;
3865+ } ) ,
3866+ ) ;
3867+
38413868 it . effect ( "allows worktree removal to run longer than the default command timeout" , ( ) =>
38423869 Effect . gen ( function * ( ) {
38433870 const delegate = yield * ChildProcessSpawner . ChildProcessSpawner ;
0 commit comments