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

1 messages from 2025-05-28 to 2025-05-28. Participants: lidongyan.
Thread: https://gitlist.dev/t/63540

## lidongyan, 2025-05-28 16:36

Subject: [RFC] revision.c: traverse to many revisions to find boundary
Message-ID: <3378F2BB-B2FB-4E07-9C02-A57D43D1A89C@smail.nju.edu.cn>
URL: https://gitlist.dev/e/3378F2BB-B2FB-4E07-9C02-A57D43D1A89C%40smail.nju.edu.cn

```
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)
```
