fetch: fetch from an external bundle URI
When a user specifies a URI via 'git clone --bundle-uri', that URI may be a bundle list that advertises a 'bundle.heuristic' value. In that case, the Git client stores a 'fetch.bundleURI' config value storing that URI. Teach 'git fetch' to check for this config value and download bundles from that URI before fetching from the Git remote(s). Likely, the bundle provider has configured a heuristic (such as "creationToken") that will allow the Git client to download only a portion of the bundles before continuing the fetch. Since this URI is completely independent of the remote server, we want to be sure that we connect to the bundle URI before creating a connection to the Git remote. We do not want to hold a stateful connection for too long if we can avoid it. To test that this works correctly, extend the previous tests that set 'fetch.bundleURI' to do follow-up fetches. The bundle list is updated incrementally at each phase to demonstrate that the heuristic avoids downloading older bundles. This includes the middle fetch downloading the objects in bundle-3.bundle from the Git remote, and therefore not needing that bundle in the third fetch. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0524ad3542
commit
7f0cc04f2c
@ -29,6 +29,7 @@
|
||||
#include "commit-graph.h"
|
||||
#include "shallow.h"
|
||||
#include "worktree.h"
|
||||
#include "bundle-uri.h"
|
||||
|
||||
#define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000)
|
||||
|
||||
@ -2109,6 +2110,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
|
||||
int cmd_fetch(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int i;
|
||||
const char *bundle_uri;
|
||||
struct string_list list = STRING_LIST_INIT_DUP;
|
||||
struct remote *remote = NULL;
|
||||
int result = 0;
|
||||
@ -2194,6 +2196,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
|
||||
if (dry_run)
|
||||
write_fetch_head = 0;
|
||||
|
||||
if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
|
||||
fetch_bundle_uri(the_repository, bundle_uri, NULL))
|
||||
warning(_("failed to fetch bundles from '%s'"), bundle_uri);
|
||||
|
||||
if (all) {
|
||||
if (argc == 1)
|
||||
die(_("fetch --all does not take a repository argument"));
|
||||
|
Reference in New Issue
Block a user