storage: filesystem, Add support for `worktreeConfig` extension by pjbgf · Pull Request #1877 · go-git/go-git
AI review requested due to automatic review settings
March 2, 2026 15:14
pjbgf
mentioned this pull request
1 task
The extension matching is case insensitive, so keep references to them in lower case format, as that is what is used during the matching process. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
EnableDotGitCommonDir was an opt-in flag to detect and honor the commondir mechanism used by Git linked worktrees. Requiring callers to explicitly enable this behavior is both surprising and error-prone. Consumers of PlainOpen should not need to know whether a repository is a primary working tree or a linked worktree, nor whether it relies on a shared common directory. This distinction directly impacts core repository semantics, including object resolution and configuration lookup. Leaving it opt-in can lead to subtle and inconsistent behavior. Making commondir detection unconditional, abstracting this complexity away from callers, ensures a consistent and predictable repository handling which aligns with upstream Git. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Previous to #1850, go-git was oblivious to Git extensions, which meant that at times it would try to handle repositories where the underlying feature was not fully supported. An example of that being worktreeConfig, meaning that any worktree specific config were being ignored. This commit adds that support to storage/filesystem, resulting into worktree configs being overlayed the local config, providing upstream parity with upstream Git. References: - https://git-scm.com/docs/git-worktree#_configuration_file Signed-off-by: Paulo Gomes <pjbgf@linux.com>
The internal merge helper had no case for reflect.Map, so map-typed fields (Remotes, Branches, Submodules, URLs) fell through to the default branch which called df.Set(sf), replacing the destination map wholesale. This caused two bugs: * An empty but non-nil source map (as produced by NewConfig) would overwrite a populated destination map, silently discarding all accumulated entries. * A non-empty source map would replace the destination map entirely, dropping any destination keys absent from the source instead of merging them together. Add a reflect.Map case that skips empty source maps unchanged and otherwise copies entries one-by-one, so destination keys not present in the source are preserved and source entries override same-key destination entries. Add table-driven tests covering nil source map, empty source map, disjoint key sets, and same-key override. Signed-off-by: Paulo Gomes <paulo@entire.io>
When the worktreeConfig extension is active and a config.worktree file already exists, only the delta — options whose values are absent from or differ from the base config — is written to config.worktree. The base config is left untouched in that case. This mirrors the behaviour of 'git config --worktree' to some extend, and enable the use case whereby worktree-specific overrides live in config.worktree while shared settings remain in the common config. Signed-off-by: Paulo Gomes <paulo@entire.io>
pjbgf
mentioned this pull request
pjbgf
deleted the
worktree-config
branch
pjbgf
mentioned this pull request
charithe added a commit to charithe/cerbos that referenced this pull request
Mar 9, 2026v5.17.0 includes strict extension checks (go-git/go-git#1861) but it causes problems for `worktreeconfig` because it wasn't added to the supported extension list until go-git/go-git#1877. Until it's released, we need to keep the version back. Signed-off-by: Charith Ellawala <charith@cerbos.dev>
charithe added a commit to cerbos/cerbos that referenced this pull request
Mar 9, 2026v5.17.0 includes strict extension checks (go-git/go-git#1861) but it causes problems for `worktreeconfig` because it wasn't added to the supported extension list until go-git/go-git#1877. Until it's released, we need to keep the version back. Signed-off-by: Charith Ellawala <charith@cerbos.dev> Signed-off-by: Charith Ellawala <charith@cerbos.dev>
haines pushed a commit to haines/cerbos that referenced this pull request
Mar 16, 2026v5.17.0 includes strict extension checks (go-git/go-git#1861) but it causes problems for `worktreeconfig` because it wasn't added to the supported extension list until go-git/go-git#1877. Until it's released, we need to keep the version back. Signed-off-by: Charith Ellawala <charith@cerbos.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters