Re: [BUG] git archive formats and dashdash

Subsystems: the rest

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [BUG] git archive formats and dashdash

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:53

Ilari Liusvaara [off-list ref] writes:
--format option of git archive stops working if -- is used:
Good catch.  Is this a regression between 1.6.5 and the current code?

 builtin-archive.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/builtin-archive.c b/builtin-archive.c
index 12351e9..8ef5ab3 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 "--" so we should make this
+		 * 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)

Re: [BUG] git archive formats and dashdash

From: Miklos Vajna <hidden>
Date: 2016-06-15 22:47:53

On Thu, Dec 10, 2009 at 02:05:39PM -0800, Junio C Hamano [off-list ref] wrote:
Good catch.  Is this a regression between 1.6.5 and the current code?
Ah, you version is much shorter. :)

I think it was introduced by 0f4b377c (git-archive: infer output format
from filename when unspecified, 2009-09-14), so it was introduced
before 1.6.5.

Re: [BUG] git archive formats and dashdash

From: Ilari Liusvaara <hidden>
Date: 2016-06-15 22:47:53

On Thu, Dec 10, 2009 at 02:05:39PM -0800, Junio C Hamano wrote:
Ilari Liusvaara [off-list ref] writes:
quoted
--format option of git archive stops working if -- is used:
Good catch.  Is this a regression between 1.6.5 and the current code?
Doesn't appear to be so:

Based on quick look at source, it seems that this is indeed regression,
and the commit which introduced it is:

commit 0f4b377c20fb7d93f8bfeec39efb2b9392d6aebc
Author: Dmitry Potapov [off-list ref]
Date:   Mon Sep 14 00:17:01 2009 +0400

Describe: v1.6.5-rc1-7-g0f4b377 / v1.6.5-rc2~34

-Ilari
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help