Óscar Fuentes <ofv@xxxxxxxxxx> writes: > when [--max-count is] used with -S as in > > git log -Sfoo --max-count=N > > it acts as "inspect only the N first commits", i.e. if `foo' is not > present on any of the first N commits no output is shown. I'd call this a bug. The following patch seems to fix it, but I'm not terribly happy with the way it works. Any better idea? >From 3b962e004790c36c426efff64ad34043045e4aca Mon Sep 17 00:00:00 2001 From: Matthieu Moy <Matthieu.Moy@xxxxxxx> Date: Mon, 7 Mar 2011 13:41:05 +0100 Subject: [PATCH] log: fix --max-count when used together with -S or -G --max-count is implemented by counting revisions in get_revision(), but the -S and -G take effect later (after running diff), hence, --max-count=10 -Sfoo meant "examine the 10 first revisions, and out of them, show only those changing the occurences of foo", not "show 10 revisions changing the occurences of foo". In case the commit isn't actually shown, cancel the decrement of max_count. --- builtin/log.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index f5ed690..b83900b 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -263,7 +263,12 @@ static int cmd_log_walk(struct rev_info *rev) * retain that state information if replacing rev->diffopt in this loop */ while ((commit = get_revision(rev)) != NULL) { - log_tree_commit(rev, commit); + if (!log_tree_commit(rev, commit)) + /* + * We decremented max_count in get_revision, + * but we didn't actually show the commit. + */ + rev->max_count++; if (!rev->reflog_info) { /* we allow cycles in reflog ancestry */ free(commit->buffer); -- 1.7.4.1.176.g6b069.dirty -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html