Re: [PATCH 05/14] handle_revision_opt(): use convert_i() when handling "-<digit>"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 19, 2015, 06:34 UTC
- Message-ID
- <xmqqwq2djy0l.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1426608016-2978-6-git-send-email-mhagger@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 7 quoted lines
> 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.
Hmmm, on the surface this sound nice, but I am not sure if it is a good idea. "git cmd-in-log-family -3 --max-count=-1" would have been a nice way to flip a max-count given earlier on the command line back to the default (unlimited) and we are removing it without giving any escape hatch?
Show 24 quoted lines
>
> 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);