1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 14:57:52 +01:00
Commit graph

41 commits

Author SHA1 Message Date
Jonathan Nieder
2e820ba9bc mark contributed hooks executable
The docs in contrib/hooks/pre-auto-gc-battery suggest:

	For example, if the hook is stored in
	/usr/share/git-core/contrib/hooks/pre-auto-gc-battery:

	chmod a+x pre-auto-gc-battery
	cd /path/to/your/repository.git
	ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
	     hooks/pre-auto-gc

Unfortunately on multi-user systems most users do not have write
access to /usr.  Better to mark the sample hooks executable in
the first place so users do not have to tweak their permissions to
use them by symlinking into .git/hooks/.

Reported-by: Olivier Berger <olivier.berger@it-sudparis.eu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-25 15:01:22 -08:00
Gerrit Pape
53a7296e7e hooks/post-receive-email: set declared encoding to utf-8
Some email clients (e.g., claws-mail) display the message body
incorrectly when the charset is not defined explicitly in a
Content-Type header.  "git log" generates logs in UTF-8 encoding by
default, so add a Content-Type header declaring that encoding to
the emails the post-receive-email example hook sends.

[jn: also setting the Content-Transfer-Encoding so MTAs know what
 kind of mangling might be needed when sending to a non 8-bit clean
 SMTP host]

Requested-by: Alexander Gerasiov <gq@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-05 10:17:38 -07:00
Jonathan Nieder
3109bdb0d1 hooks/post-receive-email: force log messages in UTF-8
Git commands write commit messages in UTF-8 by default, but that
default can be overridden by the [i18n] commitEncoding and
logOutputEncoding settings.  With such a setting, the emails written
by the post-receive-email hook use a mixture of encodings:

 1. Log messages use the configured log output encoding, which is
    meant to be whatever encoding works best with local terminals
    (and does not have much to do with what encoding should be used
    for email)

 2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw
    port (which uses Unicode filesystem APIs), always UTF-8

 3. The "This is an automated email" preface uses a project description
    from .git/description, which is typically in UTF-8 to support
    gitweb.

So (1) is configurable, and (2) and (3) are unconfigurable and
typically UTF-8.  Override the log output encoding to always use UTF-8
when writing the email to get the best chance of a comprehensible
single-encoding email.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-05 10:17:36 -07:00
Jonathan Nieder
1e88f7a277 hooks/post-receive-email: use plumbing instead of git log/show
This way the hook doesn't have to keep being tweaked as porcelain
learns new features like color and pagination.

While at it, replace the "git rev-list | git shortlog" idiom with
plain "git shortlog" for simplicity.

Except for depending less on the value of settings like '[log]
abbrevCommit', no change in output intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-05 10:17:35 -07:00
Michael Haggerty
1d25e7746d post-receive-email: deprecate script in favor of git-multimail
Add a notice to the top of post-receive-email explaining that the
script is no longer under active development and pointing the user to
git-multimail.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-22 21:20:28 -07:00
Chris Hiestand
7811aabbe7 Add Auto-Submitted header to post-receive-email
This conforms to RFC3834 and is useful in preventing eg
vacation auto-responders from replying by default

Signed-off-by: Chris Hiestand <chiestand@salk.edu>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-17 12:47:27 -08:00
Richard Fearn
7703477ab9 Fix spelling error in post-receive-email hook
Signed-off-by: Richard Fearn <richardfearn@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-13 21:50:14 -07:00
Michael Haggerty
64baa4153b post-receive-email: match up $LOGBEGIN..$LOGEND pairs correctly
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-27 11:01:16 -08:00
Michael Haggerty
c48be8b759 post-receive-email: remove unused variable
prep_for_email neither is passed a fourth argument nor uses it.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-27 11:01:15 -08:00
Gerrit Pape
f6f17885ba contrib/hooks: adapt comment about Debian install location for contrib hooks
Placing the contrib hooks into /usr/share/doc/ wasn't a good idea in the
first place.  According to the Debian policy they should be located in
/usr/share/git-core/, so let's put them there.

Thanks to Bill Allombert for reporting this through
 http://bugs.debian.org/640949

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-09-26 16:39:34 -07:00
Jon Jensen
0d7c01c991 Add option hooks.diffopts to customize change summary in post-receive-email
This makes it easy to customize the git diff-tree options, for example
to include -p to include inline diffs.

It defaults to the current options "--stat --summary --find-copies-harder"
and thus is backward-compatible.

Signed-off-by: Jon Jensen <jon@endpoint.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 12:06:49 -07:00
Sitaram Chamarty
80aa55b40b post-receive-email: suppress error if description file missing
Signed-off-by: Sitaram Chamarty <sitaramc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-07 14:28:21 -08:00
Alan Raison
8828aa3418 contrib/hooks/post-receive-email: fix return values from prep_for_email
The function was returning 0 for failure and 1 for success which was
breaking the logic in the main loop.  It now also returns in all
cases, rather than exiting.

