Hi Mathieu, On Sat, 12 Dec 2020 at 09:42, Mathieu Othacehe <othac...@gnu.org> wrote:
>> 1. Loop with commit-parents as it is done for ’commit-closure’ in >> guix/git.scm. >> >> 2. Bind git_revwalk_* and use it instead. >> >> WDYT? >> >> Well, #1 is more straightforward but less efficient, IIUC. > > Running something like: > > --8<---------------cut here---------------start------------->8--- > (let loop ((commit (commit-lookup r (string->oid "cf53ea79d"))) > (res '())) > (let ((parents (commit-parents commit))) > (if (null? parents) > res > (loop (car parents) (cons (car parents) res))))) > --8<---------------cut here---------------end--------------->8--- > > takes 1.45s to go over 53391 commits. The "revwalk" API may be more > efficient but I would say that what's currently implemented could be a > fine starting point. It does not work for complex history where multiple branches are merged. For example, the snippet excludes one of the master or core-updates at the merge points; or I miss something. Therefore, the loop should explore the different branches at the merge points, keeping somehow a list of already visited commit, implementing bit of graph stuff, and all in all, it is git_revwalk_*, IIUC. I agree that looping with commit-parents is a good starting point. All the best, simon