archive: "--list" does not take further options

"git archive --list blah" should notice an extra command line parameter that goes unused. Make it so. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 21, 2023 at 10:13 UTC d6b6cd139359097f565023f9481c9943989e4463
2 files changed +12
archive.c
+2
@@ -685,6 +685,8 @@ static int parse_archive_args(int argc, const char **argv,
685 base = "";
686
687 if (list) {
688 + if (argc)
689 + die(_("extra command line parameter '%s'"), *argv);
690 for (i = 0; i < nr_archivers; i++)
691 if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)
692 printf("%s\n", archivers[i]->name);
t/t5000-tar-tree.sh
+10
@@ -124,6 +124,16 @@ test_expect_success 'setup' '
124 EOF
125 '
126
127 +test_expect_success '--list notices extra parameters' '
128 + test_must_fail git archive --list blah &&
129 + test_must_fail git archive --remote=. --list blah
130 +'
131 +
132 +test_expect_success 'end-of-options is correctly eaten' '
133 + git archive --list --end-of-options &&
134 + git archive --remote=. --list --end-of-options
135 +'
136 +
137 test_expect_success 'populate workdir' '
138 mkdir a &&
139 echo simple textfile >a/a &&