Use FILESYSTEM sort for repository tree entries

What does this MR do and why?

Contributes to #569650

Problem

Directories in the repository file browser are sorted in an unconventional order. For example, Foo.A.Test appears before Foo.A, and Foo appears last. This is because Gitaly's GetTreeEntries RPC uses TREES_FIRST sort which relies on git's internal tree sort order (appending / to directory names), causing longer names to sort before shorter ones.

Solution

Switch from TREES_FIRST to TREES_FIRST_FILESYSTEM sort order when calling Gitaly's GetTreeEntries RPC. The TREES_FIRST_FILESYSTEM sort option (added in gitaly!9089 (merged)) keeps directories first and sorts entries within each group lexicographically by path using byte-order comparison, mirroring the behavior of ls. The change is gated behind the tree_entries_filesystem_sort feature flag (disabled by default).

References

Screenshots or screen recordings

Before After
Screenshot_2026-05-22_at_11.40.57 Screenshot_2026-05-22_at_11.42.58

How to set up and validate locally

  1. Enable the feature flag: Feature.enable(:tree_entries_filesystem_sort)
  2. Navigate to a repository that has directories with names like Foo, Foo.A, Foo.A.Test
  3. Verify directories are sorted as Foo → Foo.A → Foo.A.Test (shorter before longer)
  4. Disable the flag (Feature.disable(:tree_entries_filesystem_sort)) and verify the old order returns

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