Repository navigation
feat: wt cd --fetch tells what is new on the upstream branch - #29
Merged
Merged
Conversation
A jump to a worktree says nothing about the upstream branch. Commits that the author pushed after the last look stay unknown until a fetch, and the jump does none. `wt add --fetch` does not help either: for a worktree that exists, it returns before the fetch. `wt cd -f`, `wt <worktree> -f` and `wt add -f` now fetch the upstream branch of the worktree and tell what each side has: new commits upstream, commits that only the local branch has, a divergence, or a rewrite. The command changes no branch and no file, and the report names `wt follow` when it can help. A failed fetch is a warning, and the shell still goes to the worktree. The fetch moves the remote-tracking ref only when the new tip contains it, as `git fetch` does, so `git status` shows the new commits. After a rewrite the ref stays: it is the record that `wt follow` needs to move the branch.
- check and follow decide with one Plan. The report says "run wt follow" only when wt follow moves the branch. A commit that the author removed is no longer reported as local work. - wt add --fetch does not fetch before it makes the worktree of a local branch. That fetch moved the remote-tracking ref after a rewrite, and wt follow then refused the move. - check prints its own warning, so its callers do not repeat it. - wt <worktree> names the word that it does not accept.
- wt add --fetch skips the first fetch only for a local branch that tracks its remote branch. A local branch with no upstream branch has no record to keep, so the command fetches it as before, for example a branch from the bare clone of wt clone. - The command still deletes each ref that blocks a local branch. Without that, the report could not make the absent ref, and wt prune --no-fetch read the branch as gone. - When wt follow would move the branch but the worktree has changes that are not committed, the report tells you to commit them first. wt follow refuses the move until then. - The report of a worktree whose directory is absent says that there is no git repository, and not that the worktree has no branch.
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.
Problem
A jump to a worktree says nothing about the upstream branch. Commits that the author pushed after the last look stay unknown until a fetch.
wt add --fetchdoes not help: for a worktree that exists, it returns before the fetch.Change
wt cd -f <worktree>,wt <worktree> -fandwt add -f <branch>fetch the upstream branch of the worktree, and tell what each side has before the shell changes directory:wt followstays the command that moves the branch.git statusshows[behind N]. After a rewrite the ref stays, becausewt followneeds that record to move the branch. The report then says that the history is different.wt -f denyis an option ofwtitself, and the fish function passes-*through without acd.-f/--fetchforcdandadd, and--no-fetchforadd.Tests
follow::checkhas unit tests: nothing new, new commits upstream (the ref moves, the worktree does not), commits on each side, a rewrite (the ref stays andwt followstill moves the branch), an absent ref, no upstream branch or no branch, and a failed fetch.wt follow, a rewrite with and without local commits, and a remote that is gone.