notes: check number of parameters to "git notes copy"
Otherwise we may segfault with too few parameters. Signed-off-by: Jeff King <peff@peff.net> Tested-by: Bert Wesarg <Bert.Wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
9eafa1201b
commit
bbb1b8a35a
@ -614,6 +614,10 @@ static int copy(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
error("too few parameters");
|
||||||
|
usage_with_options(git_notes_copy_usage, options);
|
||||||
|
}
|
||||||
if (2 < argc) {
|
if (2 < argc) {
|
||||||
error("too many parameters");
|
error("too many parameters");
|
||||||
usage_with_options(git_notes_copy_usage, options);
|
usage_with_options(git_notes_copy_usage, options);
|
||||||
|
@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
|
|||||||
git log -1 > output &&
|
git log -1 > output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git notes copy diagnoses too many or too few parameters' '
|
||||||
|
test_must_fail git notes copy &&
|
||||||
|
test_must_fail git notes copy one two three
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user