{"thread":{"id":"63190","subject":"gitk falsely tries executing non-executable files in PATH","startedAt":"2025-03-25T14:24:03Z","lastAt":"2025-03-25T14:24:03Z","messageCount":1,"participants":["Toni Dietze"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"515022","messageId":"553b40dd-b054-430c-a596-43cd240f7f82@mx1.e4ward.com","threadId":"63190","inReplyTo":null,"subject":"gitk falsely tries executing non-executable files in PATH","fromName":"Toni Dietze","fromEmail":"git-at-vger.kernel.org@derflupp.e4ward.com","sentAt":"2025-03-25T14:11:51Z","receivedAt":"2025-03-25T14:24:03Z","isPatch":false,"sender":{"key":"git-at-vger.kernel.org@derflupp.e4ward.com","avatar":null},"body":"Hello,\n\nI think I encountered a bug or at least unfortunate behavior in gitk\nthat I noticed the first time with version 2.49.0.\n\nAssume a Linux system. Assume there is a directory /some/dir containing\na file named 'git' which is *not* executable. Also assume that the PATH\nvariable contains /some/dir somewhere before the directory that\ncontains the actual git executable. Under these conditions, when gitk\nis executed within a Git repository, it shows the misleading message\n\"Cannot find a git repository here.\" It seems that gitk tries to\nexecute /some/dir/git, which fails, because it is not executable. The\nerror message seems to be just a misleading symptom.\n\nNote that, considering the above conditions, my shell (zsh) and the\nwhich command both resolve git to the actual git executable ignoring\n/some/dir/git. I think, also gitk should ignore non-executable files in\nthe PATH. Currently, gitk seems to check just for existence but not for\nexecutability (see line 82 [1]).\n\nPS: In case you wonder about a use case where a file named git would\nend up in the PATH: My PATH looks like PATH=/home/me/overlay:…. For\ndebugging purposes, I sometimes replace/wrap a binary like git by/in a\nscript by putting this script into /home/me/overlay. When I am done\nwith debugging, I often keep the script and just remove the executable\nbit assuming it is then ignored by the PATH resolution.\n\n[1] https://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/gitk-git/gitk#L82\n\n\n[System Info]\n\ngit version:\ngit version 2.49.0\ncpu: x86_64\nbuilt from commit: 683c54c999c301c2cd6f715c411407c413b1d84e\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 8.12.1\nOpenSSL: OpenSSL 3.4.1 11 Feb 2025\nzlib: 1.3.1\nuname: Linux 6.13.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 23 Mar 2025\n17:17:30 +0000 x86_64\ncompiler info: gnuc: 14.2\nlibc info: glibc: 2.41\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n-- \nRegards\n\nFlupp\n"}]}