]> git.ipfire.org Git - thirdparty/git.git/commit - Makefile
tests: explicitly use `git.exe` on Windows
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 14 Nov 2018 16:32:11 +0000 (08:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Nov 2018 05:18:00 +0000 (14:18 +0900)
commit8abfdf44c882ad5d31bd8d0a0f1bfb67f8a9e39f
treefc29a6ad46fe2531361ac2ffa055dfa13d249bde
parented306e4e0fbb621001f008e6d50718898be4fc09
tests: explicitly use `git.exe` on Windows

On Windows, when we refer to `/an/absolute/path/to/git`, it magically
resolves `git.exe` at that location. Except if something of the name
`git` exists next to that `git.exe`. So if we call `$BUILD_DIR/git`, it
will find `$BUILD_DIR/git.exe` *only* if there is not, say, a directory
called `$BUILD_DIR/git`.

Such a directory, however, exists in Git for Windows when building with
Visual Studio (our Visual Studio project generator defaults to putting
the build files into a directory whose name is the base name of the
corresponding `.exe`).

In the bin-wrappers/* scripts, we already take pains to use `git.exe`
rather than `git`, as this could pick up the wrong thing on Windows
(i.e. if there exists a `git` file or directory in the build directory).

Now we do the same in the tests' start-up code.

This also helps when testing an installed Git, as there might be even
more likely some stray file or directory in the way.

Note: the only way we can record whether the `.exe` suffix is by writing
it to the `GIT-BUILD-OPTIONS` file and sourcing it at the beginning of
`t/test-lib.sh`. This is not a requirement introduced by this patch, but
we move the call to be able to use the `$X` variable that holds the file
extension, if any.

Note also: the many, many calls to `git this` and `git that` are
unaffected, as the regular PATH search will find the `.exe` files on
Windows (and not be confused by a directory of the name `git` that is
in one of the directories listed in the `PATH` variable), while
`/path/to/git` would not, per se, know that it is looking for an
executable and happily prefer such a directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/test-lib-functions.sh
t/test-lib.sh