@matheusbsbs / matheus-bagliano / commits / 819b2b5824
Fork 0

archive: allow --exec and --remote without equal sign

Allow "--remote repo" and "--exec cmd" in addition to "--remote=repo" and "--exec=cmd" to make their usage consistent with parameters handled by parse_options(). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rene Scharfe committed Jul 25, 2008 at 12:41 UTC 819b2b58246a7927376930e266b4ef8b43096115
1 file changed +17 -3
builtin-archive.c
+17 -3
@@ -15,7 +15,7 @@ static int run_remote_archiver(const char *remote, int argc,
15 int fd[2], i, len, rv;
16 struct child_process *conn;
17 const char *exec = "git-upload-archive";
18 - int exec_at = 0;
18 + int exec_at = 0, exec_value_at = 0;
19
20 for (i = 1; i < argc; i++) {
21 const char *arg = argv[i];
@@ -24,7 +24,14 @@ static int run_remote_archiver(const char *remote, int argc,
24 die("multiple --exec specified");
25 exec = arg + 7;
26 exec_at = i;
27 - break;
27 + } else if (!strcmp(arg, "--exec")) {
28 + if (exec_at)
29 + die("multiple --exec specified");
30 + if (i + 1 >= argc)
31 + die("option --exec requires a value");
32 + exec = argv[i + 1];
33 + exec_at = i;
34 + exec_value_at = ++i;
35 }
36 }
37
@@ -32,7 +39,7 @@ static int run_remote_archiver(const char *remote, int argc,
39 conn = git_connect(fd, url, exec, 0);
40
41 for (i = 1; i < argc; i++) {
35 - if (i == exec_at)
42 + if (i == exec_at || i == exec_value_at)
43 continue;
44 packet_write(fd[1], "argument %s\n", argv[i]);
45 }
@@ -78,6 +85,13 @@ static const char *extract_remote_arg(int *ac, const char **av)
85 die("Multiple --remote specified");
86 remote = arg + 9;
87 continue;
88 + } else if (!strcmp(arg, "--remote")) {
89 + if (remote)
90 + die("Multiple --remote specified");
91 + if (++ix >= cnt)
92 + die("option --remote requires a value");
93 + remote = av[ix];
94 + continue;
95 }
96 if (arg[0] != '-')
97 no_more_options = 1;