MCPcopy Index your code
hub / github.com/git/git / process_request

Function process_request

serve.c:280–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278};
279
280static int process_request(struct repository *r)
281{
282 enum request_state state = PROCESS_REQUEST_KEYS;
283 struct packet_reader reader;
284 int seen_capability_or_command = 0;
285 struct protocol_capability *command = NULL;
286
287 packet_reader_init(&reader, 0, NULL, 0,
288 PACKET_READ_CHOMP_NEWLINE |
289 PACKET_READ_GENTLE_ON_EOF |
290 PACKET_READ_DIE_ON_ERR_PACKET);
291
292 /*
293 * Check to see if the client closed their end before sending another
294 * request. If so we can terminate the connection.
295 */
296 if (packet_reader_peek(&reader) == PACKET_READ_EOF)
297 return 1;
298 reader.options &= ~PACKET_READ_GENTLE_ON_EOF;
299
300 while (state != PROCESS_REQUEST_DONE) {
301 switch (packet_reader_peek(&reader)) {
302 case PACKET_READ_EOF:
303 BUG("Should have already died when seeing EOF");
304 case PACKET_READ_NORMAL:
305 if (parse_command(r, reader.line, &command) ||
306 receive_client_capability(r, reader.line))
307 seen_capability_or_command = 1;
308 else
309 die("unknown capability '%s'", reader.line);
310
311 /* Consume the peeked line */
312 packet_reader_read(&reader);
313 break;
314 case PACKET_READ_FLUSH:
315 /*
316 * If no command and no keys were given then the client
317 * wanted to terminate the connection.
318 */
319 if (!seen_capability_or_command)
320 return 1;
321
322 /*
323 * The flush packet isn't consume here like it is in
324 * the other parts of this switch statement. This is
325 * so that the command can read the flush packet and
326 * see the end of the request in the same way it would
327 * if command specific arguments were provided after a
328 * delim packet.
329 */
330 state = PROCESS_REQUEST_DONE;
331 break;
332 case PACKET_READ_DELIM:
333 /* Consume the peeked line */
334 packet_reader_read(&reader);
335
336 state = PROCESS_REQUEST_DONE;
337 break;

Callers 1

protocol_v2_serve_loopFunction · 0.85

Calls 7

packet_reader_initFunction · 0.85
packet_reader_peekFunction · 0.85
parse_commandFunction · 0.85
packet_reader_readFunction · 0.85
hash_algo_by_ptrFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected