MCPcopy Create free account
hub / github.com/git/git / command_loop

Function command_loop

builtin/remote-fd.c:24–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#define MAXCOMMAND 4096
23
24static void command_loop(int input_fd, int output_fd)
25{
26 char buffer[MAXCOMMAND];
27
28 while (1) {
29 size_t i;
30 if (!fgets(buffer, MAXCOMMAND - 1, stdin)) {
31 if (ferror(stdin))
32 die("Input error");
33 return;
34 }
35 /* Strip end of line characters. */
36 i = strlen(buffer);
37 while (i > 0 && isspace(buffer[i - 1]))
38 buffer[--i] = 0;
39
40 if (!strcmp(buffer, "capabilities")) {
41 printf("*connect\n\n");
42 fflush(stdout);
43 } else if (starts_with(buffer, "connect ")) {
44 printf("\n");
45 fflush(stdout);
46 if (bidirectional_transfer_loop(input_fd,
47 output_fd))
48 die("Copying data between file descriptors failed");
49 return;
50 } else {
51 die("Bad command: %s", buffer);
52 }
53 }
54}
55
56int cmd_remote_fd(int argc,
57 const char **argv,

Callers 1

cmd_remote_fdFunction · 0.70

Calls 3

starts_withFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected