git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] upload-pack: add a trigger for post-upload-pack hook
@ 2009-08-18  7:04 Tom Preston-Werner
  2009-08-25 17:43 ` Tom Werner
  0 siblings, 1 reply; 16+ messages in thread
From: Tom Preston-Werner @ 2009-08-18  7:04 UTC (permalink / raw)
  To: git; +Cc: Tom Preston-Werner

A post-upload-pack hook is desirable for Git hosts that need to
collect statistics on how many clones and/or fetches are made
on each repository.

The hook is called with either "clone" or "fetch" as the only
argument, depending on whether a full pack file was sent to the
client or not.

Signed-off-by: Tom Preston-Werner <tom@mojombo.com>
---
 upload-pack.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index f7d308a..96231dc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -141,6 +141,13 @@ static int do_rev_list(int fd, void *create_full_pack)
 	return 0;
 }
 
+static void run_post_upload_pack_hook(int create_full_pack)
+{
+	const char *fetch_type;
+	fetch_type = (create_full_pack) ? "clone" : "fetch";
+	run_hook(get_index_file(), "post-upload-pack", fetch_type);
+}
+
 static void create_pack_file(void)
 {
 	struct async rev_list;
@@ -314,6 +321,8 @@ static void create_pack_file(void)
 	}
 	if (use_sideband)
 		packet_flush(1);
+
+	run_post_upload_pack_hook(create_full_pack);
 	return;
 
  fail:
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-08-31 23:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-18  7:04 [PATCH] upload-pack: add a trigger for post-upload-pack hook Tom Preston-Werner
2009-08-25 17:43 ` Tom Werner
2009-08-25 18:45   ` Jeff King
2009-08-25 23:50     ` Junio C Hamano
2009-08-26  8:44       ` Johannes Schindelin
2009-08-26  9:03         ` Junio C Hamano
2009-08-26 10:06           ` Johannes Schindelin
2009-08-26 14:19             ` Jeff King
2009-08-26 23:39       ` Junio C Hamano
2009-08-27  0:47         ` Junio C Hamano
2009-08-27 12:09           ` Johan Sørensen
2009-08-27 13:33             ` Jakub Narebski
2009-08-29  6:17               ` Junio C Hamano
2009-08-31 18:50                 ` Tom Werner
2009-08-31 23:36                   ` Junio C Hamano
2009-08-27 22:56           ` Robin H. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).