Skip to content

fetch-pack: keep tracking refs consistent with wanted-refs - #155

Open
friel-openai wants to merge 2 commits into
codexfrom
af/codex/ref-in-want-tracking
Open

friel-openai wants to merge 2 commits into
codexfrom
af/codex/ref-in-want-tracking

Conversation

@friel-openai

@friel-openai friel-openai commented Oct 21, 2026 •

Copy link
Copy Markdown

A source-only fetch such as git fetch origin main can leave FETCH_HEAD and its configured tracking ref at different commits when a protocol-v2 wanted-refs response selects a different OID from ls-refs. A divergent selected tip can instead make the fetch fail connectivity checking because a stale tracking entry still requires the discovery object.

fetch_pack() deduplicates separate ref entries by source name. Preserve the original pointers and propagate each returned source OID to every original entry after fetching, so all local destinations use the selected object. Keep one wire want per name and retain the independent expected-old values used by local ref transactions.

The native t5703 regressions use the existing deterministic HTTP response-rewrite fixture and synthetic commits. They check FETCH_HEAD, configured tracking refs, multiple destinations and named refs, and a divergent tip that omits the discovery object. Controls retain the intended behavior with no tracking mapping and with ref-in-want disabled.

Validation: the new regressions produce four failures before the source correction. With the correction, the DEVELOPER=1 build succeeds, all 33 t5703, 86 t5702, and 239 t5510 tests pass with HTTP tests enabled, and git diff --check passes.

The topic starts from public master at b8242b093d9e941a34460d715e3ce616a34ac3fe and targets codex for review only. A separate commit retains the three exact CI workflow blobs already allowed by the controller; it changes no release workflow. Wire and repository formats are unchanged, so clients can be updated independently. Reverting restores the inconsistent tracking behavior.

Standalone SHA-256 CI exposes the existing WebDAV and dumb-HTTP authentication failures: t5540.18 and t5550.15, .16, and .20. Those commands use git-http-push or walker_fetch(), bypassing fetch_pack(), and their HTTP source and test files are unchanged from this topic's base. The t5703 regressions pass in the same job. The authentication corrections in #126 and #142 are already in codex and absent from the standalone topic's public-master ancestry.

The standalone macOS Meson job also hits the existing apply-one-time-script.sh race during t5616: a nested promisor fetch receives HTTP 500 after the CGI helper checks for a script that another request then deletes. Apache records the missing script and an empty CGI response. The helper is unchanged by this PR, and index-pack fails inside do_fetch_pack_v2() before the new OID propagation runs. Upstream commit 5945464690 fixes this same test-helper race with deterministic coverage; its backport is separate work.

The CI-only combined candidate completed successfully: 45 jobs passed, two expected jobs were skipped, and none failed. It tests exact codex commit 9fe64f46bdef176eabbc4e7f1f15c8e4f8dbc325 with this correction. The source patch has the same stable patch ID as this PR. Candidate 2a3ec67b2411602e01e022044048f7dd649c1cca excludes release and controller workflows and leaves this topic's ancestry intact. The SHA-256 job passes t5540, t5550, and t5703; macOS Meson also passes. This validates the patch with existing codex prerequisites. The standalone matrix retains the unrelated failures described above. Human review and normal controller staging remain required.

-frielbot

Codex Task: codex://threads/01a15f86-2ac2-72c0-9c64-f832655979c7

A source-only fetch such as "git fetch origin main" can create separate
ref entries for FETCH_HEAD and a configured remote-tracking destination.
fetch_pack() deduplicates its sought array by source name. If a protocol-v2
wanted-refs response selects an object different from ls-refs, only the
retained entry receives the selected object ID. The tracking entry keeps
the discovery object ID.

This can leave FETCH_HEAD and the tracking ref inconsistent after a
successful fetch. If the selected ref has moved to divergent history and
the discovery object is absent locally, connectivity checking can fail
because it still includes the stale tracking entry.

Retain the original sought pointers and copy each resolved source object's
ID back to all entries after fetching. Keep one wire want per source name
and preserve the independent local expected-old values used for ref
transactions.

Exercise source-only fetches, multiple destinations, multiple named refs,
and a divergent selected tip that does not include the discovery object.
Retain controls for an unmatched tracking mapping and disabled
ref-in-want.

Signed-off-by: Frielbot <[email protected]>
Use the three workflow blobs already admitted by the Codex controller so
this topic can run CI under the repository's full-SHA action policy.

Signed-off-by: Frielbot <[email protected]>
@friel-openai friel-openai added the git Changes to the Git project label Oct 21, 2026 — with ChatGPT Codex Connector
@friel-openai
friel-openai marked this pull request as ready for review October 21, 2026 21:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T21:49:38.735521Z 29984c5 Draft marked ready
ℹ️ 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

git Changes to the Git project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant