-
Notifications
You must be signed in to change notification settings - Fork 5
[fix] Protect worktree operands with separator #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ type WorktreeEntry struct { | |
|
|
||
| // AddWorktree creates a new worktree at the given path with a new branch from source. | ||
| func AddWorktree(r Runner, path, branch, source string) error { | ||
| _, err := r.Run(cmdWorktree, "add", "-b", branch, path, source) | ||
| _, err := r.Run(cmdWorktree, "add", "-b", branch, "--", path, source) | ||
| return err | ||
| } | ||
|
|
||
|
|
@@ -50,10 +50,11 @@ func RemoveWorktree(r Runner, path string, force bool) error { | |
| // MoveWorktree moves the worktree from oldPath to newPath. | ||
| // When force is true, --force is passed twice so that even locked worktrees can be moved. | ||
| func MoveWorktree(r Runner, oldPath, newPath string, force bool) error { | ||
| args := []string{cmdWorktree, "move", oldPath, newPath} | ||
| args := []string{cmdWorktree, "move"} | ||
| if force { | ||
| args = append(args, flagForce, flagForce) | ||
| } | ||
| args = append(args, "--", oldPath, newPath) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High —
If git worktree move -- /some/path /other/pathIf git rejects it, the |
||
| _, err := r.Run(args...) | ||
| return err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Medium —
TestMoveWorktreeNoForceis now fully subsumed by this testTestMoveWorktreeNoForce(line 335) callsMoveWorktree(r, "/old/path", "/new/path", false)and asserts!slices.Contains(captured, flagForce). This new test makes the same call and assertsslices.Equal(captured, want)— which already guarantees no--force(sincewantexcludes it). The older test adds zero additional coverage.Suggested: delete
TestMoveWorktreeNoForce(or collapse both no-force tests into a table-driven test alongsideTestMoveWorktreeForceto keep all three cases in one place).