git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/8] odb: resolve relative alternative paths when parsing

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 9, 2025, 08:04 UTC
Message-ID
<aTfYBGr-0SIDinYF@pks.im>
In-Reply-To
<kz2eftlrmaxpxjybhjwqlewy3dx44sdznimzs6reoqtev4qtox@hl3s2gxz3sk2>
On Mon, Dec 08, 2025 at 08:09:30PM -0600, Justin Tobler wrote:
Show 10 quoted lines
> On 25/12/08 09:04AM, Patrick Steinhardt wrote:
> > Parsing alternates and resolving potential relative paths is currently
> > handled in two separate steps. This has the effect that the logic to
> > retrieve alternates is not entirely self-contained. We want it to be
> > just that though so that we can eventually move the logic to list
> > alternates into the `struct odb_source`.
> 
> Naive question: is the intent here to eventually move alternate ODB
> sources under the primary ODB source? Or just to record the alternate
> dir info in the ODB source?

Not only the primary ODB source, but into ODB sources in general as alternates are recursive by nature.

The problem I am trying to solve is that ODB sources may not even have a filesystem-local directory, but the way we use alternates recursively very much assumes they do. I don't want to treat "files" sources specially though and only recursively add their alternates. Instead, I want to move the logic of enumerating alternates into the source so that every source can have a different way of enumerating them that may or may not use the filesystem.

Show 17 quoted lines
> > Move the logic to resolve relative alternative paths into
> > `parse_alternates()`. Besides bringing us a step closer towards the
> > above goal, it also neatly separates concerns of generating the list of
> > alternatives and linking them into the object database.
> > 
> > Note that we ignore any errors when the relative path cannot be
> > resolved. This isn't really a change in behaviour though: if the path
> > cannot be resolved to a directory then `alt_odb_usable()` still knows to
> > bail out.
> > 
> > While at it, rename the function to `odb_add_source()` to more clearly
> > indicate what its intent is and to align it with modern terminology.
> 
> Alternates are indeed just additional ODB sources appended to the
> sources list. IIUC though, doesn't this function only add alternate
> sources? If so, maybe it would be better to use
> `odb_add_alternate_source()`?

Hm, yeah, I think you're right. We still have the recursive nature at the end of this series, so let's call it accordingly.

Patrick
Previous: Justin ToblerNext: Justin Tobler
Message 6 of 41 in “Refactor handling of alternates to work via sources”
  1. 0/8 Refactor handling of alternates to work via sourcesPatrick Steinhardt, Dec 8, 2025
  2. 1/8 odb: refactor parsing of alternates to be self-containedPatrick Steinhardt, Dec 8, 2025
  3. Justin ToblerDec 8, 2025
  4. 2/8 odb: resolve relative alternative paths when parsingPatrick Steinhardt, Dec 8, 2025
  5. Justin ToblerDec 9, 2025
  6. Patrick SteinhardtDec 9, 2025
  7. Justin ToblerDec 9, 2025
  8. Patrick SteinhardtDec 10, 2025
  9. 3/8 odb: move computation of normalized objdir into `alt_odb_usable()`Patrick Steinhardt, Dec 8, 2025
  10. Justin ToblerDec 9, 2025
  11. Patrick SteinhardtDec 9, 2025
  12. 4/8 odb: adapt `odb_add_to_alternates_file()` to call `odb_add_source()`Patrick Steinhardt, Dec 8, 2025
  13. 5/8 odb: remove mutual recursion when parsing alternatesPatrick Steinhardt, Dec 8, 2025
  14. Justin ToblerDec 9, 2025
  15. 6/8 odb: drop forward declaration of `read_info_alternates()`Patrick Steinhardt, Dec 8, 2025
  16. 7/8 odb: read alternates via sourcesPatrick Steinhardt, Dec 8, 2025
  17. Justin ToblerDec 9, 2025
  18. Patrick SteinhardtDec 10, 2025
  19. 8/8 odb: write alternates via sourcesPatrick Steinhardt, Dec 8, 2025
  20. 0/8 Refactor handling of alternates to work via sourcesPatrick Steinhardt, Dec 10, 2025
  21. 1/8 odb: refactor parsing of alternates to be self-containedPatrick Steinhardt, Dec 10, 2025
  22. 2/8 odb: resolve relative alternative paths when parsingPatrick Steinhardt, Dec 10, 2025
  23. 3/8 odb: move computation of normalized objdir into `alt_odb_usable()`Patrick Steinhardt, Dec 10, 2025
  24. 4/8 odb: adapt `odb_add_to_alternates_file()` to call `odb_add_source()`Patrick Steinhardt, Dec 10, 2025
  25. SZEDER GáborDec 11, 2025
  26. Patrick SteinhardtDec 11, 2025
  27. 5/8 odb: remove mutual recursion when parsing alternatesPatrick Steinhardt, Dec 10, 2025
  28. 6/8 odb: drop forward declaration of `read_info_alternates()`Patrick Steinhardt, Dec 10, 2025
  29. 7/8 odb: read alternates via sourcesPatrick Steinhardt, Dec 10, 2025
  30. 8/8 odb: write alternates via sourcesPatrick Steinhardt, Dec 10, 2025
  31. Justin ToblerDec 10, 2025
  32. Patrick SteinhardtDec 11, 2025
  33. 0/8 Refactor handling of alternates to work via sourcesPatrick Steinhardt, Dec 11, 2025
  34. 1/8 odb: refactor parsing of alternates to be self-containedPatrick Steinhardt, Dec 11, 2025
  35. 2/8 odb: resolve relative alternative paths when parsingPatrick Steinhardt, Dec 11, 2025
  36. 3/8 odb: move computation of normalized objdir into `alt_odb_usable()`Patrick Steinhardt, Dec 11, 2025
  37. 4/8 odb: stop splitting alternate in `odb_add_to_alternates_file()`Patrick Steinhardt, Dec 11, 2025
  38. 5/8 odb: remove mutual recursion when parsing alternatesPatrick Steinhardt, Dec 11, 2025
  39. 6/8 odb: drop forward declaration of `read_info_alternates()`Patrick Steinhardt, Dec 11, 2025
  40. 7/8 odb: read alternates via sourcesPatrick Steinhardt, Dec 11, 2025
  41. 8/8 odb: write alternates via sourcesPatrick Steinhardt, Dec 11, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.