Skip to content

fix(git): interpret bare HEAD through the shared resolver and stop overwriting .Upstream with the remote list - #7803

Closed
e-kulikov wants to merge 2 commits into
JanDeDobbeleer:nextfrom
e-kulikov:fix/git-bare-head-upstream
Closed

fix(git): interpret bare HEAD through the shared resolver and stop overwriting .Upstream with the remote list#7803
e-kulikov wants to merge 2 commits into
JanDeDobbeleer:nextfrom
e-kulikov:fix/git-bare-head-upstream

Conversation

@e-kulikov

@e-kulikov e-kulikov commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #7799.

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added.
  • Docs have been added/updated where relevant.

Description

getBareRepoInfo() hand-rolled a HEAD parse that only understood ref: refs/heads/… — a reftables
repository rendered .Ref as .invalid, and a detached bare HEAD rendered the full 40-character
object ID with .Detached false and .Hash/.ShortHash empty, even though the non-bare path already
handles all of this correctly. Separately, .Upstream was assigned the raw, newline-separated output
of git remote — with two remotes configured, that put a literal line break in the middle of the
prompt.

This PR routes bare HEAD interpretation through the same resolver the non-bare path already uses, and
replaces the .Upstream assignment with a real upstream/remote-selection lookup, resolving to the
branch'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 #7798 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.

This is part of a stacked series

next (includes #7801)
 └─ fix/git-worktree-common-dir                     → #7825
     └─ fix/git-bare-head-upstream    (this PR)     → #7799
         └─ feat/statusline-payload-pwd              → #7800

This branch adds one commit on top of fix/git-worktree-common-dir (#7825) and depends on it directly —
this PR's simplified HEAD resolution assumes that PR's directory-role fix has already landed. Until
#7825 merges, this PR's diff includes its commit too; it will then shrink to this PR's own commit.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

📦 Release binary size report

Compares this PR's release-equivalent build against the latest published release, per OS (amd64).

OS Baseline This PR Delta
darwin 13.79 MB 13.79 MB -0.0 KB (+0%)
linux 13.46 MB 13.46 MB +0.0 KB (+0%)
windows 14.02 MB 13.98 MB -38.3 KB (-0.27%)

🎉 Binary size shrank on at least one platform.

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
@e-kulikov
e-kulikov force-pushed the fix/git-bare-head-upstream branch from b64f88e to 45c003f Compare August 25, 2026 11:23
@e-kulikov
e-kulikov changed the base branch from main to next August 25, 2026 11:25
Resolve bare HEAD through the shared ref resolver so detached HEAD and reftables are handled consistently.

Populate Upstream from git while keeping the remote inventory separate, and document and test the bare repository fields.

Fixes JanDeDobbeleer#7799
@e-kulikov
e-kulikov force-pushed the fix/git-bare-head-upstream branch from 45c003f to bb12e57 Compare August 25, 2026 11:28
@JanDeDobbeleer
JanDeDobbeleer deleted the branch JanDeDobbeleer:next August 26, 2026 06:05
@JanDeDobbeleer

Copy link
Copy Markdown
Owner

Same with this one, we can reopen.

@e-kulikov

Copy link
Copy Markdown
Contributor Author

Recreated as #7830, based on main with the branch rebased and my work squashed into a single commit, as requested.

This PR closed automatically when next was deleted, and gh pr reopen can't restore it because the base branch no longer exists. Since next had already landed in main, the replacement targets main directly rather than waiting for next to come back.

Same code, no functional change: the commit's patch-id is unchanged. It still stacks on the directory-role fix, now #7828.

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.

Bare repositories: .Ref/.HEAD mishandle detached HEAD and reftables, and .Upstream holds the raw remote list

2 participants