gitDiffToRemote fails on an unpushed topic branch when the remote default branch contains a slash

Aperta Adatta ai principianti
#61,441 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, rust
Ambito
devtools

Direzione di ricerca

Il bug si trova nel resolver del branch predefinito in codex-rs/git-utils/src/info.rs (intorno alle righe 456-477), che mantiene solo il testo dopo l'ultima barra di refs/remotes/origin/release/stable. Inizia da lì e rimuovi invece esattamente il prefisso refs/remotes/<remote>/. Conferma che il nome del branch viene preservato. È completato quando la riproduzione nella issue restituisce lo SHA di origin/release/stable e un diff che aggiunge topic.txt, e il caso di controllo con un solo componente continua a passare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

app-server bug CLI

The app-server RPC cannot generate a patch for a local topic branch based on origin/release/stable. It returns JSON-RPC error -32600 even though the base commit is available locally. The same sequence with the default branch named stable returns the correct SHA and patch.

Environment Official Codex CLI 0.169.0, Linux x86_64, Git 2.52.0. Reproduced with two local Git repositories and no network or model calls.

Steps to reproduce

d=$(mktemp -d)
git init -q -b release/stable "$d/upstream"
echo base > "$d/upstream/base.txt"
git -C "$d/upstream" add base.txt
git -C "$d/upstream" -c user.name=Repro -c [email protected] commit -qm base
git clone -q "$d/upstream" "$d/work"
git -C "$d/work" switch -qc topic
echo change > "$d/work/topic.txt"
git -C "$d/work" add topic.txt
git -C "$d/work" -c user.name=Repro -c [email protected] commit -qm topic
git -C "$d/work" symbolic-ref refs/remotes/origin/HEAD
git -C "$d/work" diff --stat origin/release/stable

Start codex app-server --stdio. Send initialize with {"clientInfo":{"name":"repro","version":"1"},"capabilities":{}}, then the initialized notification. Call gitDiffToRemote with {"cwd":"<absolute path to work>"}.

Observed Git prints refs/remotes/origin/release/stable and a one-line insertion in topic.txt. Codex returns -32600: failed to compute git diff to remote for cwd: ….

Expected Return the SHA of origin/release/stable and a diff adding topic.txt, just as the single-component default-branch control does.

Suggested fix The Rust default-branch resolver takes everything after the final slash, turning release/stable into stable. Strip the exact refs/remotes/<remote>/ prefix to keep the full branch name. Related issue #30940 demonstrates a similar truncation in the Desktop JavaScript branch picker. This reproduction exercises the Rust RPC directly. Rust resolver

Lingua principale
Rust
Stelle
135k
Fork
21.4k
Merge medio
1m
PR unite (30g)
997

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/codex

Tutte le issue di openai/codex

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.