[PATCH 05/14] handle_revision_opt(): use convert_i() when handling "-<digit>"
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Mar 17, 2015, 16:00 UTC
- Message-ID
- <1426608016-2978-6-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1426608016-2978-1-git-send-email-mhagger@alum.mit.edu>
This tightens up the parsing a bit:
* Leading whitespace is no longer allowed * '+' and '-' are no longer allowed
It also removes the need to check separately that max_count is non-negative.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> --- revision.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c index 25838fc..4908e66 100644 --- a/revision.c +++ b/revision.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "numparse.h" #include "tag.h" #include "blob.h" #include "tree.h" @@ -1709,8 +1710,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg return argcount; } else if ((*arg == '-') && isdigit(arg[1])) { /* accept -<digit>, like traditional "head" */ - if (strtol_i(arg + 1, 10, &revs->max_count) < 0 || - revs->max_count < 0) + if (convert_i(arg + 1, 10, &revs->max_count)) die("'%s': not a non-negative integer", arg + 1); revs->no_walk = 0; } else if (!strcmp(arg, "-n")) {
-- 2.1.4