commit: Add trees-first filesystem sorting

What does this MR do and why?

Contributes to gitlab#569650 (closed)

Problem

GitLab's public API needs tree entries grouped by type with lexical ordering within each group. Existing sort modes either interleave types or preserve Git traversal order within type groups.

  • Existing FILESYSTEM cannot provide this ordering because it sorts all entries in one lexicographical sequence by path, so trees, blobs, and submodules remain interleaved.

We need TREES_FIRST_FILESYSTEM to group entries by type first, then apply filesystem ordering within each group.

Solution

  • Add an additive TREES_FIRST_FILESYSTEM sort mode to GetTreeEntries.
  • Sort complete results by type rank and bytewise full path.
  • Cover recursive, non-recursive, path-token, and legacy OID pagination.

References

Unconventional sort order of directories in a p... (gitlab#569650 - closed)

How to set up and validate locally

  1. Run: TEST_PACKAGES=./internal/gitaly/service/commit TEST_OPTIONS="-count=1 -run=TestGetTreeEntries" make test

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports

Loading
Loading