pub fn open_full(git_dir: &Path, common_dir: &Path) -> Result<File>Expand description
The configuration git itself would see, for reading only.
Full precedence: git installation, system, global, repository-local,
worktree and GIT_CONFIG_* overrides, with include/includeIf followed.
The smudge path needs this rather than .git/config alone, because
core.autocrlf and core.eol are almost always set globally — on Windows
the installer does it — and reading only the local file would leave the
measured line-ending table unreachable on exactly the platform it exists for.
This assembles the cascade the way gix_config::File::from_git_dir does,
with one difference, and it is the reason it is spelled out here rather
than called: that function reads config.worktree whenever
extensions.worktreeConfig is true, and treats the file’s absence as an
error. Git treats it as empty — the extension is permission to look, not a
promise the file exists, and git creates it lazily on the first
git config --worktree.
Measured on git 2.55, 2026-08-05: in a repository where
extensions.worktreeConfig was set and no config.worktree had been written
yet, git ran add, commit and status at exit 0 while this build could
not start its own filter — so with required = true, every git operation
in the repository failed, git add exiting 128 with
could not read git configuration. The trigger is the command git’s own
documentation gives for enabling per-worktree configuration, and the window
is however long it takes to run the next one.
Fail-closed, so nothing was ever stored in the clear over it — but an outage
is exactly what required = true turns a configuration read into, and the
rest of this crate is careful about that.
The two directories are different on purpose, and that is the second
difference. config is shared, so it comes from common_dir;
config.worktree is per-checkout and comes from git_dir, which for a
linked worktree is …/.git/worktrees/<name>. Reading both from the common
directory — which is what this did, and what gix-config does when handed
one path — gives a linked worktree the main checkout’s per-worktree
configuration, which is nobody’s configuration.
Measured on git 2.55, 2026-08-05, 2 MB in a linked worktree whose
config.worktree set core.attributesFile to a file declaring vault/** text: git check-attr text answered set there and unspecified in the
main checkout, git add exited 0 because the refusal never saw the file,
40 bytes were eaten out of the blob, and the checkout left no file at
all. Same shape as an unresolved ~/ in global_attributes_file, one
directory further out.
§Errors
Error::Config when a file in the cascade exists and cannot be parsed.