@@ -3847,6 +3847,50 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
38473847 } ) ,
38483848 ) ;
38493849
3850+ it . effect . each ( [
3851+ { location : "root" , ref : "refs/heads/MERGE_HEAD" } ,
3852+ { location : "nested" , ref : "refs/heads/MERGE_HEAD" } ,
3853+ { location : "worktree" , ref : "refs/heads/MERGE_HEAD" } ,
3854+ { location : "root" , ref : "refs/tags/MERGE_HEAD" } ,
3855+ { location : "nested" , ref : "refs/tags/MERGE_HEAD" } ,
3856+ { location : "worktree" , ref : "refs/tags/MERGE_HEAD" } ,
3857+ ] ) (
3858+ "commits selected files with a MERGE_HEAD ref and no merge ($location, $ref)" ,
3859+ ( { location, ref } ) =>
3860+ Effect . gen ( function * ( ) {
3861+ let cwd = yield * makeTmpDir ( ) ;
3862+ yield * initRepoWithCommit ( cwd ) ;
3863+ const driver = yield * GitVcsDriver . GitVcsDriver ;
3864+ const fs = yield * FileSystem . FileSystem ;
3865+ const path = yield * Path . Path ;
3866+ const originalHead = yield * git ( cwd , [ "rev-parse" , "HEAD" ] ) ;
3867+ yield * git ( cwd , [ "update-ref" , ref , originalHead ] ) ;
3868+ if ( location === "worktree" ) {
3869+ const linked = path . join ( yield * makeTmpDir ( ) , "linked" ) ;
3870+ yield * git ( cwd , [ "worktree" , "add" , "-b" , "linked" , linked ] ) ;
3871+ cwd = linked ;
3872+ }
3873+ const commitCwd = location === "nested" ? path . join ( cwd , "nested" ) : cwd ;
3874+ yield * fs . makeDirectory ( commitCwd , { recursive : true } ) ;
3875+ yield * writeTextFile ( cwd , "selected.txt" , "selected\n" ) ;
3876+ yield * writeTextFile ( cwd , "unrelated.txt" , "unrelated\n" ) ;
3877+ const mergePath = yield * git ( commitCwd , [ "rev-parse" , "--git-path" , "MERGE_HEAD" ] ) ;
3878+ assert . isFalse ( yield * fs . exists ( path . resolve ( commitCwd , mergePath ) ) ) ;
3879+
3880+ yield * driver . commit ( commitCwd , "Selected without merge" , "" , {
3881+ stage : { filePaths : [ "selected.txt" ] } ,
3882+ } ) ;
3883+
3884+ assert . equal ( yield * git ( cwd , [ "show" , "-s" , "--format=%P" , "HEAD" ] ) , originalHead ) ;
3885+ assert . equal (
3886+ yield * git ( cwd , [ "show" , "--pretty=" , "--name-only" , "HEAD" ] ) ,
3887+ "selected.txt" ,
3888+ ) ;
3889+ assert . equal ( yield * git ( cwd , [ "rev-parse" , ref ] ) , originalHead ) ;
3890+ assert . include ( yield * git ( cwd , [ "status" , "--porcelain" ] ) , "?? unrelated.txt" ) ;
3891+ } ) ,
3892+ ) ;
3893+
38503894 it . effect . each ( [
38513895 { location : "root" , conflict : false } ,
38523896 { location : "nested" , conflict : false } ,
0 commit comments