Skip to content

Commit 8457bef

Browse files
committed
Merge branch 'cc/promisor-remote-capability' into seen
* cc/promisor-remote-capability: promisor-remote: allow a client to check fields promisor-remote: allow a server to advertise more fields promisor-remote: refactor to get rid of 'struct strvec'
2 parents d72d55f + 0578ae4 commit 8457bef

File tree

4 files changed

+425
-65
lines changed

4 files changed

+425
-65
lines changed

Documentation/config/promisor.adoc

Lines changed: 43 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,28 @@ 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, only the "partialCloneFilter" and "token"
54+
fields are supported.
55+
+
56+
When a field is part of this list and a corresponding
57+
"remote.foo.<field>" config variable is set locally for remote "foo",
58+
then the value of this config variable will be checked against the
59+
value of the same field passed by the server for the remote "foo". The
60+
remote "foo" will be rejected if the values don't match.
61+
+
62+
For the "partialCloneFilter" field, this allows the client to ensure
63+
that the server's filter matches what it expects locally, preventing
64+
inconsistencies in filtering behavior. For the "token" field, this can
65+
be used to verify that authentication credentials match expected
66+
values.
67+
+
68+
The fields should be passed by the server through the
69+
"promisor-remote" capability by using the `promisor.sendFields` config
70+
variable. The fields will be checked only if the
71+
`promisor.acceptFromServer` config variable is not set to "None". If
72+
set to "None", this config variable will have no effect. See
73+
linkgit:gitprotocol-v2[5].

Documentation/gitprotocol-v2.adoc

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -785,33 +785,52 @@ 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 = fld-name "=" fld-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 `fld-name` and `fld-value` in a given `pr-fields` are
801+
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`.
806806
807-
pr-names = pr-name | pr-names ";" pr-name
807+
The server MAY advertise the following optional fields:
808+
809+
- "partialCloneFilter": Filter used for partial clone, corresponding
810+
to the "remote.<name>.partialCloneFilter" config setting.
811+
- "token": Authentication token for the remote, corresponding
812+
to the "remote.<name>.token" config setting.
813+
814+
No other fields are defined by the protocol at this time. Clients SHOULD
815+
ignore fields they don't recognize to allow for future protocol extensions.
816+
817+
For now, the client can only use information transmitted through these
818+
fields to decide if it accepts the advertised promisor remote. In the
819+
future that information might be used for other purposes though.
820+
821+
Field values MUST be urlencoded.
822+
823+
If the client decides to use one or more promisor remotes the server
824+
advertised, it can reply with "promisor-remote=<pr-names>" where
825+
<pr-names> should be of the form:
826+
827+
pr-names = pr-name | pr-names ";" pr-names
808828
809829
where `pr-name` is the urlencoded name of a promisor remote the server
810830
advertised and the client accepts.
811831
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`.
832+
Note that, everywhere in this document, the ';' and ',' characters
833+
MUST be encoded if they appear in `pr-name` or `fld-value`.
815834
816835
If the server doesn't know any promisor remote that could be good for
817836
a client to use, or prefers a client not to use any promisor remote it
@@ -822,9 +841,10 @@ In this case, or if the client doesn't want to use any promisor remote
822841
the server advertised, the client shouldn't advertise the
823842
"promisor-remote" capability at all in its reply.
824843
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
844+
On the server side, the "promisor.advertise" and "promisor.sendFields"
845+
configuration options can be used to control what it advertises. On
846+
the client side, the "promisor.acceptFromServer" configuration option
847+
can be used to control what it accepts. See the documentation of these
828848
configuration options for more information.
829849
830850
Note that in the future it would be nice if the "promisor-remote"

0 commit comments

Comments
 (0)