mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
c2e86addb8
Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
79 lines
1.8 KiB
C
79 lines
1.8 KiB
C
#include "builtin.h"
|
|
#include "transport.h"
|
|
|
|
/*
|
|
* URL syntax:
|
|
* 'fd::<inoutfd>[/<anything>]' Read/write socket pair
|
|
* <inoutfd>.
|
|
* 'fd::<infd>,<outfd>[/<anything>]' Read pipe <infd> and write
|
|
* pipe <outfd>.
|
|
* [foo] indicates 'foo' is optional. <anything> is any string.
|
|
*
|
|
* The data output to <outfd>/<inoutfd> should be passed unmolested to
|
|
* git-receive-pack/git-upload-pack/git-upload-archive and output of
|
|
* git-receive-pack/git-upload-pack/git-upload-archive should be passed
|
|
* unmolested to <infd>/<inoutfd>.
|
|
*
|
|
*/
|
|
|
|
#define MAXCOMMAND 4096
|
|
|
|
static void command_loop(int input_fd, int output_fd)
|
|
{
|
|
char buffer[MAXCOMMAND];
|
|
|
|
while (1) {
|
|
size_t i;
|
|
if (!fgets(buffer, MAXCOMMAND - 1, stdin)) {
|
|
if (ferror(stdin))
|
|
die("Input error");
|
|
return;
|
|
}
|
|
/* Strip end of line characters. */
|
|
i = strlen(buffer);
|
|
while (i > 0 && isspace(buffer[i - 1]))
|
|
buffer[--i] = 0;
|
|
|
|
if (!strcmp(buffer, "capabilities")) {
|
|
printf("*connect\n\n");
|
|
fflush(stdout);
|
|
} else if (!strncmp(buffer, "connect ", 8)) {
|
|
printf("\n");
|
|
fflush(stdout);
|
|
if (bidirectional_transfer_loop(input_fd,
|
|
output_fd))
|
|
die("Copying data between file descriptors failed");
|
|
return;
|
|
} else {
|
|
die("Bad command: %s", buffer);
|
|
}
|
|
}
|
|
}
|
|
|
|
int cmd_remote_fd(int argc, const char **argv, const char *prefix)
|
|
{
|
|
int input_fd = -1;
|
|
int output_fd = -1;
|
|
char *end;
|
|
|
|
if (argc != 3)
|
|
die("Expected two arguments");
|
|
|
|
input_fd = (int)strtoul(argv[2], &end, 10);
|
|
|
|
if ((end == argv[2]) || (*end != ',' && *end != '/' && *end))
|
|
die("Bad URL syntax");
|
|
|
|
if (*end == '/' || !*end) {
|
|
output_fd = input_fd;
|
|
} else {
|
|
char *end2;
|
|
output_fd = (int)strtoul(end + 1, &end2, 10);
|
|
|
|
if ((end2 == end + 1) || (*end2 != '/' && *end2))
|
|
die("Bad URL syntax");
|
|
}
|
|
|
|
command_loop(input_fd, output_fd);
|
|
return 0;
|
|
}
|