fabacab / git-archive-all.sh

A bash shell script wrapper for git-archive that archives a git superproject and its submodules, if it has any.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with submodules that have overlapping names.

kdar opened this issue · comments

If you have two submodules in the same directory that have overlapping names, git-archive-all.sh fails to grab one.

E.g.
libs/test
libs/testing

To fix this, change line #157 from
TREEISH=$(git submodule | grep "^ .${path%/}" | cut -d ' ' -f 2) # git submodule does not list trailing slashes in $path
to
TREEISH=$(git submodule | grep "^ .
${path%/} " | cut -d ' ' -f 2) # git submodule does not list trailing slashes in $path

All I am doing is adding a space inside the grep after }.

I tried replicating this but failed to do so. I had a superproject ("tests") in which I created four submodules, two groups of overlapping names. The tarfile which git-archive-all.sh created included all the files:

Perseus:tests maymay$ ls
file libs mod1 mod2
Perseus:tests maymay$ git-archive-all.sh
Perseus:tests maymay$ ls
file      libs      mod1      mod2      tests.tar
Perseus:tests maymay$ tar -tf tests.tar 
.gitmodules
file
mod1/
mod2/
libs/test/
libs/test/hello
libs/testing/
libs/testing/world
mod1/
mod1/file
mod2/
mod2/file

Perhaps I am incorrectly replicating your situation, though. Can you point me at a git repository in which git-archive-all.sh exhibits this behavior? Thanks.

I just made a test repository. Using your current git-archive-all, this is my output of tar:

.gitmodules
a.txt
ext/
exthelper/
exthelperson/
exthelper/
ext/
exthelperson/
exthelperson/a.txt

When using my fix, this is what I get:

.gitmodules
a.txt
ext/
exthelper/
exthelperson/
exthelper/
exthelper/a.txt
ext/
ext/a.txt
exthelperson/
exthelperson/a.txt

Which is correct. I have uploaded my test git repository here: http://outroot.com/stuff/gitaa.tar

What I did was, make a bare git repository called super-bare. Cloned it to super. Made the ext, exthelper, and exthelperson git repositories. Added them to the super project, in that order (the order may matter, I don't know if I added them in the reverse order if the same problem would occur). Then I ran your script.

Hopefully you get the same results as me.

Thanks for the details. Somehow I still couldn't replicate the situation on my own but I did see the issue occur in the repository you linked me to. However, I was able to find other evidence of the bug, which I've described in SHA: 8ed8828. Thanks again for your help with this issue!