From: Michael Haggerty Date: Thu, 4 Aug 2011 04:36:32 +0000 (+0200) Subject: git-check-attr: Fix command-line handling to match docs X-Git-Tag: v1.7.7-rc0~23^2~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ca64d061e0ddf7fa1496a15c75eb5e730c4360e0;p=git.git git-check-attr: Fix command-line handling to match docs According to the git-check-attr synopsis, if the '--stdin' option is used then no pathnames are expected on the command line. Change the behavior to match this description; namely, if '--stdin' is used but not '--', then treat all command-line arguments as attribute names. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt index 798e5d5b4..1f7312a18 100644 --- a/Documentation/git-check-attr.txt +++ b/Documentation/git-check-attr.txt @@ -33,8 +33,11 @@ OPTIONS \--:: Interpret all preceding arguments as attributes and all following - arguments as path names. If not supplied, only the first argument will - be treated as an attribute. + arguments as path names. + +If none of `--stdin`, `--all`, or `--` is used, the first argument +will be treated as an attribute and the rest of the arguments as +pathnames. OUTPUT ------ diff --git a/builtin/check-attr.c b/builtin/check-attr.c index b0d2ebc3d..f20772ad6 100644 --- a/builtin/check-attr.c +++ b/builtin/check-attr.c @@ -111,15 +111,18 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix) } else if (doubledash == 0) { error_with_usage("No attribute specified"); } else if (doubledash < 0) { - /* - * There is no double dash; treat the first - * argument as an attribute. - */ if (!argc) error_with_usage("No attribute specified"); - cnt = 1; - filei = 1; + if (stdin_paths) { + /* Treat all arguments as attribute names. */ + cnt = argc; + filei = argc; + } else { + /* Treat exactly one argument as an attribute name. */ + cnt = 1; + filei = 1; + } } else { cnt = doubledash; filei = doubledash + 1; diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index a49f8a981..5acb2d5bb 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -70,7 +70,6 @@ test_expect_success 'command line checks' ' 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 test -- f && - echo "f" | test_must_fail git check-attr --stdin test f && test_must_fail git check-attr "" -- f '