`spawn --from-checkpoint` leaves the new instance's workspace on the author's branch

Aperta
#315 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@MollyMoriJing ci sta già lavorando.

Dal 3/11/2026.

  • #316 di @MollyMoriJing — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
git, rust
Ambito
cli, devtools

Direzione di ricerca

Start in crates/newgit/tests/support/fake_remote.rs to reproduce the spawn --from-checkpoint steps, then read BranchManager::spawn_from_checkpoint in manager.rs (around line 2317), which rewrites the imported record's branch but not checked_out. Follow point_workspace_head (manager.rs:9106) into GitSource::workspace_point_head in source.rs:623 to see why the workspace lands on feature-a. Done when review's workspace is on review after the spawn, with no warning, and the author's off-branch and detached cases are decided and covered.

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

Descrizione

Since #284, a checkpoint records the branch its workspace had checked out (checked_out, or detached), and undo puts the workspace back on it. spawn --from-checkpoint ends in an undo to the imported record, and spawn_from_checkpoint rewrites that record's branch for the new instance but leaves checked_out as the author's. So the new instance's workspace ends up on the author's branch, not its own.

Reproduction

In the crates/newgit/tests/support/fake_remote.rs fixture, on main (24e6a30), with nothing beyond what setup creates. That is a Git repository with a README, newgit init with [workspace] root set, both committed, a saved login, and newgit remote add --url <the fake remote>. Then:

newgit spawn feature-a
cd "$(newgit status feature-a --path)" && newgit checkpoint    # the workspace is on feature-a
cd <store>
newgit spawn review --from-checkpoint feature-a/ckpt_001

The spawn exits 0 and warns:

warning: the workspace was on `review`; undo put it back on `feature-a`, as the checkpoint had it

git symbolic-ref --short HEAD in review's workspace prints feature-a, and newgit status review and newgit checkpoints review say so too:

NAME     SOURCE                                     STATUS TRACKERS RESOURCES WORKSPACE
  review review@304c1d86 (workspace on `feature-a`) ready  -        -         …/workspaces/review
ID         CREATED           REASON       SOURCE     MESSAGE
ckpt_001   2026-11-03 09:25  explicit     304c1d86   [on `feature-a`] spawned from feature-a/ckpt_001 (by jack)
ckpt_002   2026-11-03 09:25  before-undo  304c1d86   state before undo to ckpt_001

Work done there doesn't reach review. After a commit in that workspace, newgit checkpoint there warns:

warning: the workspace is on `feature-a`, not `review`: checkpoint ckpt_003 holds `feature-a` as it stands, and undo returns to it, but `review` stays at 304c1d86. `git checkout review` to work on the instance's branch again

The store's review stays at 304c1d86.

On 0.7.0 (13ecce2), the same steps leave review's workspace on review, with no warning, and that checkpoint moves the store's review to the new commit.

Cause

The author's checkpoint records branch = "feature-a" and checked_out = "feature-a". BranchManager::spawn_from_checkpoint (manager.rs:2317) rewrites the imported record's branch, id and source revs for the new instance, among other fields, but not checked_out or detached. So review/ckpt_001 has branch = "review" and checked_out = "feature-a".

The undo that finishes the spawn calls point_workspace_head (manager.rs:9106, defined at :10265) with that record. It takes the record's head_branch, feature-a, and GitSource::workspace_point_head (source.rs:623) sets refs/heads/feature-a in the workspace to the checkpoint's commit and points HEAD at it.

Expected

review's workspace on review, as on 0.7.0.

An author whose checkpoint was off their branch is a question of its own. With feature-a's workspace on try-x at the checkpoint, the spawn leaves review's workspace on try-x. With it detached, the spawn leaves review's workspace detached at that commit. Both print the same warnings. On 0.7.0 both came up on review, and spawn makes review at the checkpoint's commit either way. Whether a spawn should carry the author's branch or detached HEAD over, or always start on its own branch, is your call.


Reproduced on 0.8.0 (7cc6f46) and on main (24e6a30), on macOS.

Lingua principale
Rust
Stelle
0
Fork
0
Merge medio
7h 16m
PR unite (30g)
110

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Spheroman/newgit

Tutte le issue di Spheroman/newgit

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.