diff --git a/radicle-cli/src/commands/patch/show.rs b/radicle-cli/src/commands/patch/show.rs index 494d0037..8e00b5e8 100644 --- a/radicle-cli/src/commands/patch/show.rs +++ b/radicle-cli/src/commands/patch/show.rs @@ -30,9 +30,7 @@ fn show_patch_diff(patch: &patch::Patch, storage: &Repository) -> anyhow::Result } fn patch_commits(patch: &patch::Patch, stored: &Repository) -> anyhow::Result> { - let target_head = patch_merge_target_oid(patch.target(), stored)?; - let base_oid = stored.raw().merge_base(target_head, **patch.head())?; - let range = format!("{}..{}", base_oid, patch.head()); + let range = format!("{}..{}", patch.base(), patch.head()); let mut revwalk = stored.revwalk(*patch.head())?; let mut lines = Vec::new(); diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 6637d942..2cddf6be 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -262,6 +262,16 @@ impl Patch { .oid } + /// Get the commit of the target branch on which this patch is based. + /// This can change via a patch update. + pub fn base(&self) -> &git::Oid { + &self + .latest() + .map(|(_, r)| r) + .expect("Patch::base: at least one revision is present") + .base + } + /// Index of latest revision in the revisions list. pub fn version(&self) -> RevisionIx { self.revisions