Skip to content

Commit e1af444

Browse files
authored
Merge pull request #2896 from shuvamk/fix/merge-base-peel-tag
fix: peel revspecs to a commit in `gix merge-base`
2 parents aa3b006 + 17ccf15 commit e1af444

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

gitoxide-core/src/repository/merge_base.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ pub fn merge_base(
1313
bail!("Only 'human' format is currently supported");
1414
}
1515
repo.object_cache_size_if_unset(50 * 1024 * 1024);
16-
let first_id = repo.rev_parse_single(first.as_str())?;
16+
let first_id = commit_id(&repo, first.as_str())?;
1717
let other_ids: Vec<_> = others
1818
.iter()
19-
.map(|other| repo.rev_parse_single(other.as_str()).map(gix::Id::detach))
19+
.map(|other| commit_id(&repo, other.as_str()))
2020
.collect::<Result<_, _>>()?;
2121

2222
let cache = repo.commit_graph_if_enabled()?;
@@ -30,3 +30,7 @@ pub fn merge_base(
3030
}
3131
Ok(())
3232
}
33+
34+
fn commit_id(repo: &gix::Repository, revspec: &str) -> anyhow::Result<gix::ObjectId> {
35+
Ok(repo.rev_parse_single(revspec)?.object()?.peel_to_commit()?.id)
36+
}

0 commit comments

Comments
 (0)