Skip to content

Commit d6b6cd1

Browse files
committed
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 <[email protected]>
1 parent 564d025 commit d6b6cd1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ static int parse_archive_args(int argc, const char **argv,
685685
base = "";
686686

687687
if (list) {
688+
if (argc)
689+
die(_("extra command line parameter '%s'"), *argv);
688690
for (i = 0; i < nr_archivers; i++)
689691
if (!is_remote || archivers[i]->flags & ARCHIVER_REMOTE)
690692
printf("%s\n", archivers[i]->name);

t/t5000-tar-tree.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ test_expect_success 'setup' '
124124
EOF
125125
'
126126

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+
127137
test_expect_success 'populate workdir' '
128138
mkdir a &&
129139
echo simple textfile >a/a &&

0 commit comments

Comments
 (0)