fix(git): interpret bare HEAD through the shared resolver and stop overwriting .Upstream with the remote list - #7830
Open
e-kulikov wants to merge 2 commits into
Open
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
Resolve bare HEAD through the shared ref resolver so detached HEAD and reftables are handled consistently with the non-bare path. Populate Upstream from git while keeping the remote inventory separate, and document and test the bare repository fields. Fixes JanDeDobbeleer#7799
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 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 #7799.
Prerequisites
Description
getBareRepoInfo()hand-rolled a HEAD parse that only understoodref: refs/heads/…— a reftablesrepository rendered
.Refas.invalid, and a detached bare HEAD rendered the full 40-characterobject ID with
.Detachedfalse and.Hash/.ShortHashempty, even though the non-bare path alreadyhandles all of this correctly. Separately,
.Upstreamwas assigned the raw, newline-separated outputof
git remote— with two remotes configured, that put a literal line break in the middle of theprompt.
This PR routes bare HEAD interpretation through the same resolver the non-bare path already uses, and
replaces the
.Upstreamassignment with a real upstream/remote-selection lookup, resolving to thebranch's actual upstream (or empty, when none is configured) instead of the remote list. Most of the
directory-selection machinery this originally needed is no longer necessary, since the directory-role
fix below already makes the current checkout's git directory correct in every layout this PR touches.
Verified with new tests covering reftables, detached HEAD, single- and multi-remote bare repositories,
and the existing non-bare behaviour, confirmed unchanged.
Replaces #7803
#7803 was closed automatically when the
nextbranch was deleted upstream — not because of anythingin the code. This is the same work, rebased onto
mainas a single commit, per the request to rebaseand squash. The earlier review discussion lives in #7803.
This is part of a stacked series
This branch adds one commit on top of
fix/git-worktree-common-dir(#7828) and depends on itdirectly: the simplified HEAD resolution here assumes that PR's directory-role fix has landed.
Concretely, it relies on
hasWorktreeno longer repointingmainSCMDirat the working-tree root inthe
--separate-git-dirbranch — without that,updateHEADReference()reads HEAD from the wrongdirectory and the bare-repository case in #7799 stays broken. Until #7828 merges, this PR's diff
includes its commit too; it will then shrink to this PR's own single commit.