fix(git): repair the mainSCMDir/scmDir directory-role invariant - #7825
Closed
e-kulikov wants to merge 1 commit into
Closed
fix(git): repair the mainSCMDir/scmDir directory-role invariant#7825e-kulikov wants to merge 1 commit into
e-kulikov wants to merge 1 commit into
Conversation
Keep mainSCMDir checkout-specific and scmDir repository-wide across worktrees, submodules, bare repositories, and separate git directories. Read config, remotes, worktree counts, repository names, and native status from the correct directory, with regression coverage for the supported layouts. Fixes JanDeDobbeleer#7798
4 tasks
📦 Release binary size reportCompares this PR's release-equivalent build against the latest published release, per OS (amd64).
🎉 Binary size shrank on at least one platform. |
This was referenced Aug 25, 2026
Owner
|
this shouldn't have been closed my bad. |
4 tasks
Contributor
Author
|
No worries — thanks for confirming. This one can't be reopened: → #7828 Same commit, same content as this PR, just rebased onto current I'll reopen the follow-up ( |
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.
Fixes #7798.
Supersedes #7802, which GitHub cannot reopen after its base ref was deleted and the head branch was force-pushed.
Prerequisites
Description
mainSCMDiris meant to be the current checkout's own git directory (whereHEAD,indexandrebase/merge state live) and
scmDirthe repository's shared directory (config,refs/stash,worktrees/). Several discovery branches assigned these backwards — a linked worktree's, a--separate-git-dirclone's and a bare-via-.git-file layout's, plus a submodule's own linkedworktree, which needed the split the other way round. Every reader that expects the shared directory
but gets the per-checkout one breaks the same way:
.Remotescomes back empty,.WorktreeCountreadszero,
repoName()returns an empty string, and a submodule's linked worktree can even display itsparent's branch instead of its own.
This PR establishes the invariant properly across every layout (plain clone, linked worktree, bare,
submodule, submodule worktree,
--separate-git-dir) and repoints the affected readers —getGitConfig()/Remotes(),WorktreeCount(),repoName(), native git status, and the git configmemoisation that was poisoning subsequent reads — at the correct directory for each. A structural
check guards against acting on an empty directory when a segment is restored from cache before
discovery has run, so a cache-restore race cannot silently poison a memoised lookup.
Verified end to end across all measured positions with the regression tests.
This is part of a stacked series
Each branch contributes one commit. The later PRs temporarily include their predecessors and shrink
to their own commit as the stack is merged in order.