From: Miklos Vajna <vmiklos@frugalware.org>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Cc: git@vger.kernel.org
Subject: [PATCH] builtin-archive: insert --format before double dash if necessary.
Date: Thu, 10 Dec 2009 23:20:05 +0100 [thread overview]
Message-ID: <20091210222005.GP4114@genesis.frugalware.org> (raw)
In-Reply-To: <20091210212636.GA27722@Knoppix>
Reported-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
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
prev parent reply other threads:[~2009-12-10 22:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 21:26 [BUG] git archive formats and dashdash Ilari Liusvaara
2009-12-10 22:05 ` Junio C Hamano
2009-12-10 22:22 ` Miklos Vajna
2009-12-10 22:42 ` Junio C Hamano
2009-12-10 23:27 ` [PATCH] Fix archive format with -- on the command line Junio C Hamano
2009-12-10 23:31 ` Junio C Hamano
2009-12-12 15:00 ` René Scharfe
2009-12-30 3:13 ` Nanako Shiraishi
2009-12-30 8:11 ` Junio C Hamano
2009-12-10 22:25 ` [BUG] git archive formats and dashdash Ilari Liusvaara
2009-12-10 22:20 ` Miklos Vajna [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091210222005.GP4114@genesis.frugalware.org \
--to=vmiklos@frugalware.org \
--cc=git@vger.kernel.org \
--cc=ilari.liusvaara@elisanet.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox