@@ -750,6 +750,17 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
750750 return path . isAbsolute ( gitCommonDir ) ? gitCommonDir : path . resolve ( cwd , gitCommonDir ) ;
751751 } ) ;
752752
753+ // Git renames loose objects and refs into place without fsync by default, so
754+ // an unclean restart can leave 0-byte files under refs/t3/** that break every
755+ // later fetch and push. Checkpoint writes flush before they are published;
756+ // macOS defaults to writeout-only, which does not reach the disk either.
757+ const durableWrite = [
758+ "-c" ,
759+ "core.fsync=objects,reference" ,
760+ "-c" ,
761+ "core.fsyncMethod=fsync" ,
762+ ] as const ;
763+
753764 const checkpoints : VcsDriver . VcsCheckpointOps = {
754765 captureCheckpoint : Effect . fn ( "GitVcsDriver.checkpoints.captureCheckpoint" ) ( function * ( input ) {
755766 const operation = "GitVcsDriver.checkpoints.captureCheckpoint" ;
@@ -907,14 +918,22 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
907918 operation,
908919 cwd : input . cwd ,
909920 // Preserve absent skipped entries, but capture present nonignored files outside the cone.
910- args : [ ...indexConfig , "add" , ...( sparseCheckout ? [ "--sparse" ] : [ ] ) , "-A" , "--" , "." ] ,
921+ args : [
922+ ...indexConfig ,
923+ ...durableWrite ,
924+ "add" ,
925+ ...( sparseCheckout ? [ "--sparse" ] : [ ] ) ,
926+ "-A" ,
927+ "--" ,
928+ "." ,
929+ ] ,
911930 env : commitEnv ,
912931 } ) ;
913932
914933 const writeTreeResult = yield * execute ( {
915934 operation,
916935 cwd : input . cwd ,
917- args : [ ...indexConfig , "write-tree" ] ,
936+ args : [ ...indexConfig , ... durableWrite , "write-tree" ] ,
918937 env : commitEnv ,
919938 } ) ;
920939 const treeOid = writeTreeResult . stdout . trim ( ) ;
@@ -932,7 +951,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
932951 const commitTreeResult = yield * execute ( {
933952 operation,
934953 cwd : input . cwd ,
935- args : [ "commit-tree" , treeOid , "-m" , message ] ,
954+ args : [ ... durableWrite , "commit-tree" , treeOid , "-m" , message ] ,
936955 env : commitEnv ,
937956 } ) ;
938957 const commitOid = commitTreeResult . stdout . trim ( ) ;
@@ -949,7 +968,7 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
949968 yield * execute ( {
950969 operation,
951970 cwd : input . cwd ,
952- args : [ "update-ref" , input . checkpointRef , commitOid ] ,
971+ args : [ ... durableWrite , "update-ref" , input . checkpointRef , commitOid ] ,
953972 } ) ;
954973 } ) . pipe ( Effect . ensuring ( cleanupTempIndex ) ) ;
955974 } ) ,
0 commit comments