Skip to content

Commit 72380a4

Browse files
committed
connected: add transfer.connectivityCheck config and rev-list flag
Add the transfer.connectivityCheck configuration option, accepting "full" (default) and "incremental". When set to "incremental", check_connected() passes --verify-trees-incremental to its rev-list subprocess. The rev-list flag is accepted but has no effect yet; the incremental verification will be implemented in the next commit. Signed-off-by: Kristofer Karlsson <krka@spotify.com>
1 parent 8c9a99b commit 72380a4

4 files changed

Lines changed: 55 additions & 0 deletions

File tree

‎Documentation/config/transfer.adoc‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
transfer.connectivityCheck::
2+
Choose which algorithm to use for the connectivity check
3+
performed during object transfer operations such as
4+
linkgit:git-fetch[1] and linkgit:git-receive-pack[1].
5+
The connectivity check verifies that all objects reachable
6+
from the incoming tips are available locally or, in a partial
7+
clone, promised by a promisor remote.
8+
The variants are as follows:
9+
+
10+
--
11+
`full` (default);;
12+
Walk the full object closure of the boundary commits.
13+
`incremental`;;
14+
Verify incoming commits by diffing their trees against parent
15+
trees, recursively descending only into entries that differ.
16+
The largest benefits occur when incoming commits change a
17+
small fraction of a large tree closure.
18+
Falls back to `full` for deepening fetches.
19+
--
20+
121
transfer.credentialsInUrl::
222
A configured URL can contain plaintext credentials in the form
323
`<protocol>://<user>:<password>@<domain>/<path>`. You may want

‎Documentation/rev-list-options.adoc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,12 @@ It is an error to use `--missing-only` without `--missing=print` or
11021102
stronger than `--missing=allow-promisor` because it limits the
11031103
traversal, rather than just silencing errors about missing
11041104
objects.
1105+
1106+
`--verify-trees-incremental`::
1107+
(For internal use only.) Verify tree connectivity
1108+
incrementally by comparing each commit's tree against its
1109+
parent trees. Used by `check_connected()` when
1110+
`transfer.connectivityCheck` is set to `incremental`.
11051111
endif::git-rev-list[]
11061112

11071113
`--no-walk[=(sorted|unsorted)]`::

‎builtin/rev-list.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ int cmd_rev_list(int argc,
769769
if (!strcmp(arg, "--exclude-promisor-objects")) {
770770
repo->fetch_if_missing = 0;
771771
revs.exclude_promisor_objects = 1;
772+
} else if (!strcmp(arg, "--verify-trees-incremental")) {
773+
repo->fetch_if_missing = 0;
772774
} else if (skip_prefix(arg, "--missing=", &arg)) {
773775
parse_missing_action_value(repo, arg);
774776
} else if (!strcmp(arg, "--missing-only")) {
@@ -848,6 +850,8 @@ int cmd_rev_list(int argc,
848850

849851
if (!strcmp(arg, "--exclude-promisor-objects"))
850852
continue; /* already handled above */
853+
if (!strcmp(arg, "--verify-trees-incremental"))
854+
continue; /* already handled above */
851855
if (skip_prefix(arg, "--missing=", &arg))
852856
continue; /* already handled above */
853857

‎connected.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "config.h"
23
#include "gettext.h"
34
#include "hex.h"
45
#include "odb.h"
@@ -66,6 +67,27 @@ static int check_connected_promisor(struct repository *repo,
6667
return 1;
6768
}
6869

70+
static int incremental_check_applicable(struct repository *repo,
71+
struct check_connected_options *opt)
72+
{
73+
const char *algorithm = NULL;
74+
75+
if (repo_config_get_string_tmp(repo,
76+
"transfer.connectivitycheck",
77+
&algorithm))
78+
return 0;
79+
if (!strcasecmp(algorithm, "full"))
80+
return 0;
81+
if (strcasecmp(algorithm, "incremental"))
82+
die(_("unknown transfer.connectivityCheck algorithm '%s'"),
83+
algorithm);
84+
85+
if (opt->is_deepening_fetch)
86+
return 0;
87+
88+
return 1;
89+
}
90+
6991
/*
7092
* If we feed all the commits we want to verify to this command
7193
*
@@ -133,6 +155,9 @@ int check_connected(struct repository *repo,
133155
if (opt->progress)
134156
strvec_pushf(&rev_list.args, "--progress=%s",
135157
_("Checking connectivity"));
158+
if (incremental_check_applicable(repo, opt))
159+
strvec_push(&rev_list.args,
160+
"--verify-trees-incremental");
136161

137162
rev_list.git_cmd = 1;
138163
if (opt->env)

0 commit comments

Comments
 (0)