diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-04-30 14:06:23 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-30 14:06:23 -0700 |
commit | e84c150b2f79fa7223bae1784fd8da2429bd4389 (patch) | |
tree | 4083298fbd53d28f54f9aaa63b566dfc027c0d06 /server-info.c | |
parent | 3d4a3ffe64162b45ae7c991fc60623ecb4678cfd (diff) | |
download | git-jc/clone-bundle.tar.gz |
repack: optionally create a clone.bundlejc/clone-bundle
It is envisioned that a near-future protocol extension to
upload-pack will allow a busy server to redirect newer `git clone`
clients to a pre-made bundle file (preferrably over CDN) and to come
back after they download and extract from the bundle to update
themselves via much smaller `git fetch --prune` to complete the
cloning. Let's teach `git repack` to optionally prepare the
clone.bundle file when the repository is repacked, so that the
server operators can take the resulting bundle and make it available
to the clients.
This prepares only the bundle generation part. Deploying the
resulting bundle to CDN will not be part of Git (we may give the
server operators a hook, though), but this step will help them to
maintain an up-to-date bundle.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'server-info.c')
-rw-r--r-- | server-info.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/server-info.c b/server-info.c index 34b0253177..8a25f5d0ae 100644 --- a/server-info.c +++ b/server-info.c @@ -3,6 +3,7 @@ #include "object.h" #include "commit.h" #include "tag.h" +#include "run-command.h" /* * Create the file "path" by writing to a temporary file and renaming @@ -265,6 +266,27 @@ static int update_info_packs(int force) return ret; } +static int update_clone_bundle(int force) +{ + int create_clone_bundle = 0, status; + struct child_process bundle = CHILD_PROCESS_INIT; + char *bundlefile; + + if (git_config_get_bool("repack.bundle", &create_clone_bundle) && + force) + create_clone_bundle = 1; + if (!create_clone_bundle) + return 0; + + bundle.git_cmd = 1; + bundlefile = git_pathdup("clone.bundle"); + argv_array_pushl(&bundle.args, "bundle", "create", + bundlefile, "--all", NULL); + status = run_command(&bundle); + free(bundlefile); + return status; +} + /* public */ int update_server_info(int force) { @@ -276,6 +298,7 @@ int update_server_info(int force) errs = errs | update_info_refs(force); errs = errs | update_info_packs(force); + errs = errs | update_clone_bundle(force); /* remove leftover rev-cache file if there is any */ unlink_or_warn(git_path("info/rev-cache")); |