Skip to content

Commit 0730a5a

Browse files
mark987gitster
authored andcommitted
git-gui - use git-hook, honor core.hooksPath
git-gui currently runs some hooks directly using its own code written before 2010, long predating git v2.9 that added the core.hooksPath configuration to override the assumed location at $GIT_DIR/hooks. Thus, git-gui looks for and runs hooks including prepare-commit-msg, commit-msg, pre-commit, post-commit, and post-checkout from $GIT_DIR/hooks, regardless of configuration. Commands (e.g., git-merge) that git-gui invokes directly do honor core.hooksPath, meaning the overall behaviour is inconsistent. Furthermore, since v2.36 git exposes its hook execution machinery via `git-hook run`, eliminating the need for others to maintain code duplicating that functionality. Using git-hook will both fix git-gui's current issues on hook configuration and (presumably) reduce the maintenance burden going forward. So, teach git-gui to use git-hook. Signed-off-by: Mark Levedahl <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f71c97 commit 0730a5a

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

git-gui.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -661,31 +661,8 @@ proc git_write {args} {
661661
}
662662

663663
proc githook_read {hook_name args} {
664-
set pchook [gitdir hooks $hook_name]
665-
lappend args 2>@1
666-
667-
# On Windows [file executable] might lie so we need to ask
668-
# the shell if the hook is executable. Yes that's annoying.
669-
#
670-
if {[is_Windows]} {
671-
upvar #0 _sh interp
672-
if {![info exists interp]} {
673-
set interp [_which sh]
674-
}
675-
if {$interp eq {}} {
676-
error "hook execution requires sh (not in PATH)"
677-
}
678-
679-
set scr {if test -x "$1";then exec "$@";fi}
680-
set sh_c [list $interp -c $scr $interp $pchook]
681-
return [_open_stdout_stderr [concat $sh_c $args]]
682-
}
683-
684-
if {[file executable $pchook]} {
685-
return [_open_stdout_stderr [concat [list $pchook] $args]]
686-
}
687-
688-
return {}
664+
set cmd [concat git hook run --ignore-missing $hook_name -- $args 2>@1]
665+
return [_open_stdout_stderr $cmd]
689666
}
690667

691668
proc kill_file_process {fd} {

0 commit comments

Comments
 (0)