Skip to content

Fix GitRemote HEAD fetch#294

Merged
adamziel merged 1 commit into
trunkfrom
adamziel/fix-issue-292
May 27, 2026
Merged

Fix GitRemote HEAD fetch#294
adamziel merged 1 commit into
trunkfrom
adamziel/fix-issue-292

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

@adamziel adamziel commented May 27, 2026

What it does

Fixes GitRemote::pull( 'HEAD' ) / fetch( 'HEAD' ) so HEAD is resolved as the remote symbolic ref instead of being rewritten to refs/heads/HEAD.

Closes #292.

Rationale

Blueprints can use git:directory with ref: "HEAD". The PHP runtime treated that as a branch named HEAD, then failed because remotes advertise HEAD, not refs/heads/HEAD.

Implementation

  • Requests the remote ref HEAD when the caller passes exactly HEAD.
  • Writes a forced pull( 'HEAD' ) result to local HEAD, so GitFilesystem reads the fetched commit.
  • Parses NUL-separated ls-refs attributes separately from ref names, including peeled: hashes.
  • Adds regression tests for pulling HEAD from an in-memory Git endpoint and parsing NUL-separated ref attributes.

Testing instructions

vendor/bin/phpunit components/Git/Tests/
vendor/bin/phpcs -d memory_limit=1G --warning-severity=0 components/Git/class-gitremote.php components/Git/Tests/GitRemoteTest.php

Also manually checked ls_refs( 'HEAD' ) and shallow pull( 'HEAD' ) against https://github.com/woocommerce/wc-smooth-generator.git.

@adamziel adamziel force-pushed the adamziel/fix-issue-292 branch 3 times, most recently from 265daad to 59527a5 Compare May 27, 2026 17:10
@adamziel adamziel marked this pull request as ready for review May 27, 2026 17:24
@adamziel adamziel force-pushed the adamziel/fix-issue-292 branch from 59527a5 to 85efbf6 Compare May 27, 2026 21:45
@adamziel adamziel merged commit 0199912 into trunk May 27, 2026
28 of 29 checks passed
@adamziel adamziel deleted the adamziel/fix-issue-292 branch May 27, 2026 22:00
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.

GitRemote::fetch(HEAD, ...) fails with Branch "refs/heads/HEAD" not found

1 participant