@@ -126,9 +126,10 @@ export const installHooks = ({
126126
127127 const directory = path . join ( cwd , resolvedDir , '_' ) ;
128128 const files = Object . entries ( createHookFiles ( ) ) ;
129+ const hooksPathMatches = path . resolve ( cwd , configuredHooksPath ) === directory ;
129130 // Skip all writes only when the config, generated content, and executable modes match.
130131 const unchanged =
131- path . resolve ( cwd , configuredHooksPath ) === directory &&
132+ hooksPathMatches &&
132133 isCurrentFile ( path . join ( directory , '.gitignore' ) , gitignore ) &&
133134 files . every ( ( [ name , content ] ) => isCurrentFile ( path . join ( directory , name ) , content , true ) ) ;
134135
@@ -151,6 +152,11 @@ export const installHooks = ({
151152 return fail ( 'write-failed' , `Failed to write Git hook files: ${ message } ` ) ;
152153 }
153154
155+ // Avoid rewriting .git/config when only the generated files needed repair.
156+ if ( hooksPathMatches ) {
157+ return { status : 'installed' , hooksPath } ;
158+ }
159+
154160 // Point Git at the generated directory only after every runtime file is ready.
155161 const configured = runGit ( cwd , [ 'config' , '--local' , 'core.hooksPath' , hooksPath ] ) ;
156162 if ( configured . error || configured . status === null ) {
0 commit comments