cli: Fix rad patch show with merged patches

We were not correctly calculating the base commit. Simply
using the latest revision base does the job for now.
This commit is contained in:
Alexis Sellier
2023-05-15 12:22:09 +02:00
parent a9c0152a99
commit f72b448114
2 changed files with 11 additions and 3 deletions
+1 -3
View File
@@ -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<Vec<term::Line>> {
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();
+10
View File
@@ -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