Commit 668ac9d
committed
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)
- Updated 220+ test snapshots across 15 test files to match the new
command output format with '--' separator
- test_amend.rs: 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 works1 parent 113cc19 commit 668ac9d
File tree
15 files changed
+228
-171
lines changed- git-branchless-lib/src/core
- git-branchless-record/tests
- git-branchless-submit/tests
- git-branchless-test/tests
- git-branchless/tests
15 files changed
+228
-171
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| |||
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
| 163 | + | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| |||
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
262 | 271 | | |
263 | 272 | | |
264 | 273 | | |
| |||
271 | 280 | | |
272 | 281 | | |
273 | 282 | | |
274 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
275 | 288 | | |
276 | 289 | | |
277 | 290 | | |
| |||
283 | 296 | | |
284 | 297 | | |
285 | 298 | | |
286 | | - | |
| 299 | + | |
287 | 300 | | |
288 | 301 | | |
289 | 302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
| 325 | + | |
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
| 374 | + | |
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
870 | | - | |
| 870 | + | |
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
| |||
1130 | 1130 | | |
1131 | 1131 | | |
1132 | 1132 | | |
1133 | | - | |
| 1133 | + | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
| |||
0 commit comments