-
Notifications
You must be signed in to change notification settings - Fork 427
Open
Description
I'm attempting to implement pull from a remote repo, based on the fetch and pull code examples in the repo. The relevant chunk of code is as follows:
match Repository::open(&repo_path_string) {
Ok(repo) => {
let remote_name = "origin";
let remote_branch = "master";
let mut remote = repo
.find_remote(remote_name)
.expect("could not find remote");
let mut fo = git2::FetchOptions::new();
fo.download_tags(git2::AutotagOption::All);
match remote.fetch(&[remote_branch], Some(&mut fo), None) {
Ok(_) => {
let stats = remote.stats();
if stats.local_objects() > 0 {
println!(
"\rReceived {}/{} objects in {} bytes (used {} local \
objects)",
stats.indexed_objects(),
stats.total_objects(),
stats.received_bytes(),
stats.local_objects()
);
} else {
println!(
"\rReceived {}/{} objects in {} bytes",
stats.indexed_objects(),
stats.total_objects(),
stats.received_bytes()
);
}
}
Err(e) => {
return not_ok_json_response(
Status::InternalServerError,
make_bad_json_data_response(
format!("could not fetch repo: {}", e).to_string(),
),
)
}
};
...
This code compiles and runs but the remote commits do not appear in the local repo (master or remotes/origin/master - there's a subsequent fast-forward merge which succeeds but is presumably chewing on nothing).
On the console I see
Received 4/4 objects in 0 bytes (used 2 local objects)
The 0 bytes seems suspicious. git pull
retrieves the commits as expected.
What am I missing?
Metadata
Metadata
Assignees
Labels
No labels