Web lists-archives.com

git subtree merge deletes files in top directory




Hi,

I'm trying to add a subtree which contains a folder with the same name
as the subtree directory itself.
Adding seems to work, but if i pull after the subtree remote changed,
files in my top directory are deleted and everything seems to have
"moved up" one directory - although i specify a subtree directory with "-P"

For example i start with top repository that contains one file:

.
└── topfile

Now i try to add another repository as a subtree which looks like this:

.
├── afile
└── subrep
    └── anotherfile

Running `git subtree add -P subrep origin_subrep master --squash` on the
top repository produces correctly

.
├── subrep
│   ├── afile
│   └── subrep
│       └── anotherfile
└── topfile

Now i change the subrep git by just adding files

.
├── afile
├── bfile
└── subrep
    ├── anotherfile
    └── yetanotherfile

When i try to merge these into the top repository by `git subtree pull
-P subrep origin_subrep master --squash` i get

[...]
Removing topfile
Removing subrep/subrep/anotherfile
Removing subrep/afile
Merge made by the 'recursive' strategy.
 subrep/subrep/anotherfile => anotherfile | 0
 subrep/afile                             | 0
 topfile => yetanotherfile                | 0
 3 files changed, 0 insertions(+), 0 deletions(-)
 rename subrep/subrep/anotherfile => anotherfile (100%)
 delete mode 100644 subrep/afile
 rename topfile => yetanotherfile (100%)

And my top repository looks like

.
├── anotherfile
└── yetanotherfile

The issue seems to be related to the subdirectory "subrep" of my
repository "surep" having the same name - if i rename it to something
else everything works as expected.

I could reproduce this behaviour in git 2.12.0 and the current next
branch (v2.13.0-303-g4ebf30216)

Thanks,
Nikolai