Skip to content

Commit 502be95

Browse files
Ben Waltongitster
authored andcommitted
Make templates honour SHELL_PATH and PERL_PATH
The hook script templates were hard coded to use /bin/sh and perl. This patch ensures that they use the same tools specified for the rest of the suite. The impetus for the change was noticing that, as shipped, some of the hooks used shell constructs that wouldn't work under Solaris' /bin/sh (eg: $(cmd...) substitutions). Signed-off-by: Ben Walton <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1ba1c9 commit 502be95

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ endif
14691469
ifndef NO_PYTHON
14701470
$(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
14711471
endif
1472-
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1472+
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
14731473

14741474
please_set_SHELL_PATH_to_a_more_modern_shell:
14751475
@$$(:)

templates/Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ prefix ?= $(HOME)
1111
template_instdir ?= $(prefix)/share/git-core/templates
1212
# DESTDIR=
1313

14+
ifndef SHELL_PATH
15+
SHELL_PATH = /bin/sh
16+
endif
17+
ifndef PERL_PATH
18+
PERL_PATH = perl
19+
endif
20+
21+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
22+
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
23+
1424
# Shell quote (do not use $(call) to accommodate ancient setups);
1525
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
1626
template_instdir_SQ = $(subst ','\'',$(template_instdir))
@@ -33,8 +43,11 @@ boilerplates.made : $(bpsrc)
3343
case "$$boilerplate" in \
3444
*--) continue;; \
3545
esac && \
36-
cp $$boilerplate blt/$$dst && \
37-
if test -x "blt/$$dst"; then rx=rx; else rx=r; fi && \
46+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
47+
-e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
48+
-e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \
49+
blt/$$dst && \
50+
if test -x "$$boilerplate"; then rx=rx; else rx=r; fi && \
3851
chmod a+$$rx "blt/$$dst" || exit; \
3952
done && \
4053
date >$@

templates/hooks--pre-rebase.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ then
6565
fi
6666
else
6767
not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
68-
perl -e '
68+
@PERL_PATH@ -e '
6969
my $topic = $ARGV[0];
7070
my $msg = "* $topic has commits already merged to public branch:\n";
7171
my (%not_in_next) = map {

templates/hooks--prepare-commit-msg.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
case "$2,$3" in
2424
merge,)
25-
perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
25+
@PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
2626

2727
# ,|template,)
28-
# perl -i.bak -pe '
28+
# @PERL_PATH@ -i.bak -pe '
2929
# print "\n" . `git diff --cached --name-status -r`
3030
# if /^#/ && $first++ == 0' "$1" ;;
3131

0 commit comments

Comments
 (0)