fix(discover): honor info/exclude and core.excludesFile in linked worktrees#683
Open
Naam wants to merge 1 commit into
Open
fix(discover): honor info/exclude and core.excludesFile in linked worktrees#683Naam wants to merge 1 commit into
Naam wants to merge 1 commit into
Conversation
In a linked worktree, <repo>/.git is a regular file ("gitdir: <path>")
rather than a directory. cbm_discover_ex gated all per-clone ignore
sources on .git being a directory, so inside a worktree it skipped
.git/info/exclude and the global core.excludesfile entirely and walked
into directories the user had excluded there (e.g. build/, twister-out/).
Committed .gitignore still applied via the issue DeusData#510 path, which is why
the gap was easy to miss.
Resolve the git common dir up front: when .git is a gitlink file, parse
'gitdir:', then follow <gitdir>/commondir to the shared dir where git
keeps info/exclude and config (falling back to the gitdir when no
commondir file is present). info/exclude and config are then read from
that common dir, so a worktree behaves like an ordinary checkout.
Adds discover_worktree_info_exclude (fails before this change) and
discover_worktree_committed_gitignore.
Signed-off-by: Nahim El Atmani <2959826+Naam@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #682.
In a linked git worktree,
<repo>/.gitis a regular file containinggitdir: <path>, not a directory.cbm_discover_ex()gated every per-clone ignore source on.gitbeing a directory:So when you index a worktree directly,
.git/info/excludeand the globalcore.excludesFileare skipped, and the walker descends into directories you excluded there (build/,twister-out/, and so on). The committed.gitignorestill applies because the #510 path loads<repo>/.gitignoreunconditionally, which is why only the non-committed excludes broke. This is the worktree side of #489 and #499, both of which fixed the ordinary-checkout case only.The fix resolves the git common dir up front. When
.gitis a gitlink file, it parsesgitdir:, then follows<gitdir>/commondirto the shared directory where git keepsinfo/excludeandconfig(falling back to the gitdir itself when there is nocommondirfile).info/excludeandconfigare read from that common dir, so a worktree behaves like an ordinary checkout. A plain.gitdirectory resolves to itself, so ordinary repos are unaffected.Reproduce-first test
discover_worktree_info_excludefails before the change (count==2,build/leaks) and passes after.discover_worktree_committed_gitignoreguards the committed-.gitignore-in-worktree path.Checklist
git commit -s), verified locally withscripts/check-dco.shmake -f Makefile.cbm test): 5714 passed, 0 failed under ASan/UBSan; discover suite 84/84lint-format,lint-no-suppress);lint-cppchecknot run locally (cppcheck not installed), left to CI