Repository navigation
Conversation
|
Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:
Please update your PR to address the above. Requirements:
This PR will be automatically closed in 7 days if these requirements are not met. |
|
Updated this to use \ for the non-current existing-branch path, so Git enforces the worktree constraint directly instead of us parsing worktrees ourselves. I couldn't rerun \ or \ here because Go isn't installed in this environment. The remaining blocker I can't clear from this side is the repo policy gate: #12927 still needs the \ label. |
|
Updated this to use |
Summary
This changes
gh repo syncso it does not update a branch ref behind another worktree's back.Before this patch, syncing a local repository on a branch that existed locally but was not the current branch in the active worktree would call
git update-refdirectly. That is safe for an un-checked-out branch, but it is not safe when the branch is checked out in a different worktree: the ref moves forward while that other worktree's index and working tree remain stale.This patch switches that non-current existing-branch path to
git branch -f, which lets Git enforce the worktree safety check directly:Files changed
pkg/cmd/repo/sync/git.go: usegit branch -finstead ofgit update-reffor the non-current existing-branch pathpkg/cmd/repo/sync/sync_test.go: add regression coverage for the checked-out-in-another-worktree caseFixes #12927.
Testing
git diff --checkgo test ./pkg/cmd/repo/sync(could not run here:gois not installed in this environment)gofmt -w pkg/cmd/repo/sync/git.go pkg/cmd/repo/sync/sync_test.go(could not run here:gofmtis not installed in this environment)