Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <bk2204@github.com>2023-06-27 19:18:57 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-27 21:31:05 +0300
commit1e6572122702cbf0e3b6d3226f73e6b8b45e6e37 (patch)
tree6a6bab9c2cd02d79d8d04de41c7dcfa11e40784d /t/t0007-git-var.sh
parentd6546af75c3cda2815f2e4d5322dd7a41cc0963b (diff)
var: add support for listing the shell
On most Unix systems, finding a suitable shell is easy: one simply uses "sh" with an appropriate PATH value. However, in many Windows environments, the shell is shipped alongside Git, and it may or may not be in PATH, even if Git is. In such an environment, it can be very helpful to query Git for the shell it's using, since other tools may want to use the same shell as well. To help them out, let's add a variable, GIT_SHELL_PATH, that points to the location of the shell. On Unix, we know our shell must be executable to be functional, so assume that the distributor has correctly configured their environment, and use that as a basic test. On Git for Windows, we know that our shell will be one of a few fixed values, all of which end in "sh" (such as "bash"). This seems like it might be a nice test on Unix as well, since it is customary for all shells to end in "sh", but there probably exist such systems that don't have such a configuration, so be careful here not to break them. Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0007-git-var.sh')
-rwxr-xr-xt/t0007-git-var.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh
index eeb8539c1b..e35f07afcb 100755
--- a/t/t0007-git-var.sh
+++ b/t/t0007-git-var.sh
@@ -147,6 +147,21 @@ test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration and environment
)
'
+test_expect_success POSIXPERM 'GIT_SHELL_PATH points to a valid executable' '
+ shellpath=$(git var GIT_SHELL_PATH) &&
+ test_path_is_executable "$shellpath"
+'
+
+# We know in this environment that our shell will be one of a few fixed values
+# that all end in "sh".
+test_expect_success MINGW 'GIT_SHELL_PATH points to a suitable shell' '
+ shellpath=$(git var GIT_SHELL_PATH) &&
+ case "$shellpath" in
+ *sh) ;;
+ *) return 1;;
+ esac
+'
+
# For git var -l, we check only a representative variable;
# testing the whole output would make our test too brittle with
# respect to unrelated changes in the test suite's environment.