From: Toni Dietze <git-at-vger.kernel.org@derflupp.e4ward.com>
To: git@vger.kernel.org
Subject: gitk falsely tries executing non-executable files in PATH
Date: Tue, 25 Mar 2025 15:11:51 +0100 [thread overview]
Message-ID: <553b40dd-b054-430c-a596-43cd240f7f82@mx1.e4ward.com> (raw)
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
reply other threads:[~2025-03-25 14:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=553b40dd-b054-430c-a596-43cd240f7f82@mx1.e4ward.com \
--to=git-at-vger.kernel.org@derflupp.e4ward.com \
--cc=git@vger.kernel.org \
/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).