зеркало из https://github.com/microsoft/git.git
git-check-attr: Error out if no pathnames are specified
If no pathnames are passed as command-line arguments and the --stdin option is not specified, fail with the error message "No file specified". Add tests of this behavior. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
72541040c3
Коммит
fdf6be8259
|
@ -111,8 +111,13 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check file argument(s): */
|
/* Check file argument(s): */
|
||||||
if (stdin_paths && filei < argc)
|
if (stdin_paths) {
|
||||||
error_with_usage("Can't specify files with --stdin");
|
if (filei < argc)
|
||||||
|
error_with_usage("Can't specify files with --stdin");
|
||||||
|
} else {
|
||||||
|
if (filei >= argc)
|
||||||
|
error_with_usage("No file specified");
|
||||||
|
}
|
||||||
|
|
||||||
check = xcalloc(cnt, sizeof(*check));
|
check = xcalloc(cnt, sizeof(*check));
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
|
|
|
@ -46,6 +46,8 @@ test_expect_success 'command line checks' '
|
||||||
|
|
||||||
test_must_fail git check-attr &&
|
test_must_fail git check-attr &&
|
||||||
test_must_fail git check-attr -- &&
|
test_must_fail git check-attr -- &&
|
||||||
|
test_must_fail git check-attr test &&
|
||||||
|
test_must_fail git check-attr test -- &&
|
||||||
test_must_fail git check-attr -- f &&
|
test_must_fail git check-attr -- f &&
|
||||||
echo "f" | test_must_fail git check-attr --stdin &&
|
echo "f" | test_must_fail git check-attr --stdin &&
|
||||||
echo "f" | test_must_fail git check-attr --stdin -- f &&
|
echo "f" | test_must_fail git check-attr --stdin -- f &&
|
||||||
|
|
Загрузка…
Ссылка в новой задаче