Skip to content

Commit 819b2b5

Browse files
Rene Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f15f736 commit 819b2b5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

builtin-archive.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static int run_remote_archiver(const char *remote, int argc,
1515
int fd[2], i, len, rv;
1616
struct child_process *conn;
1717
const char *exec = "git-upload-archive";
18-
int exec_at = 0;
18+
int exec_at = 0, exec_value_at = 0;
1919

2020
for (i = 1; i < argc; i++) {
2121
const char *arg = argv[i];
@@ -24,15 +24,22 @@ static int run_remote_archiver(const char *remote, int argc,
2424
die("multiple --exec specified");
2525
exec = arg + 7;
2626
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;
2835
}
2936
}
3037

3138
url = xstrdup(remote);
3239
conn = git_connect(fd, url, exec, 0);
3340

3441
for (i = 1; i < argc; i++) {
35-
if (i == exec_at)
42+
if (i == exec_at || i == exec_value_at)
3643
continue;
3744
packet_write(fd[1], "argument %s\n", argv[i]);
3845
}
@@ -78,6 +85,13 @@ static const char *extract_remote_arg(int *ac, const char **av)
7885
die("Multiple --remote specified");
7986
remote = arg + 9;
8087
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;
8195
}
8296
if (arg[0] != '-')
8397
no_more_options = 1;

0 commit comments

Comments
 (0)