8000 "Generic" repository layout by tiennou · Pull Request #5296 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

"Generic" repository layout #5296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tiennou
Copy link
Contributor
@tiennou tiennou commented Nov 5, 2019

This adds a low-level "layout" structure/subsystem, which inherits the current "filesystem resolution process" (a.k.a git_repository_item_path()), and most of the "names" git uses. This allows the rest of the code to ask about "where do I find the data for $item", and be less knowledgable about any filesystem involvement (example). The longterm goal is clearly to deprecate git_repository_new and provide more easily-customizable options at a lower level, but that's out of scope for now — I just want the repository-opening step to be less confusing, and I want more control over what's considered valid and/or overridable 😉.

This is actually a partial rebase of #4856, with a focus on refactoring/cleanups instead of feature-filling — mostly because IMHO there are low-level details that have completely conflicting semantics, and I can't manage to make sense of them when trying to preserve our own "rules" w.r.t to "opening from the environment". I don't know how much of it is in scope for #5291, hence I'm only drafting this 😉. Note that I don't intend to replace #4856 yet, since it's somehow closer to completion than this, but I'll either rebase later or polish up, fix and 🚢 if there's a need for it.

@tiennou
Copy link
Contributor Author
tiennou commented Nov 5, 2019

And, without further ado, here's my notes/questions about this undertaking :

  • This has some insights on the needs for a refactor.

The TL;DR is that, between the short-circuited codepaths of bare, env, gitlink, and the bare, normal, custom refdb/odb/config, new, and worktree/submodule repositories types, it's confusing.

  • This is still 🔴. It's likely more crazy filesystem testcases are needed to polish up the behavior — IIRC there's already an issue about a path not being absolute in some case.

  • I stared a hard time at the additions to the private items array.

I don't think "items" like HEAD, FETCH_HEAD, and friends belong in here : IMHO those should be part of the refdb layer, because it would benefit from "an automated write this ref with this data when you commit this transaction" support, which refdb already has. But right now there's no such support for "freeform storage" — our refdb is only interested in OIDs, symrefs, and reflogging, and all other uses usually go through the filesystem, bypassing any custom refdb backend black magic (there are accesses to .git/HEAD still).

Some others are less clear — I'm aware of "info/grafts" but it's along other files in "info", and the "*_MSG" ones are also kinda temporary ones… But there's still a transaction feel to them 🙄.

Thus, I've chosen to add git_repository_item_t entries, which are public. I'd like to know if that makes sense for all of them 😉.

@tiennou tiennou marked this pull request as ready for review November 5, 2019 11:11
@tiennou
Copy link
Contributor Author
tiennou commented Nov 5, 2019

Annnnd I've de-drafted it 🤣.

This introduces a string splitter to git_buf that works on static strings,
and uses it as part of a strarray helper to assist in wrangling
PATH_LIST-separated strings (a.k.a pathlists).
This changes the ceiling directories and ODB alternates lists, usually passed
via the environment, to use strarrays instead of string manipulation.
As the number of places that expect a actual .git directory to exist increases,
users of custom repository have started to encounter a varying amount of
"brokenness", depending on how custom their repository are.

As a first step to alleviate this, all used "names" are gathered in a new
header, the `git_repository_layout` struct consolidates the "file-system
resolution logic" already in place, and all users of direct file-system access
are changed to go through that system.
Fish out the existing layout-related functions out of repository.c, and move them under a project-wide name.
Now that we have a generic layout object, convert the few members in
`git_repository` to use a `git_repository_layout` instead, and require a layout
object at initialization.
@tiennou tiennou force-pushed the feature/repository-layout branch from 571e263 to a09dd3d Compare November 9, 2019 08:31
Base automatically changed from master to main January 7, 2021 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0