Is it actually possible to do a shallow clone of a specific commit? #2309
-
|
I'm currently trying to replace a "git" subprocess call with something equivalent from The git command I'm trying to replace is: Based on the use gix::create::{Kind as CreateKind, Options as CreateOptions};
use gix::clone::PrepareFetch;
use gix::open::Options as OpenOptions;
use gix::progress::Discard;
use gix::remote::fetch::Shallow;
async fn gix_clone(url: String, sha1: String) -> Result<TempDir, Error> {
let out = TempDir::new()?;
let path = out.path().to_string_lossy();
let path_str = path.to_string();
tokio::task::spawn_blocking(|| -> Result<(), Error> {
let mut pf = PrepareFetch::new(
url,
path_str,
CreateKind::WithWorktree,
CreateOptions::default(),
OpenOptions::default(),
)
.unwrap()
.with_shallow(Shallow::DepthAtRemote(NonZero::<u32>::MIN))
.with_ref_name(Some(sha1).as_ref()).unwrap();
pf.fetch_only(Discard, &AtomicBool::new(false)).unwrap();
pf.persist();
Ok(())
}).await.unwrap()?;
Ok(out)
}However, this doesn't work. The documentation for
But this does not seem to be true - I get a panic from inside gix with the following
I have no idea what this error is supposed to tell me. The thing I'm passing to So ... is this a bug? Is the documentation wrong? Or am I just not doing this correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Thanks for reaching out, and sorry for the hassle! As a general note, if this is in any way supposed to land in something that is deployed OS-wide, i.e. would see every repository under the sun, then That aside, A way to fix this would be to add a test for that, and then look at the server data to make it work. Finally, the But there is clearly no simple solution to it, but let's see if Copilot can get a fix started. |
Beta Was this translation helpful? Give feedback.
Glad I could help!
And thanks for offering! I'd love a PR that documents the panic for now instead of an issue, which should be about the same amount of effort for you while being an instant improvement that can eventually be fixed.
Besides that, here is a chance that this PR improves the situation beyond that, but I didn't take a look yet.