Skip to content

Commit ca64d06

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c9d8f0a commit ca64d06

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Documentation/git-check-attr.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ OPTIONS
3333

3434
\--::
3535
Interpret all preceding arguments as attributes and all following
36-
arguments as path names. If not supplied, only the first argument will
37-
be treated as an attribute.
36+
arguments as path names.
37+
38+
If none of `--stdin`, `--all`, or `--` is used, the first argument
39+
will be treated as an attribute and the rest of the arguments as
40+
pathnames.
3841

3942
OUTPUT
4043
------

builtin/check-attr.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,18 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
111111
} else if (doubledash == 0) {
112112
error_with_usage("No attribute specified");
113113
} else if (doubledash < 0) {
114-
/*
115-
* There is no double dash; treat the first
116-
* argument as an attribute.
117-
*/
118114
if (!argc)
119115
error_with_usage("No attribute specified");
120116

121-
cnt = 1;
122-
filei = 1;
117+
if (stdin_paths) {
118+
/* Treat all arguments as attribute names. */
119+
cnt = argc;
120+
filei = argc;
121+
} else {
122+
/* Treat exactly one argument as an attribute name. */
123+
cnt = 1;
124+
filei = 1;
125+
}
123126
} else {
124127
cnt = doubledash;
125128
filei = doubledash + 1;

t/t0003-attributes.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ test_expect_success 'command line checks' '
7070
echo "f" | test_must_fail git check-attr --stdin &&
7171
echo "f" | test_must_fail git check-attr --stdin -- f &&
7272
echo "f" | test_must_fail git check-attr --stdin test -- f &&
73-
echo "f" | test_must_fail git check-attr --stdin test f &&
7473
test_must_fail git check-attr "" -- f
7574
7675
'

0 commit comments

Comments
 (0)