Skip to content

Commit 7a3b4e3

Browse files
committed
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
2 parents cb682f8 + e3fa568 commit 7a3b4e3

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
@@ -1649,8 +1649,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
16491649
revs->skip_count = atoi(optarg);
16501650
return argcount;
16511651
} else if ((*arg == '-') && isdigit(arg[1])) {
1652-
/* accept -<digit>, like traditional "head" */
1653-
revs->max_count = atoi(arg + 1);
1652+
/* accept -<digit>, like traditional "head" */
1653+
if (strtol_i(arg + 1, 10, &revs->max_count) < 0 ||
1654+
revs->max_count < 0)
1655+
die("'%s': not a non-negative integer", arg + 1);
16541656
revs->no_walk = 0;
16551657
} else if (!strcmp(arg, "-n")) {
16561658
if (argc <= 1)

0 commit comments

Comments
 (0)