From e77235ea38385a127d2afc969435a56d3ff2b16d Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Sun, 13 Aug 2006 00:34:37 -0700 Subject: Fix regex pattern in commit-msg Between the count and the line output, some uniq(1) versions put a TAB character, not a space. Make sure both are handled. Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- templates/hooks--commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 643822d235..23617f3906 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -11,4 +11,4 @@ # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1 /d')" + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" -- cgit v1.2.3 From 9a1ae9ab03abaffc977421f182997f3e735e7098 Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Sun, 13 Aug 2006 01:41:22 -0700 Subject: sample commit-msg hook: no silent exit on duplicate Signed-off-by lines git-commit would silently exit if duplicate Signed-off-by lines were found. Users of git-commit would not know it, unless they checked '$?'. This patch makes git-commit actually print out a message that nothing was commited since duplicate Signed-off-lines were found. Signed-off-by: Luben Tuikov Signed-off-by: Junio C Hamano --- templates/hooks--commit-msg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 23617f3906..0b906caa98 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -11,4 +11,8 @@ # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} + -- cgit v1.2.3 From 59f3e254801648322b2d5cd073ca0cc5009aa2de Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Thu, 21 Dec 2006 09:24:17 +0000 Subject: hooks/commit-msg: add example to add Signed-off-by line to message After checking to see if the commit message already has the target signed-off-by (for example in --amend commits), this patch generates a signed off by line from the repository owner and adds it to the commit message. Based on Johannes Schindelin's earlier patch to perform the same function. Originally, this was done in the pre-commit hook but Junio pointed out that the commit-msg hook allows the message to be edited. This has the aditional advantage that the commit-msg hook gets passed the name of the message file as a parameter, so it doesn't have to figure out GIT_DIR for itself. Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- templates/hooks--commit-msg | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 0b906caa98..9b04f2d69c 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -8,6 +8,10 @@ # # To enable this hook, make this file executable. +# Uncomment the below to add a Signed-off-by line to the message. +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | -- cgit v1.2.3 From a6080a0a44d5ead84db3dabbbc80e82df838533d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 7 Jun 2007 00:04:01 -0700 Subject: War on whitespace This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano --- templates/hooks--commit-msg | 1 - 1 file changed, 1 deletion(-) (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index 9b04f2d69c..c5cdb9d7ee 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -19,4 +19,3 @@ test "" = "$(grep '^Signed-off-by: ' "$1" | echo >&2 Duplicate Signed-off-by lines. exit 1 } - -- cgit v1.2.3 From 8089c85bcba89464b9b2a32fa948ed85eb367e70 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 5 Feb 2008 08:04:18 +0100 Subject: git-commit: add a prepare-commit-msg hook The prepare-commit-msg hook is run whenever a "fresh" commit message is prepared, just before it is shown in the editor (if it is). Its purpose is to modify the commit message in-place. It takes one to three parameters. The first is the name of the file that the commit log message. The second is the source of the commit message, and can be: "message" (if a -m or -F option was given); "template" (if a -t option was given or the configuration option commit.template is set); "merge" (if the commit is a merge or a .git/MERGE_MSG file exists); "squash" (if a .git/SQUASH_MSG file exists); or "commit", followed by a commit SHA1 as the third parameter (if a -c, -C or --amend option was given). If its exit status is non-zero, git-commit will abort. The hook is not suppressed by the --no-verify option, so it should not be used as a replacement for the pre-commit hook. The sample prepare-commit-msg comments out the `Conflicts:` part of a merge's commit message; other examples are commented out, including adding a Signed-off-by line at the bottom of the commit messsage, that the user can then edit or discard altogether. Signed-off-by: Paolo Bonzini Signed-off-by: Junio C Hamano --- templates/hooks--commit-msg | 3 +++ 1 file changed, 3 insertions(+) (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg index c5cdb9d7ee..4ef86eb244 100644 --- a/templates/hooks--commit-msg +++ b/templates/hooks--commit-msg @@ -9,6 +9,9 @@ # To enable this hook, make this file executable. # Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" -- cgit v1.2.3 From f98f8cbac01e0d5dbb30660d7ea70af6a1439dfd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 24 Jun 2008 18:45:21 -0700 Subject: 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 --- templates/hooks--commit-msg | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 templates/hooks--commit-msg (limited to 'templates/hooks--commit-msg') diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg deleted file mode 100644 index 4ef86eb244..0000000000 --- a/templates/hooks--commit-msg +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by git-commit with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, make this file executable. - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} -- cgit v1.2.3