Reported-by: Ilari Liusvaara <ilari.liusvaara@xxxxxxxxxxx> Signed-off-by: Miklos Vajna <vmiklos@xxxxxxxxxxxxxx> --- What about this fix? builtin-archive.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/builtin-archive.c b/builtin-archive.c index 12351e9..ffbc9b0 100644 --- a/builtin-archive.c +++ b/builtin-archive.c @@ -104,14 +104,35 @@ int cmd_archive(int argc, const char **argv, const char *prefix) } if (format) { + int i, found = 0; + const char *ptr = NULL; + 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[]. + * + * First check if we have to insert the argument before + * two dashes. */ - argv[argc++] = fmt_opt; + for (i = 0; i < argc; i++) { + if (found) { + const char *tmp = argv[i]; + argv[i] = ptr; + ptr = tmp; + } else if (!strcmp(argv[i], "--")) { + found = 1; + ptr = argv[i]; + argv[i] = fmt_opt; + argc++; + } + } + + /* No double dash? Then just append it to the end of the list. */ + if (!found) + argv[argc++] = fmt_opt; argv[argc] = NULL; } -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html