git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Levedahl <mlevedahl@gmail.com>
To: gitster@pobox.com, johannes.schindelin@gmx.de,
	me@yadavpratyush.com, git@vger.kernel.org
Cc: Mark Levedahl <mlevedahl@gmail.com>
Subject: [PATCH] git-gui - use git-hook, honor core.hooksPath
Date: Sun, 17 Sep 2023 15:24:31 -0400	[thread overview]
Message-ID: <20230917192431.101775-1-mlevedahl@gmail.com> (raw)
In-Reply-To: <fa876f80-02dc-2c04-0db3-bf3f6269b427@gmail.com>

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 exection 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 <mlevedahl@gmail.com>
---
 git-gui.sh | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 8603437..3e5907a 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -661,31 +661,8 @@ proc git_write {args} {
 }
 
 proc githook_read {hook_name args} {
-	set pchook [gitdir hooks $hook_name]
-	lappend args 2>@1
-
-	# On Windows [file executable] might lie so we need to ask
-	# the shell if the hook is executable.  Yes that's annoying.
-	#
-	if {[is_Windows]} {
-		upvar #0 _sh interp
-		if {![info exists interp]} {
-			set interp [_which sh]
-		}
-		if {$interp eq {}} {
-			error "hook execution requires sh (not in PATH)"
-		}
-
-		set scr {if test -x "$1";then exec "$@";fi}
-		set sh_c [list $interp -c $scr $interp $pchook]
-		return [_open_stdout_stderr [concat $sh_c $args]]
-	}
-
-	if {[file executable $pchook]} {
-		return [_open_stdout_stderr [concat [list $pchook] $args]]
-	}
-
-	return {}
+	set cmd [concat git hook run --ignore-missing $hook_name -- $args 2>@1]
+	return [_open_stdout_stderr $cmd]
 }
 
 proc kill_file_process {fd} {
-- 
2.41.0.99.19


  reply	other threads:[~2023-09-17 19:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 16:45 BUG: git-gui no longer executes hook scripts Mark Levedahl
2023-09-15 17:00 ` Junio C Hamano
2023-09-15 17:15   ` Junio C Hamano
2023-09-15 23:33     ` Mark Levedahl
2023-09-16  0:35       ` [PATCH] git-gui - re-enable use of " Mark Levedahl
2023-09-16 17:28         ` Junio C Hamano
2023-09-16 21:01           ` [PATCH v2] " Mark Levedahl
2023-09-16 21:51             ` Junio C Hamano
2023-09-17 19:22               ` Mark Levedahl
2023-09-17 19:24                 ` Mark Levedahl [this message]
2023-09-18 15:27                   ` [PATCH] git-gui - use git-hook, honor core.hooksPath Johannes Schindelin
2023-09-18 15:58                     ` Junio C Hamano
2023-09-18 16:25                       ` Mark Levedahl
2023-09-18 17:53                         ` Junio C Hamano
2023-09-20 13:05                   ` Pratyush Yadav
2023-09-20 15:30                     ` Mark Levedahl
2023-09-20 16:58                       ` Junio C Hamano
2023-09-20 15:49                     ` Junio C Hamano
2023-09-18 15:26             ` [PATCH v2] git-gui - re-enable use of hook scripts Johannes Schindelin
2023-09-18 16:04               ` Junio C Hamano
2023-09-20 13:27             ` Pratyush Yadav
2023-09-16  4:45       ` BUG: git-gui no longer executes " Junio C Hamano
2023-09-16 12:56         ` Mark Levedahl
2023-09-16 14:49           ` Mark Levedahl
2023-09-16 17:31             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230917192431.101775-1-mlevedahl@gmail.com \
    --to=mlevedahl@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=me@yadavpratyush.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).