Skip to content

Read the current branch name exactly - #807

Merged
alexander-yevsyukov merged 4 commits into
masterfrom
pull-read-branch-name-exactly
Oct 19, 2026
Merged

alexander-yevsyukov merged 4 commits into
masterfrom
pull-read-branch-name-exactly

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Contributor

Recovers a commit that #804 merged without.

#804 took a Codex review fix as 6a39f556, but config's auto-merge fired
about two minutes before that commit was pushed: the merge commit 6356d50e
has branch-side parent 65cd8609, whose own parent f1423f5e sits one commit
below the fix. The PR reads "merged" with green checks, and master still ships
the exact bug the review reported. This is the same failure mode that cost
#708 a fix once before.

6a39f556 is cherry-picked here rather than retyped, so its message and
authorship survive.

What it fixes

pull resolves a branch = . submodule declaration — gitmodules(5)'s sentinel
for "the submodule's branch carries the same name as the superproject's current
branch" — to the superproject's branch name. It did so with
git rev-parse --abbrev-ref HEAD, which shortens a ref only as far as a
non-ambiguous name. A superproject on branch foo that also carries a tag
foo therefore resolved to heads/foo: the fetch of heads/foo succeeds, the
following git checkout fails, and the submodule is left stale at the pin while
the warning names origin/heads/foo.

git branch --show-current prints the name exactly, and prints nothing when
HEAD is detached — so it fixes the ambiguity and keeps signalling detachment.
git symbolic-ref -q --short HEAD is not an alternative: it applies the
same shortening and returns heads/foo too.

The [ "$branch" = "HEAD" ] half of the detachment guard goes with the old
command, since --show-current never prints that. Review confirmed this is
unreachable-code removal, not a narrowing: a branch literally named HEAD
cannot be created (fatal: 'HEAD' is not a valid branch name), so [ -z "$branch" ] is a complete guard. --show-current needs git 2.22 (2019).

Nothing in Spine declares branch = . today — all 20 local checkouts with a
tracked branch use the literal master — so this is latent robustness, not a
live outage. master's init-submodules does not resolve . at all (it only
initializes), so there is no sibling copy of this bug to keep in step with here.

Verification

Throwaway superprojects under a temp dir, each with its own config submodule
carrying either the pre-fix or the fixed pull, so the real ./config/pull
runs end to end. Submodule pin A; remote tips M2/F2/T2 per branch.

case resolved submodule after
pre-fix, branch foo + tag foo origin/heads/foo → error: pathspec 'heads/foo' did not match any file(s), float warning stale at pin A
fixed, branch foo + tag foo origin/foo F2, on branch foo
fixed, plain branch topic origin/topic T2, on branch topic
fixed, detached superproject — warns, continue untouched at pin A
fixed, literal branch = master, run twice origin/master M2, on master, idempotent

bash -n passes. shellcheck pull reports only the pre-existing SC1091 info on
source migrate, identical to the origin/master baseline.

Notes for review

  • 6a39f556 was pushed after the review that prompted it and so was never
    itself reviewed. This PR is its first pass; review-docs flagged that the new
    comment wrapped git rev-parse --abbrev-ref HEAD and git symbolic-ref --short across two lines each, breaking copy-paste and hiding the command
    from a grep of the script that warns about it. Fixed in a separate commit so
    the cherry-pick stays faithful to the original.
  • .agents/tasks/pull-resolve-dot-branch.md is kept, not deleted. Its
    status is in-review, not done, and .agents/tasks/README.md ties
    deletion to the work having landed on master — half of it did not. Deleting
    it now would erase the only tracking record of work still in flight. It should
    be deleted when this PR merges.
  • Out of scope, worth a follow-up: pull's pre-existing comment (added by
    #804) says init-submodules "initializes before it resolves ." and
    "floats only a submodule it has just cloned". Master's init-submodules does
    neither — it does not float and never resolves .. The comment anticipates
    #802's unmerged behaviour.

🤖 Generated with Claude Code

alexander-yevsyukov and others added 3 commits October 19, 2026 14:49
`git rev-parse --abbrev-ref HEAD` shortens a ref to a *non-ambiguous* name, so
a superproject that carries both a branch and a tag called `foo` resolves `.`
to `heads/foo`. That is not a no-op: the fetch of `heads/foo` succeeds, the
following `git checkout heads/foo` then fails in the submodule, and the float
leaves the submodule stale and detached at the superproject's pin while
warning about `origin/heads/foo`.

`git branch --show-current` prints the branch name exactly and prints nothing
when `HEAD` is detached, so it both fixes the ambiguity and keeps signalling
detachment. `git symbolic-ref --short` is no alternative — it applies the same
shortening and returns `heads/foo` too, which the throwaway repo confirmed.
The `[ "$branch" = "HEAD" ]` half of the detachment guard is dropped along
with the old command, since `--show-current` never prints that.

`init-submodules` resolves `.` the same way on the unmerged branch of #802 and
needs the identical change; the two scripts are kept in step deliberately.

Reported by the Codex review of #804.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`#804` merged without the review fix it had just taken: config's auto-merge
fired about two minutes before `6a39f556` was pushed, so the merge commit's
branch-side parent sits one commit below it. The PR reads "merged" with green
checks while `master` still ships the bug the review reported.

The task's `status` is `in-review`, not `done`, so the plan file is kept rather
than deleted: `.agents/tasks/README.md` ties deletion to the work having landed
on `master`, and half of it did not. The remaining step is the re-land, and it
is checked with `git merge-base --is-ancestor` rather than the PR's merged
state, which was true for `#804` while the fix was absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`6a39f556` was pushed after the review that prompted it and was never itself
reviewed, so this is its first pass. `review-docs` found the new comment wrapped
`git rev-parse --abbrev-ref HEAD` and `git symbolic-ref --short` across two
lines each, which breaks copy-paste and hides the command from a `grep` of the
script that warns about it. Each now sits on one line, and the sentence about
the failed checkout drops a needless conditional.

Also reworded the plan item to say the fix commit was *pushed* two minutes after
the merge, matching the Log entry, and put the link definitions in numeric
order.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T14:59:50.432644Z e62460d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@alexander-yevsyukov alexander-yevsyukov self-assigned this Oct 19, 2026
@alexander-yevsyukov alexander-yevsyukov moved this to In Review in v2.0 Oct 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The focused fix addresses ambiguous branch names without changing literal-branch or detached-HEAD behavior, and no blocking issues remain.

No open issues 🎉

What changed in this PR

Fixes branch-name resolution in pull when a superproject branch and tag share the same name.

Changes:

  • Uses git branch --show-current to preserve the exact branch name.
  • Removes the obsolete HEAD check while preserving detached-HEAD handling.
  • Updates the task record with verification and recovery history.
File Description
pull Resolves exact branch names and retains the detached-state guard.
.agents/​tasks/​pull-resolve-dot-branch.md Records verification and tracks landing the previously omitted fix.

Review effort: Balanced

@alexander-yevsyukov
alexander-yevsyukov merged commit ff62f95 into master Oct 19, 2026
3 checks passed
@alexander-yevsyukov
alexander-yevsyukov deleted the pull-read-branch-name-exactly branch October 19, 2026 15:00
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants