6 /* Stubs for functions that make no sense for git-shell. These stubs
7 * are provided here to avoid linking in external redundant modules.
9 void release_pack_memory(size_t need, int fd){}
10 void trace_argv_printf(const char **argv, const char *fmt, ...){}
11 void trace_printf(const char *fmt, ...){}
14 static int do_generic_cmd(const char *me, char *arg)
16 const char *my_argv[4];
19 if (!arg || !(arg = sq_dequote(arg)))
21 if (prefixcmp(me, "git-"))
28 return execv_git_cmd(my_argv);
31 static int do_cvs_cmd(const char *me, char *arg)
33 const char *cvsserver_argv[3] = {
34 "cvsserver", "server", NULL
37 if (!arg || strcmp(arg, "server"))
38 die("git-cvsserver only handles server: %s", arg);
41 return execv_git_cmd(cvsserver_argv);
45 static struct commands {
47 int (*exec)(const char *me, char *arg);
49 { "git-receive-pack", do_generic_cmd },
50 { "git-upload-pack", do_generic_cmd },
51 { "cvs", do_cvs_cmd },
55 int main(int argc, char **argv)
61 * Special hack to pretend to be a CVS server
63 if (argc == 2 && !strcmp(argv[1], "cvs server"))
67 * We do not accept anything but "-c" followed by "cmd arg",
68 * where "cmd" is a very limited subset of git commands.
70 else if (argc != 3 || strcmp(argv[1], "-c"))
71 die("What do you think I am? A shell?");
74 if (!strncmp(prog, "git", 3) && isspace(prog[3]))
75 /* Accept "git foo" as if the caller said "git-foo". */
78 for (cmd = cmd_list ; cmd->name ; cmd++) {
79 int len = strlen(cmd->name);
81 if (strncmp(cmd->name, prog, len))
94 exit(cmd->exec(cmd->name, arg));
96 die("unrecognized command '%s'", prog);