@matheusbsbs / matheus-bagliano / commits / 502be95953
Fork 0

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 <bwalton@artsci.utoronto.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Walton committed Mar 20, 2010 at 10:48 UTC 502be959531b34e2d9283213b7bca51842639240
4 files changed +19 -6
Makefile
+1 -1
@@ -1469,7 +1469,7 @@ endif
1469 ifndef NO_PYTHON
1470 $(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
1471 endif
1472 - $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1472 + $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
1473
1474 please_set_SHELL_PATH_to_a_more_modern_shell:
1475 @$$(:)
templates/Makefile
+15 -2
@@ -11,6 +11,16 @@ prefix ?= $(HOME)
11 template_instdir ?= $(prefix)/share/git-core/templates
12 # DESTDIR=
13
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 +
24 # Shell quote (do not use $(call) to accommodate ancient setups);
25 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
26 template_instdir_SQ = $(subst ','\'',$(template_instdir))
@@ -33,8 +43,11 @@ boilerplates.made : $(bpsrc)
43 case "$$boilerplate" in \
44 *--) continue;; \
45 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 && \
51 chmod a+$$rx "blt/$$dst" || exit; \
52 done && \
53 date >$@
templates/hooks--pre-rebase.sample
+1 -1
@@ -65,7 +65,7 @@ then
65 fi
66 else
67 not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
68 - perl -e '
68 + @PERL_PATH@ -e '
69 my $topic = $ARGV[0];
70 my $msg = "* $topic has commits already merged to public branch:\n";
71 my (%not_in_next) = map {
templates/hooks--prepare-commit-msg.sample
+2 -2
@@ -22,10 +22,10 @@
22
23 case "$2,$3" in
24 merge,)
25 - perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
25 + @PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
26
27 # ,|template,)
28 -# perl -i.bak -pe '
28 +# @PERL_PATH@ -i.bak -pe '
29 # print "\n" . `git diff --cached --name-status -r`
30 # if /^#/ && $first++ == 0' "$1" ;;
31