Fetch receiving 0 bytes

オープン
#1,183 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
git, rust
領域
devtools

調査の方向性

まず、表示されている remote.fetch 呼び出しを、リポジトリの fetch および pull のコード例と比較します。次に、報告された remote.stats の値と、remote-tracking 参照が変更されるかどうかを確認します。取得されたリモートコミットがローカルリポジトリに現れ、その後の fast-forward が空の結果ではなくそれらを使用すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Rust
スター
2.1k
フォーク
470
平均マージ
2日 17時間
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-lang/git2-rs のほかの issue

rust-lang/git2-rs の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。