Signed-off-by: Alan Raison <alan@theraisons.me.uk>
Acked-by: Kevin P. Fleming <kpfleming@digium.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-09 09:34:11 -08:00
Junio C Hamano
6cf9bf6cbc Merge branch 'kf/post-receive-sample-hook' into maint
* kf/post-receive-sample-hook:
  post-receive-email: ensure sent messages are not empty
2010-11-24 12:45:39 -08:00
Kevin P. Fleming
53cad69105 post-receive-email: ensure sent messages are not empty
Changes the logic in the script to determine whether an email message
will be sent before invoking the send_mail() function; otherwise, if
the logic determines that a message will not be sent, send_mail() will
cause an empty email to be sent. In addition, ensures that if multiple
refs are updated and a message cannot be sent for one of them,
the others are still processed normally.

Signed-off-by: Kevin P. Fleming <kpfleming@digium.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-10 09:37:51 -07:00
Junio C Hamano
c1807defb8 Merge branch 'kf/post-receive-sample-hook'
* kf/post-receive-sample-hook:
  post-receive-email: optional message line count limit
2010-08-18 12:16:50 -07:00
Matthieu Moy
b5e233ecc4 post-receive-email: remove spurious commas in email subject
The previous form produced subjects like

  [SCM] project.git branch, foo, updated. ...

The new one will produce the lighter

  [SCM] project.git branch foo updated. ...

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-11 11:23:25 -07:00
Kevin P. Fleming
b03e7b7d76 post-receive-email: optional message line count limit
We have become used to the features of svnmailer when used with Subversion,
and one of those useful features is that it can limit the maximum length
(in lines) of a commit email message. This is terribly useful since once the
goes beyond a reasonable number of lines, nobody is going to read the remainder,
and if they really want the entire contents of the commits, they can use
git itself to get them using the revision IDs present in the message already.

Change the post-receive-email script to respond to an 'emailmaxlines' config key
which, if specified, will limit the number of lines generated (including
headers); any lines beyond the limit are suppressed, and a final line is added
indicating the number that were suppressed.

Signed-off-by: Kevin P. Fleming <kpfleming@digium.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-16 15:34:12 -07:00
Jonathan Nieder
cc24a1d809 post-receive-email: document command-line mode
According to the default hooks/post-receive file, the hook is called
with three arguments on stdin:

  <oldrev> <newrev> <refname>

In command-line mode, the arguments come in a different order, because
the email hook instead calls:

  generate_email $2 $3 $1

Add a comment to explain why, based on comments from the mailing list
and the commit message to v1.5.1~9.  Thanks to Andy for the
explanation.

Requested-by: martin f. krafft <madduck@debian.org>
Cc: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-19 20:45:30 -07:00
Felipe Contreras
a75d7b5409 Use 'fast-forward' all over the place
It's a compound word.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-24 23:50:28 -07:00
Jim Meyering
5ffd3113d4 post-receive-email: hooks.showrev: show how to include both web link and patch
Add a comment showing how to include a web link (i.e. gitweb/cgit)
and a patch in the email that is sent for each pushed commit.

The quoting was tricky enough that it's worth documenting.  To add
two blank lines (i.e. put \n\n in the printf), you would need to
say \\\\n\\\\n, and in the end, the pair of "echo" statements seemed
better.  This is used in glibc.git repository:

  http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=summary

push-triggered messages have been sent to this list since May 21:

  http://sourceware.org/ml/glibc-cvs/2009-q2/

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-23 10:29:22 -07:00
Pat Notz
e5f5050ed1 Fix contrib/hooks/post-receive-email for new duplicate branch
In the show_new_revisions function, the original code:

  git rev-parse --not --branches | grep -v $(git rev-parse $refname) |

isn't quite right since one can create a new branch and push it
without any new commits.  In that case, two refs will have the same
sha1 but both would get filtered by the 'grep'.  In the end, we'll
show ALL the history which is not what we want.  Instead, we should
list the branches by name and remove the branch being updated and THEN
pass that list through rev-parse.

Revised as suggested by Jakub Narebski and Junio C Hamano to use
git-for-each-ref instead of git-branch.  (Thanks!)

Signed-off-by: Pat Notz <pknotz@sandia.gov>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-11 10:38:53 -08:00
Pete Harlan
b0a7d11173 contrib/hooks/post-receive-email: Make revision display configurable
Add configuration option hooks.showrev, letting the user override how
revisions will be shown in the commit email.

Signed-off-by: Pete Harlan <pgit@pcharlan.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-04 14:43:16 -08:00
Pete Harlan
4471649f44 contrib/hooks/post-receive-email: Put rev display in separate function
The display of a revision in an email-appropriate format is done in
two places with similar code.  In preparation for making that display
more complex, move it into a separate function that handles both cases.

Signed-off-by: Pete Harlan <pgit@pcharlan.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-04 14:43:07 -08:00
Andy Parkins
71bd81ade2 post-receive-email: fix accidental removal of a trailing space in signature line
post-receive-email adds a signature to the end of emails in
generate_email_footer().  The signature was separated from the main email
body using the standard string "-- ". (see RFC 3676)

