Skip to content

Commit ec0465a

Browse files
committed
Merge branch 'km/bsd-shells'
Portability fixes and workarounds for shell scripts have been added to help BSD-derived systems. * km/bsd-shells: t5528: do not fail with FreeBSD shell help.c: use SHELL_PATH instead of hard-coded "/bin/sh" git-compat-util.h: move SHELL_PATH default into header git-instaweb: use @SHELL_PATH@ instead of /bin/sh git-instaweb: allow running in a working tree subdirectory
2 parents 89ebf97 + ce026cc commit ec0465a

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

builtin/help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
171171
{
172172
struct strbuf shell_cmd = STRBUF_INIT;
173173
strbuf_addf(&shell_cmd, "%s %s", cmd, page);
174-
execl("/bin/sh", "sh", "-c", shell_cmd.buf, (char *)NULL);
174+
execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
175175
warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
176176
}
177177

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,4 +876,8 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
876876
#define USE_PARENS_AROUND_GETTEXT_N 1
877877
#endif
878878

879+
#ifndef SHELL_PATH
880+
# define SHELL_PATH "/bin/sh"
881+
#endif
882+
879883
#endif

git-instaweb.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ start start the web server
2020
restart restart the web server
2121
"
2222

23+
SUBDIRECTORY_OK=Yes
2324
. git-sh-setup
2425

2526
fqgitdir="$GIT_DIR"
@@ -204,7 +205,7 @@ webrick_conf () {
204205
# actual gitweb.cgi using a shell script to force it
205206
wrapper="$fqgitdir/gitweb/$httpd/wrapper.sh"
206207
cat > "$wrapper" <<EOF
207-
#!/bin/sh
208+
#!@SHELL_PATH@
208209
# we use this shell script wrapper around the real gitweb.cgi since
209210
# there appears to be no other way to pass arbitrary environment variables
210211
# into the CGI process

run-command.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#include "sigchain.h"
55
#include "argv-array.h"
66

7-
#ifndef SHELL_PATH
8-
# define SHELL_PATH "/bin/sh"
9-
#endif
10-
117
void child_process_init(struct child_process *child)
128
{
139
memset(child, 0, sizeof(*child));

t/t5528-push-default.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ check_pushed_commit () {
2626
# $2 = expected target branch for the push
2727
# $3 = [optional] repo to check for actual output (repo1 by default)
2828
test_push_success () {
29-
git ${1:+-c push.default="$1"} push &&
29+
git ${1:+-c} ${1:+push.default="$1"} push &&
3030
check_pushed_commit HEAD "$2" "$3"
3131
}
3232

3333
# $1 = push.default value
3434
# check that push fails and does not modify any remote branch
3535
test_push_failure () {
3636
git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&
37-
test_must_fail git ${1:+-c push.default="$1"} push &&
37+
test_must_fail git ${1:+-c} ${1:+push.default="$1"} push &&
3838
git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&
3939
test_cmp expect actual
4040
}

0 commit comments

Comments
 (0)