Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: can move `Oid` equality check earlier
◌ CI pending Fintan Halpenny committed 7 months ago
commit dce48c1828703196692ac521744796bb450be75e
parent 243f88c679284e925cb1b1104b828e3e8c222b6a
1 pending (1 total) View logs
1 file changed +10 -10
modified crates/radicle-fetch/src/git/repository.rs
@@ -169,6 +169,16 @@ fn direct<'a>(
        });
    };

+
    if prev == *target {
+
        // If the two objects are identical, their ancestry does not matter,
+
        // we can always skip the update.
+
        return Ok(RefUpdate::Skipped {
+
            name: name.to_ref_string(),
+
            oid: target,
+
        }
+
        .into());
+
    }
+

    let ancestry = {
        use git::raw::ObjectType::{self, *};
        const ANY_KIND: Option<ObjectType> = Some(Any);
@@ -185,16 +195,6 @@ fn direct<'a>(
            .find_object(*target, ANY_KIND)
            .map_err(|err| error::Update::Ancestry(error::Ancestry::Object { oid: target, err }))?;

-
        if prev.id() == target.id() {
-
            // If the two objects are identical, their ancestry does not matter,
-
            // we can always skip the update.
-
            return Ok(RefUpdate::Skipped {
-
                name: name.to_ref_string(),
-
                oid: target.id().into(),
-
            }
-
            .into());
-
        }
-

        match (prev.kind(), target.kind()) {
            (Some(Commit), Some(Commit)) => {
                // This is the common case, we have two commits to compare.