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

SHOWN means shown

From
Junio C Hamano <junkio@cox.net>
Date
Mar 6, 2007, 02:23 UTC
Message-ID
<7vzm6rt8hu.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<7v4pozuncr.fsf@assigned-by-dhcp.cox.net>

This moves the code to set SHOWN on the commit from get_revision_1() back to get_revision(), so that the bit means what it originally meant: this commit has been given back to the caller.

Also it fixes the --reverse breakage Dscho pointed out.
---
  Junio C Hamano <junkio@cox.net> writes:
  >> Is this really relevant in practice?
  >
  > Absolutely.  But I have further updates on this series.
  ... otherwise, "git-bundle create -3 A B" when B is A~3 would
  mistakenly say "Ah, B is SHOWN so include it".
 revision.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/revision.c b/revision.c
index 2d27ccf..35a1711 100644
--- a/revision.c
+++ b/revision.c
@@ -1227,7 +1227,6 @@ static struct commit *get_revision_1(struct rev_info *revs)
 			if (revs->parents)
 				rewrite_parents(revs, commit);
 		}
-		commit->object.flags |= SHOWN;
 		return commit;
 	} while (revs->commits);
 	return NULL;
@@ -1280,11 +1279,22 @@ struct commit *get_revision(struct rev_info *revs)
 	}
 
 	if (revs->reverse) {
+		int limit = -1;
+
+		if (0 <= revs->max_count) {
+			limit = revs->max_count;
+			if (0 < revs->skip_count)
+				limit += revs->skip_count;
+		}
 		l = NULL;
-		while ((c = get_revision_1(revs)))
+		while ((c = get_revision_1(revs))) {
 			commit_list_insert(c, &l);
+			if ((0 < limit) && !--limit)
+				break;
+		}
 		revs->commits = l;
 		revs->reverse = 0;
+		revs->max_count = -1;
 		c = NULL;
 	}
 
@@ -1298,8 +1308,6 @@ struct commit *get_revision(struct rev_info *revs)
 		c = get_revision_1(revs);
 		if (!c)
 			break;
-		/* Although we grabbed it, it is not shown. */
-		c->object.flags &= ~SHOWN;
 	}
 
 	/*
@@ -1310,16 +1318,18 @@ struct commit *get_revision(struct rev_info *revs)
 		break;
 	case 0:
 		/* Although we grabbed it, it is not shown. */
-		if (c)
-			c->object.flags &= ~SHOWN;
 		c = NULL;
 		break;
 	default:
 		revs->max_count--;
 	}
 
-	if (!revs->boundary)
+	if (c)
+		c->object.flags |= SHOWN;
+
+	if (!revs->boundary) {
 		return c;
+	}
 
 	if (!c) {
 		/*
@@ -1341,7 +1351,7 @@ struct commit *get_revision(struct rev_info *revs)
 	for (l = c->parents; l; l = l->next) {
 		struct object *p;
 		p = &(l->item->object);
-		if (p->flags & CHILD_SHOWN)
+		if (p->flags & (CHILD_SHOWN | SHOWN))
 			continue;
 		p->flags |= CHILD_SHOWN;
 		gc_boundary(&revs->boundary_commits);
Previous: Junio C HamanoNext: Johannes Schindelin
Message 19 of 26 in “[BUG] git-rev-list: --topo-order --boundary and --max-count”
  1. Santi BéjarMar 5, 2007
  2. Junio C HamanoMar 5, 2007
  3. Junio C HamanoMar 5, 2007
  4. Linus TorvaldsMar 5, 2007
  5. revision walker: Fix --boundary when limitedJohannes Schindelin, Mar 5, 2007
  6. Johannes SchindelinMar 5, 2007
  7. Linus TorvaldsMar 5, 2007
  8. Linus TorvaldsMar 5, 2007
  9. Junio C HamanoMar 5, 2007
  10. Johannes SchindelinMar 6, 2007
  11. Junio C HamanoMar 6, 2007
  12. Johannes SchindelinMar 6, 2007
  13. Junio C HamanoMar 6, 2007
  14. Johannes SchindelinMar 5, 2007
  15. Junio C HamanoMar 6, 2007
  16. 2/4 revision traversal: retire BOUNDARY_SHOWJunio C Hamano, Mar 6, 2007
  17. Johannes SchindelinMar 6, 2007
  18. Junio C HamanoMar 6, 2007
  19. SHOWN means shownJunio C Hamano, Mar 6, 2007
  20. Johannes SchindelinMar 6, 2007
  21. Junio C HamanoMar 6, 2007
  22. Johannes SchindelinMar 6, 2007
  23. 3/4 git-bundle: various fixupsJunio C Hamano, Mar 6, 2007
  24. Johannes SchindelinMar 6, 2007
  25. 4/4 git-bundle: --list-prereqsJunio C Hamano, Mar 6, 2007
  26. Junio C HamanoMar 5, 2007

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.