Skip to content

Commit 1030536

Browse files
committed
Merge branch 'mm/maint-log-n-with-diff-filtering' into maint
* mm/maint-log-n-with-diff-filtering: log: fix --max-count when used together with -S or -G
2 parents c3d1a43 + 251df09 commit 1030536

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

builtin/log.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ static int cmd_log_walk(struct rev_info *rev)
263263
* retain that state information if replacing rev->diffopt in this loop
264264
*/
265265
while ((commit = get_revision(rev)) != NULL) {
266-
log_tree_commit(rev, commit);
266+
if (!log_tree_commit(rev, commit) &&
267+
rev->max_count >= 0)
268+
/*
269+
* We decremented max_count in get_revision,
270+
* but we didn't actually show the commit.
271+
*/
272+
rev->max_count++;
267273
if (!rev->reflog_info) {
268274
/* we allow cycles in reflog ancestry */
269275
free(commit->buffer);

t/t4013-diff-various.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ log -m -p master
210210
log -SF master
211211
log -S F master
212212
log -SF -p master
213+
log -SF master --max-count=0
214+
log -SF master --max-count=1
215+
log -SF master --max-count=2
213216
log -GF master
214217
log -GF -p master
215218
log -GF -p --pickaxe-all master
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git log -SF master --max-count=0
2+
$
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$ git log -SF master --max-count=1
2+
commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:02:00 2006 +0000
5+
6+
Third
7+
$
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$ git log -SF master --max-count=2
2+
commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:02:00 2006 +0000
5+
6+
Third
7+
$

0 commit comments

Comments
 (0)