git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitk falsely tries executing non-executable files in PATH
@ 2025-03-25 14:11 Toni Dietze
  0 siblings, 0 replies; only message in thread
From: Toni Dietze @ 2025-03-25 14:11 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-25 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 14:11 gitk falsely tries executing non-executable files in PATH Toni Dietze

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).