1- #define USE_THE_REPOSITORY_VARIABLE
2-
31#include "git-compat-util.h"
42#include "repository.h"
53#include "config.h"
@@ -159,7 +157,7 @@ static struct protocol_capability capabilities[] = {
159157 },
160158};
161159
162- void protocol_v2_advertise_capabilities (void )
160+ void protocol_v2_advertise_capabilities (struct repository * r )
163161{
164162 struct strbuf capability = STRBUF_INIT ;
165163 struct strbuf value = STRBUF_INIT ;
@@ -170,7 +168,7 @@ void protocol_v2_advertise_capabilities(void)
170168 for (size_t i = 0 ; i < ARRAY_SIZE (capabilities ); i ++ ) {
171169 struct protocol_capability * c = & capabilities [i ];
172170
173- if (c -> advertise (the_repository , & value )) {
171+ if (c -> advertise (r , & value )) {
174172 strbuf_addstr (& capability , c -> name );
175173
176174 if (value .len ) {
@@ -214,20 +212,20 @@ static struct protocol_capability *get_capability(const char *key, const char **
214212 return NULL ;
215213}
216214
217- static int receive_client_capability (const char * key )
215+ static int receive_client_capability (struct repository * r , const char * key )
218216{
219217 const char * value ;
220218 const struct protocol_capability * c = get_capability (key , & value );
221219
222- if (!c || c -> command || !c -> advertise (the_repository , NULL ))
220+ if (!c || c -> command || !c -> advertise (r , NULL ))
223221 return 0 ;
224222
225223 if (c -> receive )
226- c -> receive (the_repository , value );
224+ c -> receive (r , value );
227225 return 1 ;
228226}
229227
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 )
231229{
232230 const char * out ;
233231
@@ -238,7 +236,7 @@ static int parse_command(const char *key, struct protocol_capability **command)
238236 if (* command )
239237 die ("command '%s' requested after already requesting command '%s'" ,
240238 out , (* command )-> name );
241- if (!cmd || !cmd -> advertise (the_repository , NULL ) || !cmd -> command || value )
239+ if (!cmd || !cmd -> advertise (r , NULL ) || !cmd -> command || value )
242240 die ("invalid command '%s'" , out );
243241
244242 * command = cmd ;
@@ -253,7 +251,7 @@ enum request_state {
253251 PROCESS_REQUEST_DONE ,
254252};
255253
256- static int process_request (void )
254+ static int process_request (struct repository * r )
257255{
258256 enum request_state state = PROCESS_REQUEST_KEYS ;
259257 struct packet_reader reader ;
@@ -278,8 +276,8 @@ static int process_request(void)
278276 case PACKET_READ_EOF :
279277 BUG ("Should have already died when seeing EOF" );
280278 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 ))
283281 seen_capability_or_command = 1 ;
284282 else
285283 die ("unknown capability '%s'" , reader .line );
@@ -319,30 +317,30 @@ static int process_request(void)
319317 if (!command )
320318 die ("no command requested" );
321319
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 ))
323321 die ("mismatched object format: server %s; client %s" ,
324- the_repository -> hash_algo -> name ,
322+ r -> hash_algo -> name ,
325323 hash_algos [client_hash_algo ].name );
326324
327- command -> command (the_repository , & reader );
325+ command -> command (r , & reader );
328326
329327 return 0 ;
330328}
331329
332- void protocol_v2_serve_loop (int stateless_rpc )
330+ void protocol_v2_serve_loop (struct repository * r , int stateless_rpc )
333331{
334332 if (!stateless_rpc )
335- protocol_v2_advertise_capabilities ();
333+ protocol_v2_advertise_capabilities (r );
336334
337335 /*
338336 * If stateless-rpc was requested then exit after
339337 * a single request/response exchange
340338 */
341339 if (stateless_rpc ) {
342- process_request ();
340+ process_request (r );
343341 } else {
344342 for (;;)
345- if (process_request ())
343+ if (process_request (r ))
346344 break ;
347345 }
348346}
0 commit comments