diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-03-10 03:28:16 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-03-11 22:56:03 -0700 |
commit | f43cd49fb82b0eee10b88833b58edd711fe8298d (patch) | |
tree | 80310d2aa2fc7480bc25c6223e186cf12385e6b6 /Documentation/git-receive-pack.txt | |
parent | 1d9e8b56fe3a0360bf61ce633827af8fa9a7013c (diff) | |
download | git-f43cd49fb82b0eee10b88833b58edd711fe8298d.tar.gz |
Change {pre,post}-receive hooks to use stdin
Sergey Vlasov, Andy Parkins and Alex Riesen all pointed out that it
is possible for a single invocation of receive-pack to be given more
refs than the OS might allow us to pass as command line parameters
to a single hook invocation.
We don't want to break these up into multiple invocations (like
xargs might do) as that makes it impossible for the pre-receive
hook to verify multiple related ref updates occur at the same time,
and it makes it harder for post-receive to send out a single batch
notification.
Instead we pass the reference data on a pipe connected to the
hook's stdin, supplying one ref per line to the hook. This way a
single hook invocation can obtain an infinite amount of ref data,
without bumping into any operating system limits.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'Documentation/git-receive-pack.txt')
-rw-r--r-- | Documentation/git-receive-pack.txt | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt index 3cf55111cc..6914aa59c3 100644 --- a/Documentation/git-receive-pack.txt +++ b/Documentation/git-receive-pack.txt @@ -40,13 +40,13 @@ OPTIONS pre-receive Hook ---------------- Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists -and is executable, it will be invoked once, with three parameters -per ref to be updated: +and is executable, it will be invoked once with no parameters. The +standard input of the hook will be one line per ref to be updated: - $GIT_DIR/hooks/pre-receive (refname sha1-old sha1-new)+ + sha1-old SP sha1-new SP refname LF -The refname parameter is relative to $GIT_DIR; e.g. for the master -head this is "refs/heads/master". The two sha1 arguments after +The refname value is relative to $GIT_DIR; e.g. for the master +head this is "refs/heads/master". The two sha1 values before each refname are the object names for the refname before and after the update. Refs to be created will have sha1-old equal to 0{40}, while refs to be deleted will have sha1-new equal to 0{40}, otherwise @@ -86,13 +86,14 @@ post-receive Hook ----------------- After all refs were updated (or attempted to be updated), if any ref update was successful, and if $GIT_DIR/hooks/post-receive -file exists and is executable, it will be invoke once with three -parameters for each successfully updated ref: +file exists and is executable, it will be invoke once with no +parameters. The standard input of the hook will be one line +for each successfully updated ref: - $GIT_DIR/hooks/post-receive (refname sha1-old sha1-new)+ + sha1-old SP sha1-new SP refname LF -The refname parameter is relative to $GIT_DIR; e.g. for the master -head this is "refs/heads/master". The two sha1 arguments after +The refname value is relative to $GIT_DIR; e.g. for the master +head this is "refs/heads/master". The two sha1 values before each refname are the object names for the refname before and after the update. Refs that were created will have sha1-old equal to 0{40}, while refs that were deleted will have sha1-new equal to @@ -105,18 +106,17 @@ ref listing the commits pushed to the repository: #!/bin/sh # mail out commit update information. - while test $# -gt 0 + while read oval nval ref do - if expr "$2" : '0*$' >/dev/null + if expr "$oval" : '0*$' >/dev/null then echo "Created a new ref, with the following commits:" - git-rev-list --pretty "$2" + git-rev-list --pretty "$nval" else echo "New commits:" - git-rev-list --pretty "$3" "^$2" + git-rev-list --pretty "$nval" "^$oval" fi | - mail -s "Changes to ref $1" commit-list@mydomain - shift; shift; shift; # discard this ref's args + mail -s "Changes to ref $ref" commit-list@mydomain done exit 0 |