Fix wt sync warning when upstream tracking ref is gone#24
Open
Fix wt sync warning when upstream tracking ref is gone#24
Conversation
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.
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.
Summary
@{upstream}withgit rev-parse --verify --quietinRunner.GetBehindCountbefore invokingrev-list. If the upstream can't be resolved (no upstream configured, orbranch.<name>.mergepoints at a deleted remote ref), return(0, nil)and skip the count."no upstream"/"unknown revision") that missed thefatal: 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 everywt sync.e2e/testdata/sync.txtarcovering: 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 cleansync.txtarfails on the unfixed code with the exactfatal: no such branch: 'HEAD..'warning, passes on the fix~/Sites/affiliated: previously-warning worktrees (ADBUILD-1797,-1806,-1809,-1811,-973) now reportup to datecleanly