a6080a0 (War on whitespace, 2007-06-07) removed the trailing whitespace
from "-- ", leaving it as "--", which is not a correct signature
separator.

This patch restores the missing space, but does it in a way that will
not set off the trailing whitespace alarms.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-21 23:36:56 -07:00
Denis Cheng
9225d7be0a specify explicit "--pretty=medium" with git log/show/whatchanged
The following patch will introduce a new configuration variable,
"format.pretty", from then on the pretty format without specifying
"--pretty" might not be the default "--pretty=medium", it depends on
the user's config. So all kinds of Shell/Perl/Emacs scripts that needs
the default medium pretty format must specify it explicitly.

Signed-off-by: Denis Cheng <crquan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-05 12:06:09 -08:00
Dan McGee
22fa97d4e0 Remove usage of git- (dash) commands from email hook
Switch all git command calls to use the git (space) command format, and
remove the use of git-repo-config in place of git config.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-13 21:48:20 -08:00
Gerrit Pape
5c355059c3 contrib/hooks/post-receive-email: remove cruft, $committer is not used
Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-08 14:18:13 -08:00
Gerrit Pape
e7509ee388 contrib/hooks/post-receive-email: make subject prefix configurable
Email subjects are prefixed with "[SCM] " by default, make this optionally
configurable through the hooks.emailprefix config option.

Suggested by martin f krafft through
 http://bugs.debian.org/428418

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-07 16:45:31 -08:00
Gerrit Pape
15a2f53011 contrib/hooks/post-receive-email: reformat to wrap comments at 76 chars
Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-07 16:45:31 -08:00
Gerrit Pape
b5786c8283 contrib/hooks/post-receive-email: fix typo
Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-07 16:45:31 -08:00
Shawn O. Pearce
e75c55844f Merge branch 'maint'
* maint:
  Yet more 1.5.3.5 fixes mentioned in release notes
  cvsserver: Use exit 1 instead of die when req_Root fails.
  git-blame shouldn't crash if run in an unmerged tree
  git-config: print error message if the config file cannot be read
  fixing output of non-fast-forward output of post-receive-email
2007-10-18 03:11:17 -04:00
Robert Schiele
a2d6b872db fixing output of non-fast-forward output of post-receive-email
post-receive-email has one place where the variable fast_forward is not
spelled correctly.  At the same place the logic was reversed.  The
combination of both bugs made the script work correctly for fast-forward
commits but not for non-fast-forward ones.  This change fixes this to
be correct in both cases.

Signed-off-by: Robert Schiele <rschiele@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-18 00:59:25 -04:00
Jeff Muizelaar
fdfeb87c14 fix contrib/hooks/post-receive-email hooks.recipients error message
Have the error message for missing recipients actually report the
missing config variable and not a fictional one.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-15 21:26:42 -04:00
Andy Parkins
e6dc8d60fb post-receive-hook: Remove the From field from the generated email header so that the pusher's name is used
Using the name of the committer of the revision at the tip of the
updated ref is not sensible.  That information is available in the email
itself should it be wanted, and by supplying a "From", we were
effectively hiding the person who performed the push - which is useful
information in itself.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-01 01:59:22 -07:00
Jim Meyering
d1637a07f6 Do not over-quote the -f envelopesender value.
Without this, the value passed to sendmail would have an extra set of
single quotes.  At least exim's sendmail emulation would object to that:

    exim: bad -f address "'list-addr@example.org'": malformed address: ' \
      may not follow 'list-addr@example.org
    error: hooks/post-receive exited with error code 1

Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-25 00:30:19 -07:00
Junio C Hamano
a6080a0a44 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 <gitster@pobox.com>
2007-06-07 00:04:01 -07:00
Andy Parkins
c855195cd0 post-receive-email example hook: sed command for getting description was wrong
The sed command that extracted the first line of the project description
didn't include the -n switch and hence the project name was being
printed twice.  This was ruining the email header generation because it
was assumed that the description was only one line and was included in
the subject.  This turned the subject into a two line item and
prematurely finished the header.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-26 20:59:55 -07:00
Andy Parkins
024e5b31af post-receive-email example hook: detect rewind-only updates and output sensible message
Sometimes a non-fast-forward update doesn't add new commits, it merely
removes old commits.  This patch adds support for detecting that and
outputting a more correct message.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-26 20:59:49 -07:00
Andy Parkins
8e404f82ab post-receive-email example hook: fastforward should have been fast_forward
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-26 20:58:04 -07:00
Gerrit Pape
5850cb645d rename contrib/hooks/post-receieve-email to contrib/hooks/post-receive-email.
$ git grep post-receieve-email
 $ git grep post-receive-email
 templates/hooks--post-receive:#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
 $

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-04 22:17:59 -07:00
Renamed from contrib/hooks/post-receieve-email (Browse further)