Skip to content

Commit 1ba9ba5

Browse files
committed
Merge branch 'ds/bundle-uri-5' into next
The bundle-URI subsystem adds support for creation-token heuristics to help incremental fetches. * ds/bundle-uri-5: bundle-uri: test missing bundles with heuristic bundle-uri: store fetch.bundleCreationToken fetch: fetch from an external bundle URI bundle-uri: drop bundle.flag from design doc clone: set fetch.bundleURI if appropriate bundle-uri: download in creationToken order bundle-uri: parse bundle.<id>.creationToken values bundle-uri: parse bundle.heuristic=creationToken t5558: add tests for creationToken heuristic bundle: verify using check_connected() bundle: test unbundling with incomplete history
2 parents 3a70d6e + 026df9e commit 1ba9ba5

File tree

13 files changed

+1149
-57
lines changed

13 files changed

+1149
-57
lines changed

Documentation/config/bundle.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ bundle.mode::
1515
complete understanding of the bundled information (`all`) or if any one
1616
of the listed bundle URIs is sufficient (`any`).
1717

18+
bundle.heuristic::
19+
If this string-valued key exists, then the bundle list is designed to
20+
work well with incremental `git fetch` commands. The heuristic signals
21+
that there are additional keys available for each bundle that help
22+
determine which subset of bundles the client should download. The
23+
only value currently understood is `creationToken`.
24+
1825
bundle.<id>.*::
1926
The `bundle.<id>.*` keys are used to describe a single item in the
2027
bundle list, grouped under `<id>` for identification purposes.

Documentation/config/fetch.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,27 @@ fetch.writeCommitGraph::
9696
merge and the write may take longer. Having an updated commit-graph
9797
file helps performance of many Git commands, including `git merge-base`,
9898
`git push -f`, and `git log --graph`. Defaults to false.
99+
100+
fetch.bundleURI::
101+
This value stores a URI for downloading Git object data from a bundle
102+
URI before performing an incremental fetch from the origin Git server.
103+
This is similar to how the `--bundle-uri` option behaves in
104+
linkgit:git-clone[1]. `git clone --bundle-uri` will set the
105+
`fetch.bundleURI` value if the supplied bundle URI contains a bundle
106+
list that is organized for incremental fetches.
107+
+
108+
If you modify this value and your repository has a `fetch.bundleCreationToken`
109+
value, then remove that `fetch.bundleCreationToken` value before fetching from
110+
the new bundle URI.
111+
112+
fetch.bundleCreationToken::
113+
When using `fetch.bundleURI` to fetch incrementally from a bundle
114+
list that uses the "creationToken" heuristic, this config value
115+
stores the maximum `creationToken` value of the downloaded bundles.
116+
This value is used to prevent downloading bundles in the future
117+
if the advertised `creationToken` is not strictly larger than this
118+
value.
119+
+
120+
The creation token values are chosen by the provider serving the specific
121+
bundle URI. If you modify the URI at `fetch.bundleURI`, then be sure to
122+
remove the value for the `fetch.bundleCreationToken` value before fetching.

Documentation/technical/bundle-uri.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,14 @@ outline for submitting these features:
479479
(This choice is an opt-in via a config option and a command-line
480480
option.)
481481

482-
4. Allow the client to understand the `bundle.flag=forFetch` configuration
482+
4. Allow the client to understand the `bundle.heuristic` configuration key
483483
and the `bundle.<id>.creationToken` heuristic. When `git clone`
484-
discovers a bundle URI with `bundle.flag=forFetch`, it configures the
485-
client repository to check that bundle URI during later `git fetch <remote>`
484+
discovers a bundle URI with `bundle.heuristic`, it configures the client
485+
repository to check that bundle URI during later `git fetch <remote>`
486486
commands.
487487

488488
5. Allow clients to discover bundle URIs during `git fetch` and configure
489-
a bundle URI for later fetches if `bundle.flag=forFetch`.
489+
a bundle URI for later fetches if `bundle.heuristic` is set.
490490

491491
6. Implement the "inspect headers" heuristic to reduce data downloads when
492492
the `bundle.<id>.creationToken` heuristic is not available.

builtin/clone.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,12 +1248,16 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12481248
* data from the --bundle-uri option.
12491249
*/
12501250
if (bundle_uri) {
1251+
int has_heuristic = 0;
1252+
12511253
/* At this point, we need the_repository to match the cloned repo. */
12521254
if (repo_init(the_repository, git_dir, work_tree))
12531255
warning(_("failed to initialize the repo, skipping bundle URI"));
1254-
else if (fetch_bundle_uri(the_repository, bundle_uri))
1256+
else if (fetch_bundle_uri(the_repository, bundle_uri, &has_heuristic))
12551257
warning(_("failed to fetch objects from bundle URI '%s'"),
12561258
bundle_uri);
1259+
else if (has_heuristic)
1260+
git_config_set_gently("fetch.bundleuri", bundle_uri);
12571261
}
12581262

12591263
strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");

builtin/fetch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "commit-graph.h"
3030
#include "shallow.h"
3131
#include "worktree.h"
32+
#include "bundle-uri.h"
3233

3334
#define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000)
3435

@@ -2109,6 +2110,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
21092110
int cmd_fetch(int argc, const char **argv, const char *prefix)
21102111
{
21112112
int i;
2113+
const char *bundle_uri;
21122114
struct string_list list = STRING_LIST_INIT_DUP;
21132115
struct remote *remote = NULL;
21142116
int result = 0;
@@ -2194,6 +2196,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21942196
if (dry_run)
21952197
write_fetch_head = 0;
21962198

2199+
if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
2200+
fetch_bundle_uri(the_repository, bundle_uri, NULL))
2201+
warning(_("failed to fetch bundles from '%s'"), bundle_uri);
2202+
21972203
if (all) {
21982204
if (argc == 1)
21992205
die(_("fetch --all does not take a repository argument"));

0 commit comments

Comments
 (0)