libgit2 / git2go

Git to Go; bindings for libgit2. Like McDonald's but tastier.
MIT License
1.92k stars 316 forks source link

libgit.Clone produces empty directory, fails with `failed to stat path/to/repo/.git` #957

Closed juanique closed 8 months ago

juanique commented 9 months ago

I'm doing this:

if libgit.Features()&libgit.FeatureSSH != 0 {
    fmt.Println("libgit2 has SSH support!")
} else {
    fmt.Println("libgit2 does not have SSH support.")
}

repo, err := libgit.Clone(repoURL, localPath, &libgit.CloneOptions{})
if err != nil {
    return nil, fmt.Errorf("error cloning repository %s to %s: %w", repoURL, localPath, err)
}
defer repo.Free()

The code fails with:

libgit2 has SSH support!

error cloning repository git@github.com/juanique/bazel-examples.git to /home/juanique/ggo/bazel-examples: failed to stat '/home/juanique/ggo/bazel-examples/.git':

I see that the directory /home/juanique/ggo/bazel-examples was created and it's empty.

I don't know if it is relevant but I'm running Ubuntu with WSL2 on Windows and building my go binary using bazel with cgo for the libgit2 dependency.

I'm using git2go@v33

juanique commented 8 months ago

It turns out the issue is because I'm using the zig C toolchain and I'm hitting this bug: https://github.com/ziglang/zig/issues/11878