Skip to content

Commit

Permalink
git-check-attr: Fix command-line handling to match docs
Browse files Browse the repository at this point in the history
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 <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
mhagger authored and gitster committed Aug 4, 2011
1 parent c9d8f0a commit ca64d06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Documentation/git-check-attr.txt
Expand Up @@ -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
------
Expand Down
15 changes: 9 additions & 6 deletions builtin/check-attr.c
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion t/t0003-attributes.sh
Expand Up @@ -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
'
Expand Down

0 comments on commit ca64d06

Please sign in to comment.