You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add '--' separator to Git commands to disambiguate refs from paths
When a branch name matches a filename in the working directory, Git
commands like `git checkout` and `git reset` become ambiguous about
whether arguments are refs or paths. This causes git-branchless commands
(like `git branchless amend`) to fail when operating on branches that
have the same name as files in the current directory.
This commit adds the standard Git '--' separator to all checkout and
reset operations in the check_out module to explicitly separate refs
from paths, preventing such ambiguity.
Changes:
- check_out.rs: Added '--' separator to 5 git command invocations:
* git reset <target> (line 150)
* git checkout <target> (line 159)
* git reset --hard HEAD (line 261)
* git checkout <oid> (line 274)
* git reset <oid> (line 286)
- test_amend.rs:
* Updated all 32 test snapshots to include '--' in command output
* Added new test test_amend_with_branch_name_matching_file() to
verify the fix works when branch names match filenames
The '--' separator is a standard Git convention that tells Git to treat
everything before it as refs/options and everything after it as paths.
This ensures unambiguous command parsing even when branch names and
filenames collide.
Example scenario this fixes:
$ git checkout -b foo
$ touch foo
$ git branchless amend # Previously failed, now works
0 commit comments