diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt index f40202b8e3ab52..f0f647e14ab2aa 100644 --- a/Documentation/git-var.txt +++ b/Documentation/git-var.txt @@ -71,6 +71,9 @@ endif::git-default-pager[] GIT_DEFAULT_BRANCH:: The name of the first branch created in newly initialized repositories. +GIT_SHELL_PATH:: + The path of the binary providing the POSIX shell for commands which use the shell. + SEE ALSO -------- linkgit:git-commit-tree[1] diff --git a/builtin/var.c b/builtin/var.c index 10ee62f84c4848..bd340c5717dcab 100644 --- a/builtin/var.c +++ b/builtin/var.c @@ -36,6 +36,11 @@ static const char *default_branch(int ident_flag UNUSED) return git_default_branch_name(1); } +static const char *shell_path(int ident_flag UNUSED) +{ + return SHELL_PATH; +} + struct git_var { const char *name; const char *(*read)(int); @@ -47,6 +52,7 @@ static struct git_var git_vars[] = { { "GIT_SEQUENCE_EDITOR", sequence_editor }, { "GIT_PAGER", pager }, { "GIT_DEFAULT_BRANCH", default_branch }, + { "GIT_SHELL_PATH", shell_path }, { "", NULL }, }; diff --git a/t/t0007-git-var.sh b/t/t0007-git-var.sh index eeb8539c1bcb2d..e35f07afcb97b6 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.