@@ -373,27 +373,52 @@ const make = Effect.gen(function* () {
373373 // No-overlay checkout carries deletions; read-tree unstages edits without moving the branch.
374374 yield * git ( input . worktreePath , [ "checkout" , "--no-overlay" , input . snapshot , "--" , "." ] ) ;
375375 yield * git ( input . worktreePath , [ "read-tree" , "-m" , input . tip ] ) ;
376- // Keep carried force-added ignored files visible to the next commit or handoff.
377- const ignored = yield * git (
376+ // Only snapshot additions qualify; checkout hooks can also produce ignored local files.
377+ // Prefix paths so check-ignore does not interpret literal names as pathspec magic.
378+ const added = yield * git (
378379 input . worktreePath ,
379- [ "ls-files" , "-z" , "--others" , "--ignored" , "--exclude-standard" ] ,
380+ [
381+ "diff" ,
382+ "-z" ,
383+ "--name-only" ,
384+ "--line-prefix=./" ,
385+ "--no-renames" ,
386+ "--diff-filter=A" ,
387+ input . tip ,
388+ input . snapshot ,
389+ ] ,
380390 { maxOutputBytes : 16 * 1024 * 1024 , outputMode : "error" } ,
381391 ) ;
382- if ( ignored . stdout !== "" ) {
383- yield * git (
392+ if ( added . stdout !== "" ) {
393+ const ignored = yield * git (
384394 input . worktreePath ,
385- [
386- "--literal-pathspecs" ,
387- "add" ,
388- "--intent-to-add" ,
389- "--force" ,
390- "--pathspec-from-file=-" ,
391- "--pathspec-file-nul" ,
392- ] ,
393- { stdin : ignored . stdout } ,
395+ [ "check-ignore" , "-z" , "--stdin" , "--no-index" ] ,
396+ {
397+ stdin : added . stdout ,
398+ allowNonZeroExit : true ,
399+ maxOutputBytes : 16 * 1024 * 1024 ,
400+ outputMode : "error" ,
401+ } ,
394402 ) ;
395- // An intent entry can displace a tracked ancestor in a file-to-directory replacement.
396- yield * git ( input . worktreePath , [ "diff" , "--cached" , "--quiet" , input . tip ] ) ;
403+ if ( ignored . exitCode !== 0 && ignored . exitCode !== 1 ) {
404+ return yield * new HandoffGitStepError ( { step : "check-ignore" , cause : ignored } ) ;
405+ }
406+ if ( ignored . stdout !== "" ) {
407+ yield * git (
408+ input . worktreePath ,
409+ [
410+ "--literal-pathspecs" ,
411+ "add" ,
412+ "--intent-to-add" ,
413+ "--force" ,
414+ "--pathspec-from-file=-" ,
415+ "--pathspec-file-nul" ,
416+ ] ,
417+ { stdin : ignored . stdout } ,
418+ ) ;
419+ // An intent entry can displace a tracked ancestor in a file-to-directory replacement.
420+ yield * git ( input . worktreePath , [ "diff" , "--cached" , "--quiet" , input . tip ] ) ;
421+ }
397422 }
398423 return {
399424 branch,
0 commit comments