pack-check.c::verify_packfile(): don't run SHA-1 update on huge data
[git/mingw/4msysgit/wingit-dll.git] / shell.c
blob8c08cf0fb339d293383c3dacb8cdfc805afa3727
1 #include "cache.h"
2 #include "quote.h"
3 #include "exec_cmd.h"
5 static int do_generic_cmd(const char *me, char *arg)
7 const char *my_argv[4];
9 if (!arg || !(arg = sq_dequote(arg)))
10 die("bad argument");
11 if (strncmp(me, "git-", 4))
12 die("bad command");
14 my_argv[0] = me + 4;
15 my_argv[1] = arg;
16 my_argv[2] = NULL;
18 return execv_git_cmd(my_argv);
21 static struct commands {
22 const char *name;
23 int (*exec)(const char *me, char *arg);
24 } cmd_list[] = {
25 { "git-receive-pack", do_generic_cmd },
26 { "git-upload-pack", do_generic_cmd },
27 { NULL },
30 int main(int argc, char **argv)
32 char *prog;
33 struct commands *cmd;
35 /* We want to see "-c cmd args", and nothing else */
36 if (argc != 3 || strcmp(argv[1], "-c"))
37 die("What do you think I am? A shell?");
39 prog = argv[2];
40 argv += 2;
41 argc -= 2;
42 for (cmd = cmd_list ; cmd->name ; cmd++) {
43 int len = strlen(cmd->name);
44 char *arg;
45 if (strncmp(cmd->name, prog, len))
46 continue;
47 arg = NULL;
48 switch (prog[len]) {
49 case '\0':
50 arg = NULL;
51 break;
52 case ' ':
53 arg = prog + len + 1;
54 break;
55 default:
56 continue;
58 exit(cmd->exec(cmd->name, arg));
60 die("unrecognized command '%s'", prog);