libgit2 icon indicating copy to clipboard operation
libgit2 copied to clipboard

git_submodule_update should call git_clone__submodule instead of git_clone to omit the path check

Open lrm29 opened this issue 3 years ago • 1 comments

Reproduction steps

  1. Create a repository that has a submodule called "mysubmodule".
  2. Change directory to a folder which has a subfolder called "mysubmodule".
  3. Clone the main repository and then call git_submodule_update on "mysubmodule".

Expected behavior

The submodule is initialised and cloned.

Actual behavior

Unable to clone the submodule with error: Error code = -4, Error class = 3. "mysubmodule" exists and is not an empty directory.

The path check in git__clone checks the current directory, rather than the repository working directory. If omitting the path check is undesirable, perhaps there's another solution.

Version of libgit2 (release number or SHA1)

1.0.0

Operating system(s) tested

Windows

lrm29 avatar Mar 29 '21 12:03 lrm29

Ran into this issue on v1.3.0 as well

mattnite avatar Dec 31 '21 05:12 mattnite

We also ran into this issue via the cargo generate tool which uses libgit2 as its dependency.

As I see it in git_submodule_update the submodule is cloned only if it is uninitialized. As a result it seems safe to use git_clone__submodule instead of git_clone here https://github.com/libgit2/libgit2/blob/936b184e7494158c20e522981f4a324cac6ffa47/src/libgit2/submodule.c#L1396

abizjak avatar Jan 05 '23 20:01 abizjak