Git::Raw::Tree::Builder doesn't allow for COMMIT (submodule) entry type
thebamaman opened this issue · 4 comments
Here's an example from an existing repo I have:
> git cat-file -p b2c63b31b59ef9f638b62b90ccccd370eedf64be
100644 blob e3def7f930f98b83d11654eaf4a10db19896f25e .gitmodules
160000 commit b79b2fcd76dbab3a4eceae494384ed96f7b0cb42 build
160000 commit f3a5e961e95b9b3ba877aa4193f28ad0b1e39922 build:codesearch-gitlink-overlay
160000 commit 7be5101e9f344ea2b0b96f648d377c31199fe6fe infra
160000 commit 41ebd3375422d4274e885410434c88864181b7a4 infra:codesearch-gitlink-overlay
160000 commit b324e0140b97c11b7fe580336c050d6e2afce169 src
160000 commit b740576619c47566a6ef124002d54fcdf4804c78 src:codesearch-gitlink-overlay
040000 tree 101e2616c4955fdd60a28c6a9cbbd9f709ce97b9 tools
While trying to recreate this using Git::Raw::Tree::Builder, I encountered an error since I can't lookup the submodule commits since they exist in another git repo. Looking in xs/Tree/Builder.xs (and the documentation), the insert function can only accept blobs or trees.
I can try to figure out how to modify xs/Tree/Builder.xs to be able to accept these submodule ids, but would need to know how exactly you would prefer that to be structured?
I could change the if/else statement in the PPCODE section to an if/else if (tree)/else where the else would just assume you pass in a raw SHA-1? Doesn't quite seem as elegant, but I don't see another way since any type of submodule lookup just won't work...
I haven't played with submodules... accepting a SHA-1 is ok as the last option, but I don't think that git_treebuilder_insert
is going to be happy about an OID that doesn't exist in the repository, YMMV
For the time being, I wrote a small c program using libgit2 and the git_treebuilder_insert/write functions. They obviously care about non-existent blobs and trees, but it seems it ignores checking commits.
And sure, SHA-1 as an argument is probably less than ideal, but I'm not really sure of the best way to handle commits in trees other than that.
Also, pardon my ignorance (not too familiar with building cpan distributions), but I don't see a README on building this code if I were to make changes to the xs files prior to potentially submitting a merge request?
The steps required are contained in the .travis.yml
file:
Installing the prerequisites:
cpanm --quiet --notest Dist::Zilla~">= 5.0000, < 6.0000"
cpanm --quiet --notest Dist::Zilla::PluginBundle::Author::ALEXBIO
cpanm --quiet --notest Pod::Coverage::TrustPod
cpanm --quiet --notest Devel::Cover::Report::Coveralls
cpanm --quiet --notest Dist::Zilla::App::Command::cover
dzil authordeps --missing | cpanm --quiet --notest
dzil listdeps --missing | cpanm --quiet --notest
Testing changes:
dzil test