diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-12-10 16:20:59 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-12-10 16:20:59 -0800 |
commit | 4cb51a65a478ff005630d8806d01cd76a8889faf (patch) | |
tree | cbf6a55e2d516ef719ccbead2ec030ce13386f42 /builtin-archive.c | |
parent | 80d93611c55fec171e0d9aba98db079952f9d7aa (diff) | |
parent | 9861b644e045b5ee0e16dea65b44419205090960 (diff) | |
download | git-4cb51a65a478ff005630d8806d01cd76a8889faf.tar.gz |
Sync with 1.6.5.6
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-archive.c')
-rw-r--r-- | builtin-archive.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/builtin-archive.c b/builtin-archive.c index 12351e9dd5..446d6bff30 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -106,13 +106,17 @@ int cmd_archive(int argc, const char **argv, const char *prefix) if (format) { sprintf(fmt_opt, "--format=%s", format); /* - * This is safe because either --format and/or --output must - * have been given on the original command line if we get to - * this point, and parse_options() must have eaten at least - * one argument, i.e. we have enough room to append to argv[]. + * We have enough room in argv[] to muck it in place, + * because either --format and/or --output must have + * been given on the original command line if we get + * to this point, and parse_options() must have eaten + * it, i.e. we can add back one element to the array. + * But argv[] may contain "--"; we should make it the + * first option. */ - argv[argc++] = fmt_opt; - argv[argc] = NULL; + memmove(argv + 2, argv + 1, sizeof(*argv) * argc); + argv[1] = fmt_opt; + argv[++argc] = NULL; } if (remote) |