1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/*
* Copyright (C) 2018, 2022 Google LLC. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.transport;
import static java.util.Objects.requireNonNull;
import java.util.List;
import java.util.Set;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.lib.ObjectId;
/**
* Common fields between v0/v1/v2 fetch requests.
*/
abstract class FetchRequest {
final Set<ObjectId> wantIds;
final int depth;
final Set<ObjectId> clientShallowCommits;
final FilterSpec filterSpec;
final Set<String> clientCapabilities;
final int deepenSince;
final List<String> deepenNots;
@Nullable
final String agent;
@Nullable
final String clientSID;
/**
* Initialize the common fields of a fetch request.
*
* @param wantIds
* list of want ids
* @param depth
* how deep to go in the tree
* @param clientShallowCommits
* commits the client has without history
* @param filterSpec
* the filter spec
* @param clientCapabilities
* capabilities sent in the request
* @param deepenNots
* Requests that the shallow clone/fetch should be cut at these
* specific revisions instead of a depth.
* @param deepenSince
* Requests that the shallow clone/fetch should be cut at a
* specific time, instead of depth
* @param agent
* agent as reported by the client in the request body
* @param clientSID
* agent as reported by the client in the request body
*/
FetchRequest(@NonNull Set<ObjectId> wantIds, int depth,
@NonNull Set<ObjectId> clientShallowCommits,
@NonNull FilterSpec filterSpec,
@NonNull Set<String> clientCapabilities, int deepenSince,
@NonNull List<String> deepenNots, @Nullable String agent,
@Nullable String clientSID) {
this.wantIds = requireNonNull(wantIds);
this.depth = depth;
this.clientShallowCommits = requireNonNull(clientShallowCommits);
this.filterSpec = requireNonNull(filterSpec);
this.clientCapabilities = requireNonNull(clientCapabilities);
this.deepenSince = deepenSince;
this.deepenNots = requireNonNull(deepenNots);
this.agent = agent;
this.clientSID = clientSID;
}
/**
* Get object ids in the "want" lines
*
* @return object ids in the "want" (and "want-ref") lines of the request
*/
@NonNull
Set<ObjectId> getWantIds() {
return wantIds;
}
/**
* Get the depth set in a "deepen" line
*
* @return the depth set in a "deepen" line. 0 by default.
*/
int getDepth() {
return depth;
}
/**
* Shallow commits the client already has.
*
* These are sent by the client in "shallow" request lines.
*
* @return set of commits the client has declared as shallow.
*/
@NonNull
Set<ObjectId> getClientShallowCommits() {
return clientShallowCommits;
}
/**
* Get the filter spec given in a "filter" line
*
* @return the filter spec given in a "filter" line
*/
@NonNull
FilterSpec getFilterSpec() {
return filterSpec;
}
/**
* Capabilities that the client wants enabled from the server.
*
* Capabilities are options that tune the expected response from the server,
* like "thin-pack", "no-progress" or "ofs-delta". This list should be a
* subset of the capabilities announced by the server in its first response.
*
* These options are listed and well-defined in the git protocol
* specification.
*
* The agent capability is not included in this set. It can be retrieved via
* {@link #getAgent()}.
*
* @return capabilities sent by the client (excluding the "agent"
* capability)
*/
@NonNull
Set<String> getClientCapabilities() {
return clientCapabilities;
}
/**
* The value in a "deepen-since" line in the request, indicating the
* timestamp where to stop fetching/cloning.
*
* @return timestamp in seconds since the epoch, where to stop the shallow
* fetch/clone. Defaults to 0 if not set in the request.
*/
int getDeepenSince() {
return deepenSince;
}
/**
* Get refs received in "deepen-not" lines
*
* @return refs received in "deepen-not" lines.
*/
@NonNull
List<String> getDeepenNots() {
return deepenNots;
}
/**
* Get string identifying the agent
*
* @return string identifying the agent (as sent in the request body by the
* client)
*/
@Nullable
String getAgent() {
return agent;
}
/**
* Get string identifying the client session ID
*
* @return string identifying the client session ID (as sent in the request
* body by the client)
*/
@Nullable
String getClientSID() {
return clientSID;
}
}
|