summaryrefslogtreecommitdiff
path: root/builtin/check-attr.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2011-08-04 04:36:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-08-04 22:53:19 (GMT)
commit72541040c3ed00084344de5bf75cbc5a514504bb (patch)
tree5fe12a87a64c4e67360533da1ebf6d4ee400e703 /builtin/check-attr.c
parent27937447efdf2b50e6294e94bde22f07c526b2de (diff)
downloadgit-72541040c3ed00084344de5bf75cbc5a514504bb.zip
git-72541040c3ed00084344de5bf75cbc5a514504bb.tar.gz
git-72541040c3ed00084344de5bf75cbc5a514504bb.tar.bz2
git-check-attr: Process command-line args more systematically
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/check-attr.c')
-rw-r--r--builtin/check-attr.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index de3fef7..e9b827f 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -81,8 +81,6 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, check_attr_options,
check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
- if (!argc)
- usage_with_options(check_attr_usage, check_attr_options);
if (read_cache() < 0) {
die("invalid cache");
@@ -94,8 +92,17 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
doubledash = i;
}
- /* If there is no double dash, we handle only one attribute */
- if (doubledash < 0) {
+ /* Check attribute argument(s): */
+ 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;
} else {
@@ -103,9 +110,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
filei = doubledash + 1;
}
- if (cnt <= 0)
- error_with_usage("No attribute specified");
-
+ /* Check file argument(s): */
if (stdin_paths && filei < argc)
error_with_usage("Can't specify files with --stdin");