Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Order of branches in 'Get Included In' REST API response

68 views
Skip to first unread message

Piotr Szlązak

unread,
Apr 16, 2025, 1:55:30 AMApr 16
to Repo and Gerrit Discussion
Hello Experts,
Is order of branches in response of 'Get Included In' REST API call [1] strictly defined? I.e. the oldest branch in which the commit is included is always the last on the list?


Regards!
-- 
Piotr

Matthias Sohn

unread,
Apr 16, 2025, 4:13:45 AMApr 16
to Piotr Szlązak, Repo and Gerrit Discussion
The refs are sorted by their tip commit time, see
 
Regards!
-- 
Piotr

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/13c4f612-e2ff-4345-b4c2-001298e30cb3n%40googlegroups.com.

Piotr Szlązak

unread,
Apr 16, 2025, 7:18:11 AMApr 16
to Repo and Gerrit Discussion
On Wednesday, April 16, 2025 at 10:13:45 AM UTC+2 Matthias Sohn wrote:

Thanks Matthias for pointing me to right part of the code!
So this one will return them sorted according to tip commit time. But still we are not able to tell which branch is the oldest. Example:
- we have a commit in the master branch
- then branches devA and devB are created (in that order) with their unique commits
- devB branch is the most active branch, so tip of this branch is newer than tip of devA and master branches

So devB will be the the first returned branch.
 

But order is being changed for final response:
It will be lexicographical (alphabetical) order.

To have branches sorted by creation time it would be needed to find all branches in which the commit is included, then find first unique commit for every branch and finally sort branches by creation time of this unique commit.

Is my understanding correct?

Regards!
-- 
Piotr

Matthias Sohn

unread,
Apr 16, 2025, 9:45:12 AMApr 16
to Piotr Szlązak, Repo and Gerrit Discussion
On Wed, Apr 16, 2025 at 1:18 PM Piotr Szlązak <piotr....@gmail.com> wrote:
On Wednesday, April 16, 2025 at 10:13:45 AM UTC+2 Matthias Sohn wrote:

Thanks Matthias for pointing me to right part of the code!

The refs are sorted by their tip commit time, see

So this one will return them sorted according to tip commit time. But still we are not able to tell which branch is the oldest. Example:
- we have a commit in the master branch
- then branches devA and devB are created (in that order) with their unique commits
- devB branch is the most active branch, so tip of this branch is newer than tip of devA and master branches

So devB will be the the first returned branch.
 

But order is being changed for final response:
It will be lexicographical (alphabetical) order.

Yes, this is correct, the order by tip commit time is done to speedup RevWalk#getMergedInto and
at the end branches and tags are sorted lexicographically.
 
To have branches sorted by creation time it would be needed to find all branches in which the commit is included, then find first unique commit for every branch and finally sort branches by creation time of this unique commit.

Is my understanding correct?

I wouldn't know how to sort branches by creation time since git doesn't store when a ref was created.
It's just a named pointer to some git object, usually a commit or tag.
 
Regards!
-- 
Piotr

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages