Skip to content

Commit 6ba3184

Browse files
committed
Improvements to my pre-commit hook template
1 parent d750c3e commit 6ba3184

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pre-commit.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/sh
22

3+
if [ ! $(git rev-parse --symbolic-full-name HEAD) = refs/heads/master ]; then
4+
exit 0
5+
fi
6+
37
# These are the locations I keep my temporary source and build trees in
48
TMPDIR=$HOME/Products/ledger-pre-commit
59
MIRROR=$HOME/Products/ledger-pre-commit-mirror
@@ -17,19 +21,23 @@ git diff-index --cached --name-only --diff-filter=D -z HEAD | \
1721
# Copy only _changed files_ from MIRROR to TMPDIR, without copying timestamps.
1822
# This includes copying over new files, and deleting removed ones. This way,
1923
# "make check" will only rebuild what is necessary to validate the commit.
20-
rsync -rlpgoDO --size-only --delete \
21-
--exclude-from=tools/excludes $MIRROR/ $TMPDIR/
24+
rsync -rlpgoDOc --delete --exclude-from=tools/excludes $MIRROR/ $TMPDIR/
2225

2326
# Everything else happens in the temporary build tree
27+
if [ ! -f $TMPDIR/lib/utfcpp/source/utf8.h ]; then
28+
rsync -a --delete lib/utfcpp/ $TMPDIR/lib/utfcpp/
29+
fi
2430
cd $TMPDIR
2531

2632
# Make sure there is a current Makefile. Regeneration of Makefile happens
2733
# automatically, but if myacprep or acprep changes, we want to regenerate
2834
# everything manually. If the user doesn't have acprep or myacprep, look for
2935
# other common autoconf-related script files.
3036
if [ ! -f Makefile -o \
31-
\( -f tools/myacprep -a -f acprep -a \
32-
\( tools/myacprep -nt Makefile -o acprep -nt Makefile \) \) ]
37+
Makefile.am -nt Makefile -o \
38+
configure.ac -nt Makefile -o \
39+
\( -f acprep -a acprep -nt Makefile \) -o \
40+
\( -f tools/myacprep -a tools/myacprep -nt Makefile \) ]
3341
then
3442
if [ -f tools/myacprep ]; then
3543
tools/myacprep --local

0 commit comments

Comments
 (0)