summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-04-30 14:06:23 -0700
committerJunio C Hamano <gitster@pobox.com>2015-04-30 14:06:23 -0700
commite84c150b2f79fa7223bae1784fd8da2429bd4389 (patch)
tree4083298fbd53d28f54f9aaa63b566dfc027c0d06
parent3d4a3ffe64162b45ae7c991fc60623ecb4678cfd (diff)
downloadgit-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>
-rw-r--r--Documentation/config.txt6
-rw-r--r--Documentation/git-repack.txt9
-rw-r--r--Documentation/git-update-server-info.txt13
-rw-r--r--Documentation/gitrepository-layout.txt5
-rw-r--r--server-info.c23
5 files changed, 53 insertions, 3 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 2e5ceaf719..c727a0c241 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2298,6 +2298,12 @@ remotes.<group>::
The list of remotes which are fetched by "git remote update
<group>". See linkgit:git-remote[1].
+repack.bundle::
+ A newer server can prepare the `$GIT_DIR/clone.bundle` file,
+ which will help it respond to `git clone` requests more
+ efficiently, when the repository is repacked. Setting this
+ variable to `true` enables this feature.
+
repack.useDeltaBaseOffset::
By default, linkgit:git-repack[1] creates packs that use
delta-base offset. If you need to share your repository with
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 0e0bd363d6..8858e7505a 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -79,7 +79,8 @@ other objects in that pack they already have locally.
'git update-server-info'. This option skips
updating local catalog files needed to publish
this repository (or a direct copy of it)
- over HTTP or FTP. See linkgit:git-update-server-info[1].
+ over HTTP or FTP, and generation of the
+ clone.bundle file. See linkgit:git-update-server-info[1].
--window=<n>::
--depth=<n>::
@@ -139,6 +140,12 @@ need to set the configuration variable `repack.UseDeltaBaseOffset` to
is unaffected by this option as the conversion is performed on the fly
as needed in that case.
+To keep the `$GIT_DIR/clone.bundle` file up to date for a newer
+server automatically when `git repack` repacks the repository, the
+`repack.bundle` configuration variable must be set to `true` on the
+server side.
+
+
SEE ALSO
--------
linkgit:git-pack-objects[1]
diff --git a/Documentation/git-update-server-info.txt b/Documentation/git-update-server-info.txt
index bd0e36492f..8235f97c7c 100644
--- a/Documentation/git-update-server-info.txt
+++ b/Documentation/git-update-server-info.txt
@@ -16,8 +16,15 @@ DESCRIPTION
A dumb server that does not do on-the-fly pack generations must
have some auxiliary information files in $GIT_DIR/info and
$GIT_OBJECT_DIRECTORY/info directories to help clients discover
-what references and packs the server has. This command
-generates such auxiliary files.
+what references and packs the server has.
+
+A future protocol update will allow a server to respond to a "git
+clone" request by first telling the client to fetch a pre-made
+bundle file and then fetch from it. To prepare such a server,
+the pre-made bundle file `$GIT_DIR/clone.bundle` needs to be
+kept up to date.
+
+This command generates such auxiliary files.
OPTIONS
@@ -39,6 +46,8 @@ what they are for:
* info/refs
+* clone.bundle
+
GIT
---
Part of the linkgit:git[1] suite
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 79653f3134..91161de231 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -222,6 +222,11 @@ shallow::
modules::
Contains the git-repositories of the submodules.
+clone.bundle::
+ A bundle file a newer server will tell "git clone" clients
+ to fetch, so that it does not have to pack the entire
+ repository data every time a "git clone" request is made.
+
SEE ALSO
--------
linkgit:git-init[1],
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"));