git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Added hook in git-receive-pack

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Aug 13, 2005, 20:39 UTC
Message-ID
<200508132239.41445.Josef.Weidendorfer@gmx.de>
In-Reply-To
<7voe81myc4.fsf@assigned-by-dhcp.cox.net>
On Saturday 13 August 2005 21:27, Junio C Hamano wrote:
Show 6 quoted lines
> Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:
> > Or is there already an easy way to detect the fast-forward situation in
> > the script?
>
> Since you are given old and new, presumably you can do
> merge-base in the hook to see what it yields?

Ah, yes, thanks. A proposed update for the example hook (one change actually is a fix):

Fixed/Extended example for update hook ---

diff --git a/templates/hooks--update b/templates/hooks--update
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # An example hook script to mail out commit update information.
+# Called by git-receive-pack with arguments: refname sha1-old sha1-new
 #
 # To enable this hook:
 # (1) change the recipient e-mail address
@@ -12,10 +13,15 @@ recipient="commit-list@mydomain.xz"
 if expr "$2" : '0*$' >/dev/null
 then
        echo "Created a new ref, with the following commits:"
-       git-rev-list --pretty "$2"
+       git-rev-list --pretty "$3"
 else
-       echo "New commits:"
-       git-rev-list --pretty "$3" "^$2"
+       $base=$(git-merge-base "$2" "$3")
+       if [ $base == "$2" ]; then
+               echo "New commits:"
+       else
+               echo "Rebased ref, commits from common ancestor:"
+       fi
+       git-rev-list --pretty "$3" "^$base"
 fi |
 mail -s "Changes to ref $1" "$recipient"
 exit 0
Previous: Junio C Hamano
Message 15 of 15 in “Added hook in git-receive-pack”
  1. Added hook in git-receive-packJosef Weidendorfer, Jul 31, 2005
  2. Linus TorvaldsJul 31, 2005
  3. Junio C HamanoJul 31, 2005
  4. Linus TorvaldsJul 31, 2005
  5. Junio C HamanoJul 31, 2005
  6. Johannes SchindelinJul 31, 2005
  7. Linus TorvaldsJul 31, 2005
  8. Junio C HamanoAug 1, 2005
  9. Linus TorvaldsAug 1, 2005
  10. Junio C HamanoJul 31, 2005
  11. Josef WeidendorferJul 31, 2005
  12. Junio C HamanoAug 1, 2005
  13. Josef WeidendorferAug 13, 2005
  14. Junio C HamanoAug 13, 2005
  15. Josef WeidendorferAug 13, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.