Fetch receiving 0 bytes

Đang mở
#1,183 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
git, rust
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng cách so sánh lệnh gọi remote.fetch được hiển thị với các ví dụ mã fetch và pull của repository, sau đó kiểm tra các giá trị remote.stats được báo cáo và xem tham chiếu remote-tracking có thay đổi hay không. Được coi là hoàn tất khi các commit remote đã fetch xuất hiện trong repository cục bộ và fast-forward tiếp theo sử dụng chúng thay vì cho ra kết quả rỗng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Rust
Star
2.1k
Fork
470
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/git2-rs

Tất cả issue của rust-lang/git2-rs

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.