Skip to content

Commit a0dc569

Browse files
committed
Merge branch 'cc/promisor-remote-capability' into seen
The "promisor-remote" capability mechanism has been updated to allow the "partialCloneFilter" settings and the "token" value to be communicated from the server side. * cc/promisor-remote-capability: promisor-remote: use string constants for 'name' and 'url' too promisor-remote: allow a client to check fields promisor-remote: refactor how we parse advertised fields promisor-remote: allow a server to advertise more fields promisor-remote: refactor to get rid of 'struct strvec'
2 parents b4ad032 + a348195 commit a0dc569

File tree

4 files changed

+479
-83
lines changed

4 files changed

+479
-83
lines changed

Documentation/config/promisor.adoc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ promisor.advertise::
99
"false", which means the "promisor-remote" capability is not
1010
advertised.
1111

12+
promisor.sendFields::
13+
A comma or space separated list of additional remote related
14+
fields that a server will send while advertising its promisor
15+
remotes using the "promisor-remote" capability, see
16+
linkgit:gitprotocol-v2[5]. Currently, only the
17+
"partialCloneFilter" and "token" fields are supported. The
18+
"partialCloneFilter" field contains the partial clone filter
19+
used for the remote, and the "token" field contains an
20+
authentication token for the remote.
21+
+
22+
When a field is part of this list and a corresponding
23+
"remote.foo.<field>" config variable is set on the server to a
24+
non-empty value, then the field and its value will be sent when
25+
advertising the promisor remote "foo". This list has no effect unless
26+
the "promisor.advertise" config variable is set to "true", and the
27+
"name" and "url" fields are always advertised regardless of this
28+
setting.
29+
1230
promisor.acceptFromServer::
1331
If set to "all", a client will accept all the promisor remotes
1432
a server might advertise using the "promisor-remote"
@@ -28,3 +46,38 @@ promisor.acceptFromServer::
2846
lazily fetchable from this promisor remote from its responses
2947
to "fetch" and "clone" requests from the client. Name and URL
3048
comparisons are case sensitive. See linkgit:gitprotocol-v2[5].
49+
50+
promisor.checkFields::
51+
A comma or space separated list of additional remote related
52+
fields that a client will check before accepting a promisor
53+
remote. Currently, "partialCloneFilter" and "token" are the only
54+
supported field names.
55+
+
56+
If one of these field names (e.g., "token") is being checked for an
57+
advertised promisor remote (e.g., "foo"), three conditions must be met
58+
for the check of this specific field to pass:
59+
+
60+
1. The corresponding local configuration (e.g., `remote.foo.token`)
61+
must be set.
62+
2. The server must advertise the "token" field for remote "foo".
63+
3. The value of the locally configured `remote.foo.token` must exactly
64+
match the value advertised by the server for the "token" field.
65+
+
66+
If any of these conditions are not met for any field name listed in
67+
`promisor.checkFields`, the advertised remote "foo" will be rejected.
68+
+
69+
For the "partialCloneFilter" field, this allows the client to ensure
70+
that the server's filter matches what it expects locally, preventing
71+
inconsistencies in filtering behavior. For the "token" field, this can
72+
be used to verify that authentication credentials match expected
73+
values.
74+
+
75+
The "name" and "url" fields are always checked according to the
76+
`promisor.acceptFromServer` policy, independently of this setting.
77+
+
78+
The fields should be passed by the server through the
79+
"promisor-remote" capability by using the `promisor.sendFields` config
80+
variable. The fields will be checked only if the
81+
`promisor.acceptFromServer` config variable is not set to "None". If
82+
set to "None", this config variable will have no effect. See
83+
linkgit:gitprotocol-v2[5].

