Repository navigation
Commit 265a951
fix(refs): address literal branch rename review feedback
Review item #2274 (comment)
reports that "the returned head points to `refs/heads/topic`, which may be
missing or identify a different branch" after renaming to the short branch
name `refs/heads/topic`. A repository with an existing `topic` at commit A
and a source branch at commit B reproduces the incorrect returned ref on
both backends.
Compute the destination by prepending `refs/heads/` to the literal name
passed to `git branch`. Validate that same destination and retain it only
after Git successfully renames the branch. Git 2.54.0's
`builtin/branch.c::copy_or_rename_branch()` uses `refs.c::check_branch_ref()`,
which always prepends that namespace. The general `to_full_path()` helper
continues to normalize already-qualified references for its other callers.
The SHA-1/SHA-256 regressions fail before this fix and pass afterwards.
They check the returned path, name and commit, current `HEAD`, and that the
original `topic` still points to commit A. All 50 reference tests and 24
subtests pass on each backend, including ordinary and forced renames.
Ruff, ShellCheck, mypy and basedpyright pass.1 parent 88958c9 commit 265a951
3 files changed
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| 255 | + | |
255 | 256 | | |
256 | | - | |
| 257 | + | |
257 | 258 | | |
258 | | - | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
95 | 112 | | |
96 | 113 | | |
97 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
0 commit comments