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 <redacted>
---
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