gitk falsely tries executing non-executable files in PATH

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

 



Hello,

I think I encountered a bug or at least unfortunate behavior in gitk
that I noticed the first time with version 2.49.0.

Assume a Linux system. Assume there is a directory /some/dir containing
a file named 'git' which is *not* executable. Also assume that the PATH
variable contains /some/dir somewhere before the directory that
contains the actual git executable. Under these conditions, when gitk
is executed within a Git repository, it shows the misleading message
"Cannot find a git repository here." It seems that gitk tries to
execute /some/dir/git, which fails, because it is not executable. The
error message seems to be just a misleading symptom.

Note that, considering the above conditions, my shell (zsh) and the
which command both resolve git to the actual git executable ignoring
/some/dir/git. I think, also gitk should ignore non-executable files in
the PATH. Currently, gitk seems to check just for existence but not for
executability (see line 82 [1]).

PS: In case you wonder about a use case where a file named git would
end up in the PATH: My PATH looks like PATH=/home/me/overlay:…. For
debugging purposes, I sometimes replace/wrap a binary like git by/in a
script by putting this script into /home/me/overlay. When I am done
with debugging, I often keep the script and just remove the executable
bit assuming it is then ignored by the PATH resolution.

[1] https://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/gitk-git/gitk#L82


[System Info]

git version:
git version 2.49.0
cpu: x86_64
built from commit: 683c54c999c301c2cd6f715c411407c413b1d84e
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.12.1
OpenSSL: OpenSSL 3.4.1 11 Feb 2025
zlib: 1.3.1
uname: Linux 6.13.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 23 Mar 2025
17:17:30 +0000 x86_64
compiler info: gnuc: 14.2
libc info: glibc: 2.41
$SHELL (typically, interactive shell): /usr/bin/zsh

-- 
Regards

Flupp





[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