6 static int do_generic_cmd(const char *me, char *arg)
8 const char *my_argv[4];
10 if (!arg || !(arg = sq_dequote(arg)))
12 if (prefixcmp(me, "git-"))
19 return execv_git_cmd(my_argv);
22 static int do_cvs_cmd(const char *me, char *arg)
24 const char *cvsserver_argv[3] = {
25 "cvsserver", "server", NULL
27 const char *oldpath = getenv("PATH");
28 struct strbuf newpath = STRBUF_INIT;
30 if (!arg || strcmp(arg, "server"))
31 die("git-cvsserver only handles server: %s", arg);
33 strbuf_addstr(&newpath, git_exec_path());
34 strbuf_addch(&newpath, ':');
35 strbuf_addstr(&newpath, oldpath);
37 setenv("PATH", strbuf_detach(&newpath, NULL), 1);
39 return execv_git_cmd(cvsserver_argv);
43 static struct commands {
45 int (*exec)(const char *me, char *arg);
47 { "git-receive-pack", do_generic_cmd },
48 { "git-upload-pack", do_generic_cmd },
49 { "cvs", do_cvs_cmd },
53 int main(int argc, char **argv)
58 if (argc == 2 && !strcmp(argv[1], "cvs server"))
60 /* We want to see "-c cmd args", and nothing else */
61 else if (argc != 3 || strcmp(argv[1], "-c"))
62 die("What do you think I am? A shell?");
67 for (cmd = cmd_list ; cmd->name ; cmd++) {
68 int len = strlen(cmd->name);
70 if (strncmp(cmd->name, prog, len))
83 exit(cmd->exec(cmd->name, arg));
85 die("unrecognized command '%s'", prog);