Skip to content

Commit 91043fc

Browse files
committed
Merge branch 'jc/revision-dash-count-parsing' into maint
"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
2 parents 81bd9b1 + e3fa568 commit 91043fc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

revision.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,8 +1648,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
16481648
revs->skip_count = atoi(optarg);
16491649
return argcount;
16501650
} else if ((*arg == '-') && isdigit(arg[1])) {
1651-
/* accept -<digit>, like traditional "head" */
1652-
revs->max_count = atoi(arg + 1);
1651+
/* accept -<digit>, like traditional "head" */
1652+
if (strtol_i(arg + 1, 10, &revs->max_count) < 0 ||
1653+
revs->max_count < 0)
1654+
die("'%s': not a non-negative integer", arg + 1);
16531655
revs->no_walk = 0;
16541656
} else if (!strcmp(arg, "-n")) {
16551657
if (argc <= 1)

0 commit comments

Comments
 (0)