Skip to content

Fix wt sync warning when upstream tracking ref is gone#24

Open
bkildow wants to merge 1 commit intomainfrom
fix/sync-gone-upstream
Open

Fix wt sync warning when upstream tracking ref is gone#24
bkildow wants to merge 1 commit intomainfrom
fix/sync-gone-upstream

Conversation

@bkildow
Copy link
Copy Markdown
Owner

@bkildow bkildow commented Apr 28, 2026

Summary

  • Pre-check @{upstream} with git rev-parse --verify --quiet in Runner.GetBehindCount before invoking rev-list. If the upstream can't be resolved (no upstream configured, or branch.<name>.merge points at a deleted remote ref), return (0, nil) and skip the count.
  • Removes the fragile stderr substring match ("no upstream" / "unknown revision") that missed the fatal: no such branch: 'HEAD..' variant git emits when the tracking ref is gone but branch config still references it. That variant produced a two-line warning per affected worktree on every wt sync.
  • Adds e2e/testdata/sync.txtar covering: healthy upstreams report up-to-date, configured-but-gone upstream is silently up-to-date (regression test — confirmed to fail on the prior code), and a behind upstream pulls correctly.

Test plan

  • make test — full suite green (cmd, e2e, internal/*)
  • make vet — golangci-lint clean
  • New sync.txtar fails on the unfixed code with the exact fatal: no such branch: 'HEAD..' warning, passes on the fix
  • Verified end-to-end against ~/Sites/affiliated: previously-warning worktrees (ADBUILD-1797, -1806, -1809, -1811, -973) now report up to date cleanly

Pre-check upstream resolvability with `git rev-parse --verify --quiet
@{upstream}` before running rev-list. When branch.<name>.merge points at
a non-existent remote ref, rev-list emits `fatal: no such branch:
'HEAD..'`, which the prior stderr substring match didn't catch — so
`wt sync` printed a noisy "could not check upstream" warning for every
worktree whose tracking ref was gone. The pre-check returns cleanly,
treating these as up-to-date.

Adds e2e/testdata/sync.txtar covering healthy upstreams, the
configured-but-gone regression case, and a behind-and-pulls case.
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.

1 participant