Documentation/gitprotocol-v2.adoc

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -785,33 +785,59 @@ retrieving the header from a bundle at the indicated URI, and thus
785785
save themselves and the server(s) the request(s) needed to inspect the
786786
headers of that bundle or bundles.
787787
788-
promisor-remote=<pr-infos>
788+
promisor-remote=<pr-info>
789789
~~~~~~~~~~~~~~~~~~~~~~~~~~
790790
791791
The server may advertise some promisor remotes it is using or knows
792792
about to a client which may want to use them as its promisor remotes,
793-
instead of this repository. In this case <pr-infos> should be of the
793+
instead of this repository. In this case <pr-info> should be of the
794794
form:
795795
796-
pr-infos = pr-info | pr-infos ";" pr-info
796+
pr-info = pr-fields | pr-info ";" pr-info
797797
798-
pr-info = "name=" pr-name | "name=" pr-name "," "url=" pr-url
798+
pr-fields = field-name "=" field-value | pr-fields "," pr-fields
799799
800-
where `pr-name` is the urlencoded name of a promisor remote, and
801-
`pr-url` the urlencoded URL of that promisor remote.
800+
where all the `field-name` and `field-value` in a given `pr-fields`
801+
are field names and values related to a single promisor remote.
802802
803-
In this case, if the client decides to use one or more promisor
804-
remotes the server advertised, it can reply with
805-
"promisor-remote=<pr-names>" where <pr-names> should be of the form:
803+
The server MUST advertise at least the "name" and "url" field names
804+
along with the associated field values, which are the name of a valid
805+
remote and its URL, in each `pr-fields`. The "name" and "url" fields
806+
MUST appear first in each pr-fields, in that order.
806807
807-
pr-names = pr-name | pr-names ";" pr-name
808+
After these mandatory fields, the server MAY advertise the following
809+
optional fields in any order:
810+
811+
- "partialCloneFilter": The filter specification used by the remote.
812+
Clients can use this to determine if the remote's filtering strategy
813+
is compatible with their needs (e.g., checking if both use "blob:none").
814+
It corresponds to the "remote.<name>.partialCloneFilter" config setting.
815+
816+
- "token": An authentication token that clients can use when
817+
connecting to the remote. It corresponds to the "remote.<name>.token"
818+
config setting.
819+
820+
No other fields are defined by the protocol at this time. Clients MUST
821+
ignore fields they don't recognize to allow for future protocol
822+
extensions.
823+
824+
For now, the client can only use information transmitted through these
825+
fields to decide if it accepts the advertised promisor remote. In the
826+
future that information might be used for other purposes though.
827+
828+
Field values MUST be urlencoded.
829+
830+
If the client decides to use one or more promisor remotes the server
831+
advertised, it can reply with "promisor-remote=<pr-names>" where
832+
<pr-names> should be of the form:
833+
834+
pr-names = pr-name | pr-names ";" pr-names
808835
809836
where `pr-name` is the urlencoded name of a promisor remote the server
810837
advertised and the client accepts.
811838
812-
Note that, everywhere in this document, `pr-name` MUST be a valid
813-
remote name, and the ';' and ',' characters MUST be encoded if they
814-
appear in `pr-name` or `pr-url`.
839+
Note that, everywhere in this document, the ';' and ',' characters
840+
MUST be encoded if they appear in `pr-name` or `field-value`.
815841
816842
If the server doesn't know any promisor remote that could be good for
817843
a client to use, or prefers a client not to use any promisor remote it
@@ -822,9 +848,10 @@ In this case, or if the client doesn't want to use any promisor remote
822848
the server advertised, the client shouldn't advertise the
823849
"promisor-remote" capability at all in its reply.
824850
825-
The "promisor.advertise" and "promisor.acceptFromServer" configuration
826-
options can be used on the server and client side to control what they
827-
advertise or accept respectively. See the documentation of these
851+
On the server side, the "promisor.advertise" and "promisor.sendFields"
852+
configuration options can be used to control what it advertises. On
853+
the client side, the "promisor.acceptFromServer" configuration option
854+
can be used to control what it accepts. See the documentation of these
828855
configuration options for more information.
829856
830857
Note that in the future it would be nice if the "promisor-remote"

0 commit comments

Comments
 (0)