1
- #define USE_THE_REPOSITORY_VARIABLE
2
-
3
1
#include "git-compat-util.h"
4
2
#include "repository.h"
5
3
#include "config.h"
@@ -159,7 +157,7 @@ static struct protocol_capability capabilities[] = {
159
157
},
160
158
};
161
159
162
- void protocol_v2_advertise_capabilities (void )
160
+ void protocol_v2_advertise_capabilities (struct repository * r )
163
161
{
164
162
struct strbuf capability = STRBUF_INIT ;
165
163
struct strbuf value = STRBUF_INIT ;
@@ -170,7 +168,7 @@ void protocol_v2_advertise_capabilities(void)
170
168
for (size_t i = 0 ; i < ARRAY_SIZE (capabilities ); i ++ ) {
171
169
struct protocol_capability * c = & capabilities [i ];
172
170
173
- if (c -> advertise (the_repository , & value )) {
171
+ if (c -> advertise (r , & value )) {
174
172
strbuf_addstr (& capability , c -> name );
175
173
176
174
if (value .len ) {
@@ -214,20 +212,20 @@ static struct protocol_capability *get_capability(const char *key, const char **
214
212
return NULL ;
215
213
}
216
214
217
- static int receive_client_capability (const char * key )
215
+ static int receive_client_capability (struct repository * r , const char * key )
218
216
{
219
217
const char * value ;
220
218
const struct protocol_capability * c = get_capability (key , & value );
221
219
222
- if (!c || c -> command || !c -> advertise (the_repository , NULL ))
220
+ if (!c || c -> command || !c -> advertise (r , NULL ))
223
221
return 0 ;
224
222
225
223
if (c -> receive )
226
- c -> receive (the_repository , value );
224
+ c -> receive (r , value );
227
225
return 1 ;
228
226
}
229
227
230
- static int parse_command (const char * key , struct protocol_capability * * command )
228
+ static int parse_command (struct repository * r , const char * key , struct protocol_capability * * command )
231
229
{
232
230
const char * out ;
233
231
@@ -238,7 +236,7 @@ static int parse_command(const char *key, struct protocol_capability **command)
238
236
if (* command )
239
237
die ("command '%s' requested after already requesting command '%s'" ,
240
238
out , (* command )-> name );
241
- if (!cmd || !cmd -> advertise (the_repository , NULL ) || !cmd -> command || value )
239
+ if (!cmd || !cmd -> advertise (r , NULL ) || !cmd -> command || value )
242
240
die ("invalid command '%s'" , out );
243
241
244
242
* command = cmd ;
@@ -253,7 +251,7 @@ enum request_state {
253
251
PROCESS_REQUEST_DONE ,
254
252
};
255
253
256
- static int process_request (void )
254
+ static int process_request (struct repository * r )
257
255
{
258
256
enum request_state state = PROCESS_REQUEST_KEYS ;
259
257
struct packet_reader reader ;
@@ -278,8 +276,8 @@ static int process_request(void)
278
276
case PACKET_READ_EOF :
279
277
BUG ("Should have already died when seeing EOF" );
280
278
case PACKET_READ_NORMAL :
281
- if (parse_command (reader .line , & command ) ||
282
- receive_client_capability (reader .line ))
279
+ if (parse_command (r , reader .line , & command ) ||
280
+ receive_client_capability (r , reader .line ))
283
281
seen_capability_or_command = 1 ;
284
282
else
285
283
die ("unknown capability '%s'" , reader .line );
@@ -319,30 +317,30 @@ static int process_request(void)
319
317
if (!command )
320
318
die ("no command requested" );
321
319
322
- if (client_hash_algo != hash_algo_by_ptr (the_repository -> hash_algo ))
320
+ if (client_hash_algo != hash_algo_by_ptr (r -> hash_algo ))
323
321
die ("mismatched object format: server %s; client %s" ,
324
- the_repository -> hash_algo -> name ,
322
+ r -> hash_algo -> name ,
325
323
hash_algos [client_hash_algo ].name );
326
324
327
- command -> command (the_repository , & reader );
325
+ command -> command (r , & reader );
328
326
329
327
return 0 ;
330
328
}
331
329
332
- void protocol_v2_serve_loop (int stateless_rpc )
330
+ void protocol_v2_serve_loop (struct repository * r , int stateless_rpc )
333
331
{
334
332
if (!stateless_rpc )
335
- protocol_v2_advertise_capabilities ();
333
+ protocol_v2_advertise_capabilities (r );
336
334
337
335
/*
338
336
* If stateless-rpc was requested then exit after
339
337
* a single request/response exchange
340
338
*/
341
339
if (stateless_rpc ) {
342
- process_request ();
340
+ process_request (r );
343
341
} else {
344
342
for (;;)
345
- if (process_request ())
343
+ if (process_request (r ))
346
344
break ;
347
345
}
348
346
}
0 commit comments