]> git.ipfire.org Git - thirdparty/git.git/commitdiff
archive: "--list" does not take further options
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 Dec 2023 18:13:58 +0000 (10:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Dec 2023 18:33:09 +0000 (10:33 -0800)
"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>
archive.c
t/t5000-tar-tree.sh

index ca11db185b15a73dd31b239d91a609071faa9a2a..8da820d1ce0d5ab30a8de592008ba5675d8c8935 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -685,6 +685,8 @@ static int parse_archive_args(int argc, const char **argv,
                base = "";
 
        if (list) {
+               if (argc)
+                       die(_("extra command line parameter '%s'"), *argv);
                for (i = 0; i < nr_archivers; i++)
                        if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)
                                printf("%s\n", archivers[i]->name);
index 4b4c3315d885f02fdcf2be65885ea9107f65b86d..72b8d0ff02e34be0606747c850b0815be31196d4 100755 (executable)
@@ -124,6 +124,16 @@ test_expect_success 'setup' '
        EOF
 '
 
+test_expect_success '--list notices extra parameters' '
+       test_must_fail git archive --list blah &&
+       test_must_fail git archive --remote=. --list blah
+'
+
+test_expect_success 'end-of-options is correctly eaten' '
+       git archive --list --end-of-options &&
+       git archive --remote=. --list --end-of-options
+'
+
 test_expect_success 'populate workdir' '
        mkdir a &&
        echo simple textfile >a/a &&