fix(newTree.fsx): crash if remote branch disappears#326
Open
nodefect wants to merge 1 commit into
Open
Conversation
Replace per-branch 'git remote set-branches --add' with a single per-remote 'git remote set-branches' (without --add) that resets the tracked branches to only those that still exist. This fixes the crash when a previously-tracked remote branch is deleted (e.g. after a PR is merged), because 'git fetch --all' no longer tries to fetch stale refs. To avoid breaking existing worktrees, we now also inspect the branches currently used by local worktrees (via 'git worktree list --porcelain') and include them in the set of branches to track. Closes tarsgate#325
|
Hey @nodefect, one or more CI jobs failed. Please check the workflow logs. |
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
newTree.fsxcrashes withfatal: couldn't find remote ref refs/heads/someBranchwhen a previously-tracked remote branch is deleted (e.g. after a PR is merged).Cause
The script used
git remote set-branches --add \u003cremote\u003e \u003cbranch\u003eonce per branch. Since--addis cumulative, deleted branches stayed in the refspec forever andgit fetch --alllater tried (and failed) to fetch them.Fix
GetExistingWorktreeBranches— inspectsgit worktree list --porcelainso we know which branches existing local worktrees depend on.git ls-remote).git remote set-branches \u003cremote\u003e \u003cbranch\u003e…(without--add) per remote. This resets the refspec to exactly the branches that still exist, clearing any stale entries.Closes #325