When cloning with `RepoBuilder`, specifying branch makes repository bare
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 450
- Avg merge
- 11m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided RepoBuilder::branch and clone example with git2-rs 0.13.25, then compare its behavior with 0.14.2 and the installed libgit2 1.4.2. Inspect the RepoBuilder branch and clone entry points; done means determining whether the bare repository result is an unintended version-specific bug or an intentional change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100