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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
seen
Kristofer Karlsson 2026-10-12 12:07:56 +00:00 committed by Junio C Hamano
parent b51feb0943
commit 01955ae2e2
4 changed files with 54 additions and 0 deletions

View File

@ -1,3 +1,23 @@
transfer.connectivityCheck::
Choose which algorithm to use for the connectivity check
performed during object transfer operations such as
linkgit:git-fetch[1] and linkgit:git-receive-pack[1].
The connectivity check verifies that all objects reachable
from the incoming tips are available locally or, in a partial
clone, promised by a promisor remote.
The variants are as follows:
+
--
`full` (default);;
Walk the full object closure of the boundary commits.
`incremental`;;
Verify incoming commits by diffing their trees against parent
trees, recursively descending only into entries that differ.
The largest benefits occur when incoming commits change a
small fraction of a large tree closure.
Falls back to `full` for deepening fetches.
--

transfer.credentialsInUrl::
A configured URL can contain plaintext credentials in the form
`<protocol>://<user>:<password>@<domain>/<path>`. You may want

View File

@ -1102,6 +1102,12 @@ It is an error to use `--missing-only` without `--missing=print` or
stronger than `--missing=allow-promisor` because it limits the
traversal, rather than just silencing errors about missing
objects.

`--verify-trees-incremental`::
(For internal use only.) Verify tree connectivity
incrementally by comparing each commit's tree against its
parent trees. Used by `check_connected()` when
`transfer.connectivityCheck` is set to `incremental`.
endif::git-rev-list[]

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

View File

@ -769,6 +769,8 @@ int cmd_rev_list(int argc,
if (!strcmp(arg, "--exclude-promisor-objects")) {
repo->fetch_if_missing = 0;
revs.exclude_promisor_objects = 1;
} else if (!strcmp(arg, "--verify-trees-incremental")) {
repo->fetch_if_missing = 0;
} else if (skip_prefix(arg, "--missing=", &arg)) {
parse_missing_action_value(repo, arg);
} else if (!strcmp(arg, "--missing-only")) {
@ -848,6 +850,8 @@ int cmd_rev_list(int argc,

if (!strcmp(arg, "--exclude-promisor-objects"))
continue; /* already handled above */
if (!strcmp(arg, "--verify-trees-incremental"))
continue; /* already handled above */
if (skip_prefix(arg, "--missing=", &arg))
continue; /* already handled above */


View File

@ -1,6 +1,7 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "odb.h"
@ -67,6 +68,26 @@ static int check_connected_promisor(oid_iterate_fn fn,
return 1;
}

static int incremental_check_applicable(struct check_connected_options *opt)
{
const char *algorithm = NULL;

if (repo_config_get_string_tmp(the_repository,
"transfer.connectivitycheck",
&algorithm))
return 0;
if (!strcasecmp(algorithm, "full"))
return 0;
if (strcasecmp(algorithm, "incremental"))
die(_("unknown transfer.connectivityCheck algorithm '%s'"),
algorithm);

if (opt->is_deepening_fetch)
return 0;

return 1;
}

/*
* If we feed all the commits we want to verify to this command
*
@ -133,6 +154,9 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
if (opt->progress)
strvec_pushf(&rev_list.args, "--progress=%s",
_("Checking connectivity"));
if (incremental_check_applicable(opt))
strvec_push(&rev_list.args,
"--verify-trees-incremental");

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