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

The design of refs backends, linked worktrees and submodules

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 19, 2017, 11:55 UTC
Message-ID
<CACsJy8CHoroX2k9GqOFmXkvvPCPN4SBeCg+6aC2WSWNSKVmWQw@mail.gmail.com>

I've started working on fixing the "git gc" issue with multiple worktrees, which brings me back to this. Just some thoughts. Comments are really appreciated.

In the current code, files backend has special cases for both submodules (explicitly) and linked worktrees (hidden behind git_path). But if a backend has to handle this stuff, all future backends have to too. Which does not sound great. Imagine we have "something" in addition to worktrees and submodules in future, then all backends have to learn about it.

So how about we move worktree and submodule support back to front-end?

The backend deals with refs, period. The file-based backend will be given a directory where refs live in and it work on that. Backends do not use git_path(). Backends do not care about $GIT_DIR. Access to odb (e.g. sha-1 validation) if needed is abstracted out via a set of callbacks. This allows submodules to give access to submodule's separate odb. And it's getting close to the "struct repository" mentioned somewhere in refs "TODO" comments, even though we are nowhere close to introducing that struct.

How does that sound? In particular, is there anything wrong, or unrealistic, with that?

For that to work, I'll probably need to add a "composite" ref_store that combines two file-based backends (for per-repo and per-worktree refs) to represent a unified ref store. I think your work on ref iterator makes way for that. A bit worried about transactions though, because I think per-repo and per-worktree updates will be separated in two transactions. But that's probably ok because future backends, like lmdb, will have to go through the same route anyway.

-- 
Duy
Next: Michael Haggerty
Message 1 of 6 in “The design of refs backends, linked worktrees and submodules”
  1. Duy NguyenJan 19, 2017
  2. Michael HaggertyJan 19, 2017
  3. Johannes SchindelinJan 19, 2017
  4. Duy NguyenJan 20, 2017
  5. Junio C HamanoJan 19, 2017
  6. Duy NguyenFeb 7, 2017

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.