Re: [PATCH v2] help: improve is_executable() on Windows
From: Junio C Hamano <hidden>
Date: 2017-01-30 17:03:19
Johannes Schindelin [off-list ref] writes:
From: Heiko Voigt <redacted> On Windows, executables need to have the file extension `.exe`, or they are not executables. Hence, to support scripts, Git for Windows also looks for a she-bang line by opening the file in question, and executing it via the specified script interpreter. To figure out whether files in the `PATH` are executable, `git help` has code that imitates this behavior. With one exception: it *always* opens the files and looks for a she-bang line *or* an `MZ` tell-tale (nevermind that files with the magic `MZ` but without file extension `.exe` would still not be executable). Opening this many files leads to performance problems that are even more serious when a virus scanner is running. Therefore, let's change the code to look for the file extension `.exe` early, and avoid opening the file altogether if we already know that it is executable.
Much more readable than the initial round. Will queue; thanks.