Skip to content

Commit f98f8cb

Browse files
committed
Ship sample hooks with .sample suffix
We used to mark hooks we ship as samples by making them unexecutable, but some filesystems cannot tell what is executable and what is not. This makes it much more explicit. The hooks are suffixed with .sample (but now are made executable), so enabling it is still one step operation (instead of "chmod +x $hook", you would do "mv $hook.sample $hook") but now they won't get accidentally enabled on systems without executable bit. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba2d0f4 commit f98f8cb

12 files changed

+25
-25
lines changed

Documentation/githooks.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Hooks are little scripts you can place in `$GIT_DIR/hooks`
1717
directory to trigger action at certain points. When
1818
`git-init` is run, a handful example hooks are copied in the
1919
`hooks` directory of the new repository, but by default they are
20-
all disabled. To enable a hook, make it executable with `chmod +x`.
20+
all disabled. To enable a hook, rename it by removing its `.sample`
21+
suffix.
2122

2223
This document describes the currently defined hooks.
2324

templates/hooks--applypatch-msg renamed to templates/hooks--applypatch-msg.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# appropriate message if it wants to stop the commit. The hook is
88
# allowed to edit the commit message file.
99
#
10-
# To enable this hook, make this file executable.
10+
# To enable this hook, rename this file to "applypatch-msg".
1111

1212
. git-sh-setup
1313
test -x "$GIT_DIR/hooks/commit-msg" &&

templates/hooks--commit-msg renamed to templates/hooks--commit-msg.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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.
88
#
9-
# To enable this hook, make this file executable.
9+
# To enable this hook, rename this file to "commit-msg".
1010

1111
# Uncomment the below to add a Signed-off-by line to the message.
1212
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg

templates/hooks--post-commit renamed to templates/hooks--post-commit.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# An example hook script that is called after a successful
44
# commit is made.
55
#
6-
# To enable this hook, make this file executable.
6+
# To enable this hook, rename this file to "post-commit".
77

88
: Nothing

templates/hooks--post-receive

Lines changed: 0 additions & 16 deletions
This file was deleted.

templates/hooks--post-receive.sample

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script for the "post-receive" event.
4+
#
5+
# The "post-receive" script is run after receive-pack has accepted a pack
6+
# and the repository has been updated. It is passed arguments in through
7+
# stdin in the form
8+
# <oldrev> <newrev> <refname>
9+
# For example:
10+
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
11+
#
12+
# see contrib/hooks/ for an sample, or uncomment the next line and
13+
# rename the file to "post-receive".
14+
15+
#. /usr/share/doc/git-core/contrib/hooks/post-receive-email

templates/hooks--post-update renamed to templates/hooks--post-update.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# An example hook script to prepare a packed repository for use over
44
# dumb transports.
55
#
6-
# To enable this hook, make this file executable by "chmod +x post-update".
6+
# To enable this hook, rename this file to "post-update".
77

88
exec git-update-server-info

templates/hooks--pre-applypatch renamed to templates/hooks--pre-applypatch.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# The hook should exit with non-zero status after issuing an
77
# appropriate message if it wants to stop the commit.
88
#
9-
# To enable this hook, make this file executable.
9+
# To enable this hook, rename this file to "pre-applypatch".
1010

1111
. git-sh-setup
1212
test -x "$GIT_DIR/hooks/pre-commit" &&

templates/hooks--pre-commit renamed to templates/hooks--pre-commit.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# exit with non-zero status after issuing an appropriate message if
66
# it wants to stop the commit.
77
#
8-
# To enable this hook, make this file executable.
8+
# To enable this hook, rename this file to "pre-commit".
99

1010
# This is slightly modified from Andrew Morton's Perfect Patch.
1111
# Lines you introduce should not have trailing whitespace.
File renamed without changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# message file. If the hook fails with a non-zero status,
88
# the commit is aborted.
99
#
10-
# To enable this hook, make this file executable.
10+
# To enable this hook, rename this file to "prepare-commit-msg".
1111

1212
# This hook includes three examples. The first comments out the
1313
# "Conflicts:" part of a merge commit.

templates/hooks--update renamed to templates/hooks--update.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# An example hook script to blocks unannotated tags from entering.
44
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
55
#
6-
# To enable this hook, make this file executable by "chmod +x update".
6+
# To enable this hook, rename this file to "update".
77
#
88
# Config
99
# ------

0 commit comments

Comments
 (0)