Skip to content

fix: stop truncating local branch names containing '/' - #147

Merged
devlint merged 2 commits into
mainfrom
fix/137-branch-slash-truncation
Aug 10, 2026
Merged

fix: stop truncating local branch names containing '/'#147
devlint merged 2 commits into
mainfrom
fix/137-branch-slash-truncation

Conversation

@devlint

@devlint devlint commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • dagLayout.ts's parseRefs() classified any slash-containing ref decoration as type: "remote", assuming shape <remote>/<branch>. A local branch like test/some_experiment, once switched away from, decorates identically (no HEAD -> prefix) and got misclassified the same way.
  • CommitGraph.vue's commitRefs() only corrected the type when it found a match in props.branches; an empty/stale list (e.g. right after a repo/tab switch) let the wrong "remote" type through.
  • Two call sites then stripped everything before the first /, assuming a remote prefix — truncating test/some_experiment to some_experiment on checkout and delete.

Fix: parseRefs() now tags such refs as a new neutral "ambiguous" type instead of guessing "remote". commitRefs() is the sole authority resolving "ambiguous" against the ground-truth branch list, defaulting to "branch" (not "remote") when unmatched. The checkout/delete code paths now only strip the remote prefix once type === "remote" has been positively confirmed.

Test plan

  • New dagLayout.test.ts: 6/6 pass
  • New CommitGraph.branchSlash.test.ts: 5/5 pass, including explicit regression coverage that origin/main and tags still classify correctly
  • Full desktop suite: 662/662 pass across 86 files

Fixes #137

Laurent Guitton added 2 commits August 10, 2026 14:57
Commit Tree's ref classification assumed any decoration containing '/'
was a remote-tracking ref (<remote>/<branch>), which also matches a
local branch's own name once it's no longer checked out (e.g.
`test/some_experiment` decorates as the bare name, no `HEAD -> `
prefix). Two context-menu actions then stripped everything up to the
first '/', truncating the branch to `some_experiment` for both
checkout and delete.

- dagLayout.ts's parseRefs() no longer guesses "remote" from '/' alone;
  it tags such refs "ambiguous" instead.
- CommitGraph.vue's commitRefs() is now the sole authority that
  resolves "ambiguous" against the real branch list, defaulting to
  "branch" (not "remote") when no match is found — the actual bug
  scenario, since props.branches can be empty/stale right after a
  repo/tab switch.
- Replaced the remaining ad-hoc `indexOf('/')` slicing in the checkout
  context-menu handler with a single computed derived from the
  now-trustworthy classification, and documented why the equivalent
  slicing in branchToDelete's confirmed-remote branch stays safe.

Added regression tests for parseRefs() and for CommitGraph's checkout/
delete emit paths with a slash-named local branch, plus coverage
confirming origin/main and tags still classify correctly.
# Conflicts:
#	CHANGELOG.md
@devlint
devlint merged commit b92cc19 into main Aug 10, 2026
3 checks passed
@devlint
devlint deleted the fix/137-branch-slash-truncation branch August 10, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot checkout or delete local branch with '/' in its name

1 participant