Skip to content

add resort() function to sort event dependencies first

Richard Hansen requested to merge rhansen/reposurgeon:topological-resort into master

Add a new Repository.resort() function that sorts the repository's events to ensure that objects referenced by other objects appear first (e.g., blobs appear before the commits they're in, ancestor commits appear before their descendants). The topological sort is stable to prevent unnecessary churn.

Nothing directly calls this new function because there is no real need for it just yet. However:

  • A future change will allow the reparent command to completely rearrange commits, making it possible for ancestor commits to have a later index than their descendants.
  • Users can use the exec command to modify events in arbitrary ways.
  • If the add command's requirements were relaxed it could support referencing a blob that appears later in the event sequence.

In all of these cases, a call to resort() can repair the event order so that a valid output stream is produced.

Merge request reports