From: Junio C Hamano Date: Fri, 23 Mar 2012 19:31:03 GMT Subject: Re: [GIT GUI PATCH 1/2] git-gui: teach _which procedure to work with absolute paths Message-ID: <7v8virt8qw.fsf@alter.siamese.dyndns.org> In-Reply-To: Heiko Voigt writes: > _which is useful to check whether a certain command can be called. > Previously when given an absolute path it would not recognize it as > an existing program. Lets change that so it transparently handles such > cases. > > Signed-off-by: Heiko Voigt > --- > git-gui/git-gui.sh | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh > index ba4e5c1..35cdee8 100755 > --- a/git-gui/git-gui.sh > +++ b/git-gui/git-gui.sh > @@ -429,6 +429,10 @@ proc _git_cmd {name} { > proc _which {what args} { > global env _search_exe _search_path > > + if {[file exists $what]} { > + return [file normalize $what] > + } Has $what been verified that it is either an absolute path, or contains a directory separator, at this point in the code? Otherwise, "_which Makefile" would say "Yeah, that is the one I will launch" in a directory that has a "Makefile" even when the user does not have "." in his $PATH, no? > if {$_search_path eq {}} { > if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} { > set _search_path [split [exec cygpath \