Skip to content

Commit 0cb050a

Browse files
committed
Merge branch 'bw/template-tool-buildconfig'
* bw/template-tool-buildconfig: Modernize git calling conventions in hook templates Make templates honour SHELL_PATH and PERL_PATH
2 parents 59d1e01 + 100e762 commit 0cb050a

9 files changed

+36
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ endif
14801480
ifndef NO_PYTHON
14811481
$(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
14821482
endif
1483-
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1483+
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
14841484

14851485
please_set_SHELL_PATH_to_a_more_modern_shell:
14861486
@$$(:)

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--commit-msg.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
#
33
# An example hook script to check the commit log message.
4-
# Called by git-commit with one argument, the name of the file
4+
# Called by "git commit" with one argument, the name of the file
55
# that has the commit message. The hook should exit with non-zero
66
# status after issuing an appropriate message if it wants to stop the
77
# commit. The hook is allowed to edit the commit message file.

templates/hooks--post-update.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
#
66
# To enable this hook, rename this file to "post-update".
77

8-
exec git-update-server-info
8+
exec git update-server-info

templates/hooks--pre-commit.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/sh
22
#
33
# An example hook script to verify what is about to be committed.
4-
# Called by git-commit with no arguments. The hook should
4+
# Called by "git commit" with no arguments. The hook should
55
# exit with non-zero status after issuing an appropriate message if
66
# it wants to stop the commit.
77
#
88
# To enable this hook, rename this file to "pre-commit".
99

10-
if git-rev-parse --verify HEAD >/dev/null 2>&1
10+
if git rev-parse --verify HEAD >/dev/null 2>&1
1111
then
1212
against=HEAD
1313
else

templates/hooks--pre-rebase.sample

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright (c) 2006, 2008 Junio C Hamano
44
#
5-
# The "pre-rebase" hook is run just before "git-rebase" starts doing
5+
# The "pre-rebase" hook is run just before "git rebase" starts doing
66
# its job, and can prevent the command from running by exiting with
77
# non-zero status.
88
#
@@ -43,19 +43,19 @@ git show-ref -q "$topic" || {
4343
}
4444

4545
# Is topic fully merged to master?
46-
not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
46+
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
4747
if test -z "$not_in_master"
4848
then
4949
echo >&2 "$topic is fully merged to master; better remove it."
5050
exit 1 ;# we could allow it, but there is no point.
5151
fi
5252

5353
# Is topic ever merged to next? If so you should not be rebasing it.
54-
only_next_1=`git-rev-list ^master "^$topic" ${publish} | sort`
55-
only_next_2=`git-rev-list ^master ${publish} | sort`
54+
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
55+
only_next_2=`git rev-list ^master ${publish} | sort`
5656
if test "$only_next_1" = "$only_next_2"
5757
then
58-
not_in_topic=`git-rev-list "^$topic" master`
58+
not_in_topic=`git rev-list "^$topic" master`
5959
if test -z "$not_in_topic"
6060
then
6161
echo >&2 "$topic is already up-to-date with master"
@@ -64,8 +64,8 @@ then
6464
exit 0
6565
fi
6666
else
67-
not_in_next=`git-rev-list --pretty=oneline ^${publish} "$topic"`
68-
perl -e '
67+
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
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 {
@@ -157,13 +157,13 @@ B to be deleted.
157157
158158
To compute (1):
159159
160-
git-rev-list ^master ^topic next
161-
git-rev-list ^master next
160+
git rev-list ^master ^topic next
161+
git rev-list ^master next
162162
163163
if these match, topic has not merged in next at all.
164164
165165
To compute (2):
166166
167-
git-rev-list master..topic
167+
git rev-list master..topic
168168
169169
if this is empty, it is fully merged to "master".

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
#
33
# An example hook script to prepare the commit log message.
4-
# Called by git-commit with the name of the file that has the
4+
# Called by "git commit" with the name of the file that has the
55
# commit message, followed by the description of the commit
66
# message's source. The hook's purpose is to edit the commit
77
# message file. If the hook fails with a non-zero status,
@@ -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

templates/hooks--update.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
#
33
# An example hook script to blocks unannotated tags from entering.
4-
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
4+
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
55
#
66
# To enable this hook, rename this file to "update".
77
#
@@ -64,7 +64,7 @@ zero="0000000000000000000000000000000000000000"
6464
if [ "$newrev" = "$zero" ]; then
6565
newrev_type=delete
6666
else
67-
newrev_type=$(git-cat-file -t $newrev)
67+
newrev_type=$(git cat-file -t $newrev)
6868
fi
6969

7070
case "$refname","$newrev_type" in

templates/info--exclude

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# git-ls-files --others --exclude-from=.git/info/exclude
1+
# git ls-files --others --exclude-from=.git/info/exclude
22
# Lines that start with '#' are comments.
33
# For a project mostly in C, the following would be a good set of
44
# exclude patterns (uncomment them if you want to use them):

0 commit comments

Comments
 (0)