Skip to content

Commit 649f588

Browse files
authored
Merge pull request #1557 from Byron/merge-base
initial merge-base support
2 parents ec0d03a + 18c2fc4 commit 649f588

File tree

247 files changed

+939
-595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+939
-595
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,4 @@ borrow_as_ptr = "allow" # x2
389389
unnecessary_join = "allow" # x1
390390
stable_sort_primitive = "allow" # x1
391391
no_effect_underscore_binding = "allow" # x1
392+
empty_docs = "allow"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use crate::OutputFormat;
2+
use anyhow::bail;
3+
4+
pub fn merge_base(
5+
mut repo: gix::Repository,
6+
first: String,
7+
others: Vec<String>,
8+
mut out: impl std::io::Write,
9+
format: OutputFormat,
10+
) -> anyhow::Result<()> {
11+
if format != OutputFormat::Human {
12+
bail!("Only 'human' format is currently supported");
13+
}
14+
repo.object_cache_size_if_unset(50 * 1024 * 1024);
15+
let first_id = repo.rev_parse_single(first.as_str())?;
16+
let other_ids: Vec<_> = others
17+
.iter()
18+
.cloned()
19+
.map(|other| repo.rev_parse_single(other.as_str()).map(gix::Id::detach))
20+
.collect::<Result<_, _>>()?;
21+
22+
let cache = repo.commit_graph_if_enabled()?;
23+
let bases = repo.merge_bases_many_with_cache(first_id, &other_ids, cache.as_ref())?;
24+
if bases.is_empty() {
25+
bail!("No base found for {first} and {others}", others = others.join(", "))
26+
}
27+
for id in bases {
28+
writeln!(&mut out, "{id}")?;
29+
}
30+
Ok(())
31+
}

gitoxide-core/src/repository/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ mod fsck;
4444
pub use fsck::function as fsck;
4545
pub mod index;
4646
pub mod mailmap;
47+
mod merge_base;
48+
pub use merge_base::merge_base;
4749
pub mod odb;
4850
pub mod remote;
4951
pub mod revision;

gix-actor/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use gix_date::Time;
2222

2323
mod identity;
2424
///
25-
#[allow(clippy::empty_docs)]
2625
pub mod signature;
2726

2827
/// A person with name and email.

gix-actor/src/signature/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,5 @@ pub(crate) mod write {
129129
}
130130

131131
///
132-
#[allow(clippy::empty_docs)]
133132
pub mod decode;
134133
pub use decode::function::decode;

gix-attributes/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ use kstring::{KString, KStringRef};
1414

1515
mod assignment;
1616
///
17-
#[allow(clippy::empty_docs)]
1817
pub mod name;
1918
///
20-
#[allow(clippy::empty_docs)]
2119
pub mod state;
2220

2321
///
24-
#[allow(clippy::empty_docs)]
2522
pub mod search;
2623

2724
///
28-
#[allow(clippy::empty_docs)]
2925
pub mod parse;
3026

3127
/// Parse attribute assignments line by line from `bytes`, and fail the operation on error.

gix-bitmap/src/ewah.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
///
2-
#[allow(clippy::empty_docs)]
32
pub mod decode {
43
/// The error returned by [`decode()`][super::decode()].
54
#[derive(Debug, thiserror::Error)]

gix-chunk/src/file/index.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::Range;
33
use crate::file::Index;
44

55
///
6-
#[allow(clippy::empty_docs)]
76
pub mod offset_by_kind {
87
use std::fmt::{Display, Formatter};
98

@@ -28,7 +27,6 @@ pub mod offset_by_kind {
2827
}
2928

3029
///
31-
#[allow(clippy::empty_docs)]
3230
pub mod data_by_kind {
3331
/// The error returned by [`Index::data_by_id()`][super::Index::data_by_id()].
3432
#[derive(Debug, thiserror::Error)]

gix-chunk/src/file/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
///
2-
#[allow(clippy::empty_docs)]
32
pub mod decode;
43
///
5-
#[allow(clippy::empty_docs)]
64
pub mod index;
75

86
///
9-
#[allow(clippy::empty_docs)]
107
pub mod write;
118

129
/// The offset to a chunk as seen relative to the beginning of the file containing it.

0 commit comments

Comments
 (0)