git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Spang <spang@google.com>
To: git@vger.kernel.org
Cc: "Junio C. Hamano" <gitster@pobox.com>
Subject: [PATCH] Fix git rev-list --reverse --max-count=N
Date: Wed, 27 Jan 2010 15:03:20 -0500	[thread overview]
Message-ID: <1264622600-20981-1-git-send-email-spang@google.com> (raw)

Using --max-count with --reverse currently outputs the last N commits
in the final output rather than the first N commits. We want to
truncate the reversed list after the first few commits, rather than
truncating the initial list and reversing that.

Signed-off-by: Michael Spang <spang@google.com>
---
 revision.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/revision.c b/revision.c
index f54d43f..62135e0 100644
--- a/revision.c
+++ b/revision.c
@@ -1993,7 +1993,8 @@ static struct commit *get_revision_internal(struct rev_info *revs)
 		c = NULL;
 		break;
 	default:
-		revs->max_count--;
+		if (!revs->reverse)
+			revs->max_count--;
 	}
 
 	if (c)
@@ -2055,8 +2056,21 @@ struct commit *get_revision(struct rev_info *revs)
 		revs->reverse_output_stage = 1;
 	}
 
-	if (revs->reverse_output_stage)
-		return pop_commit(&revs->commits);
+	if (revs->reverse_output_stage) {
+		c = pop_commit(&revs->commits);
+
+		switch (revs->max_count) {
+		case -1:
+			break;
+		case 0:
+			c = NULL;
+			break;
+		default:
+			revs->max_count--;
+		}
+
+		return c;
+	}
 
 	c = get_revision_internal(revs);
 	if (c && revs->graph)
-- 
1.6.6

             reply	other threads:[~2010-01-27 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 20:03 Michael Spang [this message]
2010-01-27 22:09 ` [PATCH] Fix git rev-list --reverse --max-count=N Johannes Sixt
2010-01-27 22:17   ` Sverre Rabbelier
2010-01-27 22:21   ` Michael Spang
2010-01-27 22:28   ` Junio C Hamano
2010-01-27 22:51     ` Michael Spang

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=1264622600-20981-1-git-send-email-spang@google.com \
    --to=spang@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).