git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What's in git.git

From
Linus Torvalds <torvalds@osdl.org>
Date
Mar 5, 2006, 17:53 UTC
Message-ID
<Pine.LNX.4.64.0603050946280.13139@g5.osdl.org>
In-Reply-To
<7vfylxigxc.fsf@assigned-by-dhcp.cox.net>
On Sat, 4 Mar 2006, Junio C Hamano wrote:
Show 9 quoted lines
> 
> At this point commit is revs->commits->item.  It cannot be
> UNINTERESTING because you make it sure with !revs->limited and
> friends, but I wonder if it can be SHOWN already for some
> reason, in which case returning it is wrong.
> 
> Unlike the earlier special case in rev-list, this special case
> kicks in for the last iteration of repeated calls to
> get_revision() (e.g. third iteration of "rev-list -3")...

Good point. Yes, it needs to check that it's not SHOWN. Might as well check against interesting too. Maybe something like this instead?

		Linus
---
diff --git a/revision.c b/revision.c
index a3df810..2a33637 100644
--- a/revision.c
+++ b/revision.c
@@ -684,13 +684,11 @@ static void rewrite_parents(struct commi
 struct commit *get_revision(struct rev_info *revs)
 {
 	struct commit_list *list = revs->commits;
-	struct commit *commit;
 
 	if (!list)
 		return NULL;
 
 	/* Check the max_count ... */
-	commit = list->item;
 	switch (revs->max_count) {
 	case -1:
 		break;
@@ -701,22 +699,28 @@ struct commit *get_revision(struct rev_i
 	}
 
 	do {
-		commit = pop_most_recent_commit(&revs->commits, SEEN);
+		struct commit *commit = revs->commits->item;
+
 		if (commit->object.flags & (UNINTERESTING|SHOWN))
-			continue;
+			goto next;
 		if (revs->min_age != -1 && (commit->date > revs->min_age))
-			continue;
+			goto next;
 		if (revs->max_age != -1 && (commit->date < revs->max_age))
 			return NULL;
 		if (revs->no_merges && commit->parents && commit->parents->next)
-			continue;
+			goto next;
 		if (revs->paths && revs->dense) {
 			if (!(commit->object.flags & TREECHANGE))
-				continue;
+				goto next;
 			rewrite_parents(commit);
 		}
+		/* More to go? */
+		if (revs->max_count)
+			pop_most_recent_commit(&revs->commits, SEEN);
 		commit->object.flags |= SHOWN;
 		return commit;
+next:
+		pop_most_recent_commit(&revs->commits, SEEN);
 	} while (revs->commits);
 	return NULL;
 }
Previous: Junio C HamanoNext: Linus Torvalds
Message 5 of 14 in “What's in git.git”
  1. Junio C HamanoMar 5, 2006
  2. Junio C HamanoMar 5, 2006
  3. Linus TorvaldsMar 5, 2006
  4. Junio C HamanoMar 5, 2006
  5. Linus TorvaldsMar 5, 2006
  6. Linus TorvaldsMar 5, 2006
  7. Junio C HamanoMar 5, 2006
  8. Linus TorvaldsMar 5, 2006
  9. Junio C HamanoMar 5, 2006
  10. Martin LanghoffMar 5, 2006
  11. Alexandre JulliardMar 5, 2006
  12. Martin LanghoffMar 5, 2006
  13. Alexandre JulliardMar 5, 2006
  14. Junio C HamanoMar 5, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.