diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-21 00:10:25 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-21 00:10:25 +0400 |
commit | 7a3b4e3bd20989858341e42850bbc122887bdd73 (patch) | |
tree | 23a38660ee76ead795fdda5d43463b5f63715c7e | |
parent | cb682f8cfe63ecd0da08a526f404d295e51e3ab1 (diff) | |
parent | e3fa568cb397a78a56716137c826f21f5e0b0a77 (diff) |
Merge branch 'jc/revision-dash-count-parsing'
"git log -2master" is a common typo that shows two commits starting
from whichever random branch that is not 'master' that happens to
be checked out currently.
* jc/revision-dash-count-parsing:
revision: parse "git log -<count>" more carefully
-rw-r--r-- | revision.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/revision.c b/revision.c index 3818b4628d..8351e794df 100644 --- a/revision.c +++ b/revision.c @@ -1649,8 +1649,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->skip_count = atoi(optarg); return argcount; } else if ((*arg == '-') && isdigit(arg[1])) { - /* accept -<digit>, like traditional "head" */ - revs->max_count = atoi(arg + 1); + /* accept -<digit>, like traditional "head" */ + if (strtol_i(arg + 1, 10, &revs->max_count) < 0 || + revs->max_count < 0) + die("'%s': not a non-negative integer", arg + 1); revs->no_walk = 0; } else if (!strcmp(arg, "-n")) { if (argc <= 1) |