legit
legit copied to clipboard
Switch fails to unstash for branch names with a forward slash
This has caused some issues for me in the past, and could cause you to lose work. To recreate:
- Create a branch with a forward slash in it (ie. "tasks/task-123").
- Make a change on that branch
- "legit switch" to another branch, then switch back to the original branch
- Notice that the stash has not been retrieved
I've been able to recreate on prior versions, as well as 1.2.0.post0.
This appears to be due to legit relying on the default git stash message's prefix ("On <branchname") which seems to truncate the branch name at the slash. It may be better if legit also adds the branch name in the message, and checks that when changing branches. When I have time, I'll work this up and perhaps create a PR.
I tried to reproduce this bug in GitHub Codespace (Ubuntu, git 2.42.0) but I failed (stashed edits restored).
This appears to be due to legit relying on the default git stash message's prefix ("On <branchname") which seems to truncate the branch name at the slash.
The branch name is not truncated under git 2.42.0:
Saved working directory and index state On tasks/task-123: Legit: stashing before switching branches.
Close it for now. If anyone can reproduce this bug, please comment (please provide legit version, git version, and os info).