Skip to content

Commit bc7c73e

Browse files
committed
git-shell: accept "git foo" form
This is a backport of 0a47dc1 to 'maint' to be included in 1.5.6.2 so that older server side can accept dashless form of request when clients are updated. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5070b49 commit bc7c73e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

shell.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ static int do_generic_cmd(const char *me, char *arg)
77
{
88
const char *my_argv[4];
99

10+
setup_path(NULL);
1011
if (!arg || !(arg = sq_dequote(arg)))
1112
die("bad argument");
1213
if (prefixcmp(me, "git-"))
@@ -29,7 +30,6 @@ static int do_cvs_cmd(const char *me, char *arg)
2930
die("git-cvsserver only handles server: %s", arg);
3031

3132
setup_path(NULL);
32-
3333
return execv_git_cmd(cvsserver_argv);
3434
}
3535

@@ -49,15 +49,24 @@ int main(int argc, char **argv)
4949
char *prog;
5050
struct commands *cmd;
5151

52+
/*
53+
* Special hack to pretend to be a CVS server
54+
*/
5255
if (argc == 2 && !strcmp(argv[1], "cvs server"))
5356
argv--;
54-
/* We want to see "-c cmd args", and nothing else */
57+
58+
/*
59+
* We do not accept anything but "-c" followed by "cmd arg",
60+
* where "cmd" is a very limited subset of git commands.
61+
*/
5562
else if (argc != 3 || strcmp(argv[1], "-c"))
5663
die("What do you think I am? A shell?");
5764

5865
prog = argv[2];
59-
argv += 2;
60-
argc -= 2;
66+
if (!strncmp(prog, "git", 3) && isspace(prog[3]))
67+
/* Accept "git foo" as if the caller said "git-foo". */
68+
prog[3] = '-';
69+
6170
for (cmd = cmd_list ; cmd->name ; cmd++) {
6271
int len = strlen(cmd->name);
6372
char *arg;

0 commit comments

Comments
 (0)