git/list[1] front-page[2] threads[3] people[4] search[5] about
 

gitk falsely tries executing non-executable files in PATH

From
TDToni Dietze <git-at-vger.kernel.org@derflupp.e4ward.com>
Date
Mar 25, 2025, 14:11 UTC
Message-ID
<553b40dd-b054-430c-a596-43cd240f7f82@mx1.e4ward.com>
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
Message 1 of 1 in “gitk falsely tries executing non-executable files in PATH”
  1. Toni DietzeMar 25, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.