Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: understanding remote-helper/src/fetch.rs
Fintan Halpenny committed 7 months ago
commit 9e1c2218867d751df2469eb369ad50c67abf7555
parent 23af45497577babeddd88ad2f6b496ff9acbb008
3 files changed +6 -10
modified crates/radicle-remote-helper/src/fetch.rs
@@ -1,5 +1,4 @@
use std::io;
-
use std::path::Path;
use std::str::FromStr;

use thiserror::Error;
@@ -28,7 +27,6 @@ pub enum Error {
/// Run a git fetch command.
pub fn run<R: ReadRepository>(
    mut refs: Vec<(git::Oid, git::RefString)>,
-
    working: &Path,
    stored: R,
    stdin: &io::Stdin,
    verbosity: Verbosity,
@@ -63,6 +61,9 @@ pub fn run<R: ReadRepository>(
    // used in the working copy, this will always result in the object
    // missing. This seems to only be an issue with `libgit2`/`git2`
    // and not `git` itself.
+
    /// REVIEW(finto): It's not immediately obvious to me why not passing in the
+
    /// working copy works here. And in fact it's not used, which is fixed in
+
    /// the next change. I'm going to do that in this commit :)
    git::process::fetch_local(None, &stored, oids, verbosity.into())?;

    // Nb. An empty line means we're done.
modified crates/radicle-remote-helper/src/main.rs
@@ -238,14 +238,7 @@ pub fn run(profile: radicle::Profile) -> Result<(), Error> {
                let oid = git::Oid::from_str(oid)?;
                let refstr = git::RefString::try_from(*refstr)?;

-
                // N.b. `working` is the `.git` folder and `fetch::run`
-
                // requires the working directory.
-
                let working = dunce::canonicalize(working.map_err(|_| Error::NoGitDir)?)?;
-
                let working = working.parent().ok_or_else(|| Error::NoWorkingCopy {
-
                    path: working.clone(),
-
                })?;
-

-
                return fetch::run(vec![(oid, refstr)], working, stored, &stdin, opts.verbosity)
+
                return fetch::run(vec![(oid, refstr)], stored, &stdin, opts.verbosity)
                    .map_err(Error::from);
            }
            ["push", refspec] => {
modified crates/radicle-remote-helper/src/push.rs
@@ -889,6 +889,8 @@ fn push_ref(
    // Nb. The *force* indicator (`+`) is processed by Git tooling before we even reach this code.
    // This happens during the `list for-push` phase.
    let refspec = git::Refspec { src, dst, force };
+
    /// REVIEW(finto): this isn't used in this commit, but I suppose that's
+
    /// fixed in another commit?
    let repo = working.workdir().unwrap_or_else(|| working.path());

    let mut args = vec![