From: Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>
To: "Óscar Fuentes" <ofv@wanadoo•es>
Cc: git@vger•kernel.org
Subject: [RFC/PATCH] Re: BUG? git log -Sfoo --max-count=N
Date: Mon, 07 Mar 2011 13:46:52 +0100 [thread overview]
Message-ID: <vpqpqq3qern.fsf@bauges.imag.fr> (raw)
In-Reply-To: <87hbbgvske.fsf@wanadoo.es> ("Óscar Fuentes"'s message of "Sun, 06 Mar 2011 22:37:37 +0100")
Óscar Fuentes <ofv@wanadoo•es> 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@imag•fr>
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/
next prev parent reply other threads:[~2011-03-07 12:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-06 21:37 BUG? git log -Sfoo --max-count=N Óscar Fuentes
2011-03-07 12:46 ` Matthieu Moy [this message]
2011-03-08 19:22 ` [RFC/PATCH] " Junio C Hamano
2011-03-09 20:52 ` [PATCH] log: fix --max-count when used together with -S or -G Matthieu Moy
2011-03-09 21:38 ` Jeff King
2011-03-09 21:49 ` Matthieu Moy
2011-03-09 22:27 ` Junio C Hamano
2011-03-10 22:39 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpqpqq3qern.fsf@bauges.imag.fr \
--to=matthieu.moy@grenoble-inp$(echo .)fr \
--cc=git@vger$(echo .)kernel.org \
--cc=ofv@wanadoo$(echo .)es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox