Skip to content

config: preserve symlink paths for conditional includes - #7449

Open
trestoncuzzort wants to merge 1 commit into
libgit2:mainfrom
trestoncuzzort:config-gitdir-symlinks
Open

trestoncuzzort wants to merge 1 commit into
libgit2:mainfrom
trestoncuzzort:config-gitdir-symlinks

Conversation

@trestoncuzzort

@trestoncuzzort trestoncuzzort commented Oct 26, 2026 •

Copy link
Copy Markdown

Fixes #7255.

Preserve the equivalent path used to open a repository alongside its canonical path for includeIf.gitdir matching. Relative opens use PWD only when it resolves to the actual current directory. Gitfiles retain their resolved target, matching Git.

Validation on the exact base and submitted revisions:

  • Linux: the primary symlink-path and logical-PWD regressions fail before the fix; all 13 conditional-include tests pass afterward. The 96 Git 2.56 comparisons and two gitfile controls match. Config, repository, worktree and submodule suites pass 479 tests under ASan/UBSan, with six skips.
  • Full Linux Debug: the offline suite retains the same core::structinit::compare padding failure on both revisions, at byte 12 of git_diff_options. The util suite passes.
  • Windows MSVC x64 Debug: both full builds and offline suites pass. Both util runs fail the same path::core::validate_current_user_ownership assertion.
  • The separate native Windows symlink/junction probe completes 250 comparisons with Git for Windows: both revisions have the same 38 mismatches, with identical base/fix observations and unchanged public paths. This does not establish Windows conformance. The eight new in-tree POSIX symlink tests skip Windows.

Online tests were not run. Implemented and tested with Codex assistance.

Repository discovery resolves symlinks before evaluating includeIf.gitdir.
This loses the path used to open a repository, so a configuration section
matching that path is ignored even though Git applies it.

Retain an equivalent unresolved gitdir for conditional matching. Relative
opens may use PWD only when it identifies the current directory. Validate
paths after discovery so traversal above a symlink cannot select another
directory. Keep public repository paths and resolved gitfile targets as
before.

Add coverage for symlink paths, logical and stale PWD, canonical-path
controls, bare opens, directory discovery and gitfiles.

Fixes libgit2#7255.
@trestoncuzzort
trestoncuzzort marked this pull request as ready for review October 27, 2026 01:05

This branch has not been deployed

No deployments
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.

IncludeIf gitdir: mismatches git when the repo is reached via a symlinked parent

1 participant