some1and2
some1and2

Reputation: 149

How to limit fetched object size in git2 in rust

I'm writing a program to do things with git. I need to have a way of limiting the size of cloned objects. I know you can do this using git clone through the cli using some kind of git clone --filter={some rules etc} but I can't seem to work out how to do this using git2 for rust.

Here is some example code to approximate how I'm cloning things:

let mut callbacks = RemoteCallbacks::new();

let mut fo = git2::FetchOptions::new();
fo.remote_callbacks(callbacks);

let mut builder = git2::build::RepoBuilder::new();
builder.fetch_options(fo);

let repo = builder.clone(some_url, some_path).unwrap();

I have a suspicion that it has something to do with adding a custom header into the fetch options but the docs aren't clear enough for me to understand how to do this. The docs in question.

The functionality I'm trying to create is only pulling objects from a remote under some size using some kind of fetch filter like this one. Something like --filter=blob:limit=1024.

I hope this question is clear enough.

Cheers.

Upvotes: 1

Views: 56

Answers (1)

Masklinn
Masklinn

Reputation: 42302

git2-rs is just a thin layer over libgit2, and given https://github.com/libgit2/libgit2/issues/5564 I think libgit2 simply does not support this feature.

Upvotes: 1

Related Questions