Fetch receiving 0 bytes

Aperta
#1,183 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
git, rust
Ambito
devtools

Direzione di ricerca

Inizia confrontando la chiamata remote.fetch mostrata con gli esempi di codice fetch e pull del repository, quindi esamina i valori remote.stats riportati e verifica se il riferimento remote-tracking cambia. Il lavoro è completato quando i commit remoti recuperati compaiono nel repository locale e il fast-forward successivo li utilizza invece di produrre un risultato vuoto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?

Lingua principale
Rust
Stelle
2.1k
Fork
470
Merge medio
2g 17h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/git2-rs

Tutte le issue di rust-lang/git2-rs

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.