Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
remote-helper: Fix refs advertisement for patches
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cloudhead committed Aug 6, 2023
1 parent 0974a4a commit 885f499
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion radicle-cli/examples/workflow/6-pulling-contributor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
6 changes: 5 additions & 1 deletion radicle-remote-helper/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ fn patch_refs<R: ReadRepository + cob::Store>(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(())
}
2 changes: 1 addition & 1 deletion radicle/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<git2::Commit, git::ext::Error>;

/// Perform a revision walk of a commit history starting from the given head.
Expand Down

0 comments on commit 885f499

Please sign in to comment.