threads / rfc / 63540

[RFC] revision.c: traverse to many revisions to find boundary

Subject: [RFC] revision.c: traverse to many revisions to find boundary

## tl;dr

One message between May 28, 2025 and May 28, 2025.

replies: 0people: 1as markdown or json

lidongyan· May 28, 2025, 16:36 UTC · lore
In revisions.c:get_revision_internal(), when the caller wants to
retrieve all boundary commits, this function identifies the parents
of the last commits emitted by get_revision_1() as boundary commits.
However, if get_revision_1() encounters an UNINTERESTING commit,
it continues to recursively traverse the parents of that commit. 
But only the earliest UNINTERESTING commits are eventually marked
 as boundary.

This raises the question: when revs->boundary is true, do we really need to continue traversing after encountering an UNINTERESTING commit? Perhaps we could optimize this by stopping the traversal earlier—for example, by doing something like this:

diff --git a/revision.c b/revision.c
index 2c36a9c179..0d99c22913 100644
--- a/revision.c
+++ b/revision.c
@@ -1176,6 +1176,8 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
 			if (p->object.flags & SEEN)
 				continue;
 			p->object.flags |= (SEEN | NOT_USER_GIVEN);
+			if (revs->boundary)
+				break;
 			if (list)
 				commit_list_insert_by_date(p, list);
 			if (queue)

← back to recent threads