Add a new 'remote.<name>.negotiationInclude' multi-valued config option that
provides default values for --negotiation-include when no
--negotiation-include arguments are specified over the command line. This
is a mirror of how 'remote.<name>.negotiationRestrict' specifies defaults
for the --negotiation-restrict arguments.
Each value is either an exact ref name or a glob pattern whose tips should
always be sent as 'have' lines during negotiation. The config values are
resolved through the same resolve_negotiation_include() codepath as the CLI
options.
This option is additive with the normal negotiation process: the negotiation
algorithm still runs and advertises its own selected commits, but the refs
matching the config are sent unconditionally on top of those heuristically
selected commits.
Similar to the negotiationRestrict config, an empty value resets the value
list to allow ignoring earlier config values, such as those that might be
set in system or global config.
Reviewed-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committedMay 19, 2026 at 16:24 UTC6f37fecfed7633d47b2c0e16fde0a8ca89e45beb
6 files changed+96
Documentation/config/remote.adoc
+25
index 4dcf81fbce..1951df154e 100644--- a/Documentation/config/remote.adoc+++ b/Documentation/config/remote.adoc@@ -125,6 +125,31 @@ values are not used. Blank values signal to ignore all previous values, allowing a reset of the list from broader config scenarios.+remote.<name>.negotiationInclude::+ When negotiating with this remote during `git fetch`, the client+ advertises a list of commits that exist locally. In repos with+ many references, this list of "haves" can be truncated. Depending+ on data shape, dropping certain references may be expensive. This+ multi-valued config option specifies references, commit hashes,+ or ref pattern globs whose tips should always be sent as "have"+ commits during fetch negotiation with this remote.+++Each value is either an exact ref name (e.g. `refs/heads/release`), a+commit hash, or a glob pattern (e.g. `refs/heads/release/*`). The+pattern syntax is the same as for `--negotiation-include`.+++These config values are used as defaults for the `--negotiation-include`+command-line option. If `--negotiation-include` is specified on the+command line, then the config values are not used.+++This option is additive with the normal negotiation process: the+negotiation algorithm still runs and advertises its own selected commits,+but the refs matching `remote.<name>.negotiationInclude` are sent+unconditionally on top of those heuristically selected commits.+++Blank values signal to ignore all previous values, allowing a reset of+the list from broader config scenarios.+ remote.<name>.followRemoteHEAD:: How linkgit:git-fetch[1] should handle updates to `remotes/<name>/HEAD` when fetching using the configured refspecs of a remote.
Documentation/fetch-options.adoc
+4
index 7b897a7202..8074004377 100644--- a/Documentation/fetch-options.adoc+++ b/Documentation/fetch-options.adoc@@ -91,6 +91,10 @@ The pattern syntax is the same as for `--negotiation-restrict`. If `--negotiation-restrict` is used, the have set is first restricted by that option and then increased to include the tips specified by `--negotiation-include`.+++If this option is not specified on the command line, then any+`remote.<name>.negotiationInclude` config values for the current remote+are used instead. `--negotiate-only`:: Do not fetch anything from the server, and instead print the
builtin/fetch.c
+12
index ba56e9022b..1af6500c1d 100644--- a/builtin/fetch.c+++ b/builtin/fetch.c@@ -1634,6 +1634,18 @@ static struct transport *prepare_transport(struct remote *remote, int deepen, else warning(_("ignoring %s because the protocol does not support it"), "--negotiation-include");+ } else if (remote->negotiation_include.nr) {+ if (transport->smart_options) {+ add_negotiation_tips(&remote->negotiation_include,+ &transport->smart_options->negotiation_include_tips,+ "--negotiation-include");+ } else {+ struct strbuf config_name = STRBUF_INIT;+ strbuf_addf(&config_name, "remote.%s.negotiationInclude", remote->name);+ warning(_("ignoring %s because the protocol does not support it"),+ config_name.buf);+ strbuf_release(&config_name);+ } } return transport; }