@@ -464,36 +464,49 @@ export const gitGenerators = {
464464 } satisfies Fig . Generator ,
465465
466466 getStagedFiles : {
467- script : [
468- "bash" ,
469- "-c" ,
470- "git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'" ,
471- ] ,
472- postProcess : postProcessTrackedFiles ,
473- } ,
467+ script : [ "git" , "--no-optional-locks" , "status" , "--short" ] ,
468+ postProcess : ( out , context ) => {
469+ const output = filterMessages ( out ) ;
470+
471+ if ( output . startsWith ( "fatal:" ) ) {
472+ return [ ] ;
473+ }
474+
475+ const filteredLines = output . split ( "\n" ) . filter ( line => {
476+ return line . match ( / ^ M / ) || line . match ( / A / ) ;
477+ } ) ;
478+
479+ return postProcessTrackedFiles ( filteredLines . join ( "\n" ) , context ) ;
480+ } ,
481+ } satisfies Fig . Generator ,
474482
475483 getUnstagedFiles : {
476484 script : [ "git" , "--no-optional-locks" , "diff" , "--name-only" ] ,
477485 splitOn : "\n" ,
478486 } satisfies Fig . Generator ,
479487
480488 getChangedTrackedFiles : {
481- script : function ( context ) {
489+ script : [ "git" , "--no-optional-locks" , "status" , "--short" ] ,
490+ postProcess : ( out , context ) => {
491+ const output = filterMessages ( out ) ;
492+
493+ if ( output . startsWith ( "fatal:" ) ) {
494+ return [ ] ;
495+ }
496+
497+ let filteredLines ;
482498 if ( context . includes ( "--staged" ) || context . includes ( "--cached" ) ) {
483- return [
484- "bash" ,
485- "-c" ,
486- `git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'` ,
487- ] ;
499+ filteredLines = output . split ( "\n" ) . filter ( line => {
500+ return line . match ( / ^ M / ) || line . match ( / A / ) ;
501+ } ) ;
488502 } else {
489- return [
490- "bash" ,
491- "-c" ,
492- `git --no-optional-locks status --short | sed -ne '/M /p' -e '/A /p'` ,
493- ] ;
503+ filteredLines = output . split ( "\n" ) . filter ( line => {
504+ return line . match ( / M / ) || line . match ( / A / ) ;
505+ } ) ;
494506 }
507+
508+ return postProcessTrackedFiles ( filteredLines . join ( "\n" ) , context ) ;
495509 } ,
496- postProcess : postProcessTrackedFiles ,
497510 } satisfies Fig . Generator ,
498511} ;
499512
0 commit comments