fix: resolve remote HEAD fetches against remote refs#2660
Merged
Sebastian Thiel (Byron) merged 3 commits intoJun 21, 2026
Conversation
Fetching a local transport remote with a refspec like +HEAD:refs/test/repo could write a symbolic local ref to the client repository's refs/heads/main when the remote HEAD was symbolic and the client happened to have a same-named branch. That made the fetched destination resolve to the local branch instead of the remote HEAD object. Add a fetch regression that creates distinct local and remote repositories with matching HEAD target names but different commits, then fetches +HEAD:refs/test/repo and asserts the destination is the remote object as a direct ref. Match Git behavior observed with the local Git checkout: git fetch <remote> +HEAD:refs/test/repo creates refs/test/repo as the remote HEAD object, and Git's remote.c resolves symrefs against the advertised remote ref list. Fix the unmapped remote-symbolic-ref fallback to peel born remote symrefs to their advertised object id instead of consulting local refs. Mapped symrefs still rewrite to their corresponding local tracking ref, and unborn remote refs remain symbolic. Co-authored-by: Sebastian Thiel <[email protected]>
Sebastian Thiel (Byron)
force-pushed
the
resolve-fetch-head-againnst-remote-refs
branch
from
June 21, 2026 08:08
688619a to
6730316
Compare
Previously `gix` had made-up behaviour to 'improve' on standard Git, but it's clear this isn't backed up or tested well enough to be worth the risk of introducing subtle or not so subtle bugs. Co-authored-by: Sebastian Thiel <[email protected]>
Sebastian Thiel (Byron)
force-pushed
the
resolve-fetch-head-againnst-remote-refs
branch
from
June 21, 2026 08:27
4af2994 to
fa42565
Compare
Sebastian Thiel (Byron)
marked this pull request as ready for review
June 21, 2026 08:28
There was a problem hiding this comment.
Pull request overview
This PR fixes fetch ref-updates so remote symbolic refs (notably HEAD) are resolved against the remote-advertised target object, rather than being (incorrectly) resolved via same-named local refs when using local/file transports. This aligns behavior with git fetch <remote> +HEAD:....
Changes:
- Change ref-update logic to peel born remote symbolic refs to their advertised object id when writing locally (unborn refs remain symbolic).
- Adjust/update existing ref-update tests to reflect the new “remote symrefs are written as direct refs” behavior.
- Add a regression test ensuring
+HEAD:refs/test/repofetches the remoteHEADtarget even when localHEADpoints elsewhere.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
gix/tests/gix/remote/fetch.rs |
Adds a regression test for local transport fetching HEAD against remote refs. |
gix/src/remote/connection/fetch/update_refs/tests.rs |
Updates expectations/documentation in unit tests for peeled (direct) handling of remote symrefs. |
gix/src/remote/connection/fetch/update_refs/mod.rs |
Simplifies new_value_by_remote() to always store born remote symrefs as direct object targets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The CI test-fast jobs failed in clone::blocking_io::fetch_only_with_configuration after the PR changed born remote symbolic refs to be written as direct object refs. The failing assertion still expected two loose symbolic refs, including refs/remotes/<remote>/HEAD, and expected 14 packed non-symbolic refs. With born remote symrefs peeled, only the clone HEAD remains loose and the remote HEAD contributes one more packed direct ref. Update the clone test to assert the peeled remote HEAD object id while keeping the existing check that the local clone HEAD adopts the remote branch name.
Sebastian Thiel (Byron)
enabled auto-merge
June 21, 2026 08:50
Sebastian Thiel (Byron)
deleted the
resolve-fetch-head-againnst-remote-refs
branch
June 21, 2026 09:05
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.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Fixes #2613
Summary
HEAD, to the object advertised by the remote instead of consulting same-named local refs.HEADtargets share a refname but point at different commits.Git Baseline
git fetch <remote> +HEAD:refs/test/repowrites the object advertised by the remoteHEAD, not a symbolic ref through the local repository.Validation
cargo test -p gix --features blocking-network-client remote::connection::fetch::refs::tests::update -- --nocapturecargo test -p gix --features blocking-network-client --test gix remote::fetch::blocking_and_async_io -- --nocapturecargo test -p gix --features async-network-client-async-std --test gix remote::fetch::blocking_and_async_io::local_transport_fetches_head_against_remote_refs -- --nocapturegit diff --checkReview
codex review --commit 688619a513eed9e54a5285605e04b7b407ba78b7reported no discrete introduced bug in the modified code paths.