[PATCH] git-gui - re-enable use of hook scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit aae9560a introduced search in $PATH to find executables before
running them, avoiding an issue where on Windows a same named file in
the current directory can be executed in preference to anything on the
path. The updated search excludes files given with an absolute path (e.g.,
/bin/sh). However this change precludes operation of hook scripts as these
are named with a relative path (.git/hooks/$HOOK), while a search on $PATH
can succeed only for bare file names, not relative paths. Furthermore,
the current repository's .git/hooks directory is in general not listed
in PATH.

Fix this by changing the "absolute" check to a check for more than one
component in the pathname, thereby avoiding the PATH check for anything
given with a relative path as well. Bare "git" has one component, "/sh"
has two components, and .git/hooks/$HOOK has more than two, so relative
and absolute pathnames avoid the check.

Signed-off-by: Mark Levedahl <mlevedahl@xxxxxxxxx>
---
 git-gui.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-gui.sh b/git-gui.sh
index 8bc8892..8603437 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -118,7 +118,7 @@ proc sanitize_command_line {command_line from_index} {
 	set i $from_index
 	while {$i < [llength $command_line]} {
 		set cmd [lindex $command_line $i]
-		if {[file pathtype $cmd] ne "absolute"} {
+		if {[llength [file split $cmd]] < 2} {
 			set fullpath [_which $cmd]
 			if {$fullpath eq ""} {
 				throw {NOT-FOUND} "$cmd not found in PATH"
-- 
2.41.0.99.19




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux