10000 Use `git_clone__submodule` to avoid file checks in workdir by abizjak · Pull Request #6444 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Use git_clone__submodule to avoid file checks in workdir #6444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use git_clone__submodule to avoid file checks in workdir
`git_clone` checks for existence of (non-empty) directories that would clash with what is about to be cloned.

This is problematic when cloning submodules since they make sense in the context of a parent module, so they should not use the current working dir.

Since in `git_submodule_update` we clone the submodule only when it is not yet initialized we do not need to perform directory checks.
  • Loading branch information
abizjak authored Jan 5, 2023
commit ae7a0a63658305560e5ee3463fda857d8f13e6b3
2 changes: 1 addition & 1 deletion src/libgit2/submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
*/
clone_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;

if ((error = git_clone(&sub_repo, submodule_url, sm->path, &clone_options)) < 0 ||
if ((error = git_clone__submodule(&sub_repo, submodule_url, sm->path, &clone_options)) < 0 ||
(error = git_repository_set_head_detached(sub_repo, git_submodule_index_id(sm))) < 0 ||
(error = git_checkout_head(sub_repo, &update_options.checkout_opts)) != 0)
goto done;
Expand Down
0