git2-rs
git2-rs copied to clipboard
When cloning with `RepoBuilder`, specifying branch makes repository bare
I found a strange behavior in 0.13, not in the latest version 0.14. Since I couldn't find the CHANGELOG, I was not sure that the following bug was fixed intentionally, so I'm submitting an issue.
Here is a code that clones a remote repository on https using RepoBuilder.
use std::path::PathBuf;
use git2::{build::RepoBuilder};
fn main() {
let mut builder = RepoBuilder::new();
builder.branch("my-branch"); // <- this line
let res = builder.clone("https://github.com/username/repo-name.git", &PathBuf::from("/tmp/x"));
println!("{:?}", res.is_ok());
}
Without specifying builder (without "this line"), the repository is cloned normally (/tmp/x/ contains .git and the contents of the main branch). However, if the branch is specified (with "this line"), the behavior is as if git clone --bare was run: /tmp/x/ contains:
FETCH_HEAD HEAD config description hooks/ info/ objects/ refs/
Why specifying the branch makes repository bare? Is it a bug?
It seems I have libgit2 1.4.2 installed on the system. This behavior was confirmed only in 0.13.25; for 0.14.2, it didn't happen.