From 885f4999dad83a9ca290567a2cbcecfa8ba64ee8 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Sun, 6 Aug 2023 17:29:21 +0200 Subject: [PATCH] remote-helper: Fix refs advertisement for patches Some of the old patches had missing objects and that causes problems during the ref advertisement, as the object is not found. In this patch, we check that the object exists and also that the patch is still open. Otherwise a remote tracking branch is created for every single patch ref. --- radicle-cli/examples/workflow/6-pulling-contributor.md | 1 - radicle-remote-helper/src/list.rs | 6 +++++- radicle/src/storage.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/radicle-cli/examples/workflow/6-pulling-contributor.md b/radicle-cli/examples/workflow/6-pulling-contributor.md index e60b07a9..486e2e20 100644 --- a/radicle-cli/examples/workflow/6-pulling-contributor.md +++ b/radicle-cli/examples/workflow/6-pulling-contributor.md @@ -23,7 +23,6 @@ Your branch is up to date with 'rad/master'. $ git pull --all --ff From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji f2de534..f567f69 master -> rad/master - 27857ec..f567f69 patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c -> rad/patches/50e29a111972f3b7d2123c5057de5bdf09bc7b1c From rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi f2de534..f567f69 master -> alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master ``` diff --git a/radicle-remote-helper/src/list.rs b/radicle-remote-helper/src/list.rs index 52c3bfbd..dcb265e3 100644 --- a/radicle-remote-helper/src/list.rs +++ b/radicle-remote-helper/src/list.rs @@ -72,7 +72,11 @@ fn patch_refs(stored: &R) -> Result<(), Error> { let patches = radicle::cob::patch::Patches::open(stored)?; for patch in patches.all()? { let (id, patch) = patch?; - println!("{} {}", patch.head(), git::refs::storage::patch(&id)); + let head = patch.head(); + + if patch.is_open() && stored.commit(*head).is_ok() { + println!("{} {}", patch.head(), git::refs::storage::patch(&id)); + } } Ok(()) } diff --git a/radicle/src/storage.rs b/radicle/src/storage.rs index 14d973f0..d96757a2 100644 --- a/radicle/src/storage.rs +++ b/radicle/src/storage.rs @@ -391,7 +391,7 @@ pub trait ReadRepository: Sized { /// Get the [`git2::Commit`] found using its `oid`. /// - /// Returns `None` if the commit did not exist. + /// Returns `Err` if the commit did not exist. fn commit(&self, oid: Oid) -> Result; /// Perform a revision walk of a commit history starting from the given head.