Skip to content

crate_git_repository: recurse submodules to match Cargo#114

Closed
walter-zeromatter wants to merge 1 commit into
hermeticbuild:mainfrom
walter-zeromatter:user/wgray/clone-submodule
Closed

crate_git_repository: recurse submodules to match Cargo#114
walter-zeromatter wants to merge 1 commit into
hermeticbuild:mainfrom
walter-zeromatter:user/wgray/clone-submodule

Conversation

@walter-zeromatter
Copy link
Copy Markdown
Contributor

Cargo always recursively checks out submodules for git dependencies, so a crate whose source uses submodules (e.g. khronos_api in rust-windowing/gl-rs, which vendors KhronosGroup/WebGL via submodule for the WebGL extensions registry) builds cleanly under Cargo but produces empty source trees here. The previous implementation only ran git worktree add, which does not populate submodules.

Run git submodule update --init --recursive after the worktree is created when a .gitmodules file is present. To preserve repository reproducibility, also remove the per-submodule .git gitlink files (which contain machine-specific absolute paths into the cache repo's modules dir) at the end of the rule, alongside the existing top-level .git removal.

Cargo always recursively checks out submodules for git dependencies, so a
crate whose source uses submodules (e.g. khronos_api in rust-windowing/gl-rs,
which vendors KhronosGroup/WebGL via submodule for the WebGL extensions
registry) builds cleanly under Cargo but produces empty source trees here.
The previous implementation only ran `git worktree add`, which does not
populate submodules.

Run `git submodule update --init --recursive` after the worktree is created
when a `.gitmodules` file is present. To preserve repository reproducibility,
also remove the per-submodule `.git` gitlink files (which contain
machine-specific absolute paths into the cache repo's modules dir) at the
end of the rule, alongside the existing top-level `.git` removal.
@dzbarsky
Copy link
Copy Markdown
Member

dzbarsky commented May 2, 2026

Sorry #113 is gonna conflict with you pretty badly :(

@dzbarsky
Copy link
Copy Markdown
Member

dzbarsky commented May 2, 2026

Oh actually I think #113 incidentally fixed this, see

"recursive_init_submodules": attr.bool(default = True),
. Can you double check?

@walter-zeromatter
Copy link
Copy Markdown
Contributor Author

yep, that fixes it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants