git branch rename does not catch bad name
Submitted by lil..@..ot.org
Link to original bug (#794514)
Description
Bug
Rename a branch to have a dir with the same name as an existing branch name, will remove the branch and make the commits undiscoverable (I could not find them at least).
e.g.
$ git branch
branch/lvl1
- branch/lvl1-lvl2
+ branch/lvl1/lvl2
* master
test/me/foo
Will give you this message:
**Failed to rename**
Could not remove directory. File '/home/lil5/Desktop/gitg-test/.git/refs/heads/branch/lvl1/lvl2' parent is not directory: Not a directory
Steps to reproduce:
- Create git repo
git init
echo "# $( basename $( pwd ) )\n" > readme.md
git add readme.md
git commit -m 'Initial commit'
- Branch once with
/
in name
git checkout -b branch/lvl1
- Branch again with one
/
in name
git checkout -b branch/lvl1-lvl2
- In gitg rename
branch/lvl1-lvl2
tobranch/lvl1/lvl2
.
Version: 3.26.x