Search repositories with / on the host index

The finder answers "/" on every page that addresses a tree, but not on
the host index -- which is where readers arrive, and which is itself a
listing, of repositories rather than files. A keystroke that works
nearly everywhere and then silently does nothing never becomes muscle
memory.

Render the same palette there, over repository names. The page already
contains every repository it lists, so the finder reads them out of the
document instead of asking for the same names again: a host index
response names no revision and is therefore served no-store, so a
second request would be made on every page load and cached after none
of them. Reading the page also makes the finder's answers agree with it
by construction -- nothing can be missing from the finder that the
reader can already see.

The worker gains a load variant taking a list rather than a URL, and
sorts it. That is not cosmetic: two of its lookups are binary searches
over a byte-ordered index. indexOfPath is one, so an unsorted list
silently fails to find names that are present -- 2,828 of 2,838 on a
real host index. The literal-prefix channel is the other, so an
unsorted list would leave a typed namespace unpromoted, which on a host
index is the common case: readers type "platform/frameworks", not a
repository's last segment. The directory-run compression additionally
assumes sorted input for its speed. A git tree listing arrives sorted;
a list scraped from a page cannot be assumed to be.

Repository results are never warmed. Warming is only worth doing
because file links are SHA-pinned and therefore cacheable; a repository
index page names no revision, so a speculative fetch of one would be
discarded and the request wasted.

Descriptions are shown beside the name, as the page shows them, because
repository names alone are often not enough to choose between.

Verified against a host index of 2,838 real repository names. Engine:
every name is found by typing it in full, none is absent from a search
for its own last segment, all 2,838 are located by indexOfPath, a
shuffled list yields an identical index, and skipping the sort
demonstrably breaks it. Browser: the index is built with zero network
requests, rows link where the page links, nothing is warmed, Enter
opens the repository, and returning offers it again. Keystroke to
repaint on that index is 3.9 ms median, 6.0 ms worst.

Repository search sits inside the gitiles.fileSearch guard, so the one
switch covers both listings; FileSearchTest and Documentation/config.md
reflect that.

Three unit tests cover the new load path: that a supplied listing is
used without a fetch, that it is sorted whatever order it arrives in,
and that the sort is by UTF-8 bytes rather than UTF-16 code units. The
last one matters above the basic plane, where the two orders disagree
-- Array#sort would put U+10000 before U+FFFD, the bytes run the other
way -- and it discriminates: replacing the sort entirely fails two
tests, replacing it with Array#sort fails exactly that one.

Eight more cover repository mode in the palette: that the listing is
read out of the page and nothing is fetched, that rows link where the
page links and carry the description, that repositories named after
Object.prototype properties survive with or without a description, that
Enter navigates and records the visit under the host index key, that an
index reached with or without a trailing slash keeps one history, that
no repository page is ever warmed, that an empty index hides the trigger
and offers no palette, and that the same repository listed twice is
offered once. Reverted fixes were each caught -- building the name or
description maps with an object literal instead of Object.create(null),
dropping the repository-mode return from schedulePrefetch, dropping the
duplicate skip, and keying history on the raw pathname. Unmutated, the
palette suite passes 43 of 43 and the worker suite 21 of 21.

Bug: 564986686
TAG=agy
CONV=0b3e4b30-d902-4587-8bb2-ce23109d6955
CONV=60d1bfdf-34a4-460e-85ab-0f251e052543
Change-Id: I82ec98521c722a6f316eed456e1894e5b7da98c7
11 files changed
tree: 50fcb3c71347e1936bb91ff3bc9d64dc3b3bd4e4
  1. .settings/
  2. Documentation/
  3. java/
  4. javatests/
  5. jstests/
  6. lib/
  7. modules/
  8. resources/
  9. tools/
  10. .bazelignore
  11. .bazelrc
  12. .bazelversion
  13. .gitignore
  14. .gitmodules
  15. .mailmap
  16. .zuul.yaml
  17. BUILD
  18. COPYING
  19. external_deps.lock.json
  20. fake_pom_deploy.xml
  21. MODULE.bazel
  22. MODULE.bazel.lock
  23. navbar.md
  24. README.md
  25. version.bzl
README.md

Gitiles - A simple JGit repository browser

Gitiles is a simple repository browser for Git repositories, built on JGit. Its guiding principle is simplicity: it has no formal access controls, no write access, no fancy Javascript, etc.

Gitiles automatically renders *.md Markdown files into HTML for simplified documentation. Refer to the Markdown documentation for details.

Configuration

Gitiles is configurable in a git-style configuration file named gitiles.config. Refer to the configuration documentation for details.

Bugs

Use gerrit's issue tracker to file bugs.

Contributing to Gitiles

Please refer to the Developer Guide.