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

[PATCH] upload-pack: add a trigger for post-upload-pack hook

From
TPTom Preston-Werner <tom@mojombo.com>
Date
Aug 18, 2009, 07:04 UTC
Message-ID
<1250579093-40706-1-git-send-email-tom@mojombo.com>

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
Next: Tom Werner
Message 1 of 16 in “upload-pack: add a trigger for post-upload-pack hook”
  1. upload-pack: add a trigger for post-upload-pack hookTom Preston-Werner, Aug 18, 2009
  2. Tom WernerAug 25, 2009
  3. Jeff KingAug 25, 2009
  4. Junio C HamanoAug 25, 2009
  5. Johannes SchindelinAug 26, 2009
  6. Junio C HamanoAug 26, 2009
  7. Johannes SchindelinAug 26, 2009
  8. Jeff KingAug 26, 2009
  9. Junio C HamanoAug 26, 2009
  10. upload-pack: add a trigger for post-upload-pack hookJunio C Hamano, Aug 27, 2009
  11. Johan SørensenAug 27, 2009
  12. Jakub NarebskiAug 27, 2009
  13. Junio C HamanoAug 29, 2009
  14. Tom WernerAug 31, 2009
  15. Junio C HamanoAug 31, 2009
  16. Robin H. JohnsonAug 27, 2009

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.