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

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
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"
+31
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

+2
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

-1
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

-1
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

-4
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

-1
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

-2
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

-3
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.

gix-chunk/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub type Id = [u8; 4];
1010
pub const SENTINEL: Id = [0u8; 4];
1111

1212
///
13-
#[allow(clippy::empty_docs)]
1413
pub mod range {
1514
use std::ops::Range;
1615

@@ -34,5 +33,4 @@ pub mod range {
3433
}
3534

3635
///
37-
#[allow(clippy::empty_docs)]
3836
pub mod file;

gix-command/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ pub fn extract_interpreter(executable: &Path) -> Option<shebang::Data> {
337337
}
338338

339339
///
340-
#[allow(clippy::empty_docs)]
341340
pub mod shebang {
342341
use bstr::{BStr, ByteSlice};
343342
use std::ffi::OsString;

gix-commitgraph/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub fn at(path: impl AsRef<Path>) -> Result<Graph, init::Error> {
5151
mod access;
5252
pub mod file;
5353
///
54-
#[allow(clippy::empty_docs)]
5554
pub mod init;
5655
pub mod verify;
5756

gix-config-value/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ impl Error {
3737

3838
mod boolean;
3939
///
40-
#[allow(clippy::empty_docs)]
4140
pub mod color;
4241
///
43-
#[allow(clippy::empty_docs)]
4442
pub mod integer;
4543
///
46-
#[allow(clippy::empty_docs)]
4744
pub mod path;
4845

4946
mod types;

gix-config-value/src/path.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use bstr::BStr;
55
use crate::Path;
66

77
///
8-
#[allow(clippy::empty_docs)]
98
pub mod interpolate {
109
use std::path::PathBuf;
1110

gix-config/src/file/includes/types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ impl Default for Options<'_> {
118118
}
119119

120120
///
121-
#[allow(clippy::empty_docs)]
122121
pub mod conditional {
123122
/// Options to handle conditional includes like `includeIf.<condition>.path`.
124123
#[derive(Clone, Copy, Default)]

gix-config/src/file/init/comfort.rs

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ impl File<'static> {
145145
}
146146

147147
///
148-
#[allow(clippy::empty_docs)]
149148
pub mod from_git_dir {
150149
use crate::file::init;
151150

gix-config/src/file/init/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ pub use types::{Error, Options};
1010

1111
mod comfort;
1212
///
13-
#[allow(clippy::empty_docs)]
1413
pub mod from_env;
1514
///
16-
#[allow(clippy::empty_docs)]
1715
pub mod from_paths;
1816

1917
impl<'a> File<'a> {

gix-config/src/file/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@ mod mutable;
1313
pub use mutable::{multi_value::MultiValueMut, section::SectionMut, value::ValueMut};
1414

1515
///
16-
#[allow(clippy::empty_docs)]
1716
pub mod init;
1817

1918
mod access;
2019
mod impls;
2120
///
22-
#[allow(clippy::empty_docs)]
2321
pub mod includes;
2422
mod meta;
2523
mod util;
2624

2725
///
28-
#[allow(clippy::empty_docs)]
2926
pub mod section;
3027

3128
///
32-
#[allow(clippy::empty_docs)]
3329
pub mod rename_section {
3430
/// The error returned by [`File::rename_section(…)`][crate::File::rename_section()].
3531
#[derive(Debug, thiserror::Error)]
@@ -43,7 +39,6 @@ pub mod rename_section {
4339
}
4440

4541
///
46-
#[allow(clippy::empty_docs)]
4742
pub mod set_raw_value {
4843
/// The error returned by [`File::set_raw_value(…)`][crate::File::set_raw_value()].
4944
#[derive(Debug, thiserror::Error)]

gix-config/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@
4040
pub mod file;
4141

4242
///
43-
#[allow(clippy::empty_docs)]
4443
pub mod lookup;
4544
pub mod parse;
4645
///
47-
#[allow(clippy::empty_docs)]
4846
pub mod value;
4947
pub use gix_config_value::{color, integer, path, Boolean, Color, Integer, Path};
5048

@@ -53,5 +51,4 @@ pub use key::{AsKey, KeyRef};
5351
mod types;
5452
pub use types::{File, Source};
5553
///
56-
#[allow(clippy::empty_docs)]
5754
pub mod source;

gix-config/src/lookup.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub enum Error<E> {
99
}
1010

1111
///
12-
#[allow(clippy::empty_docs)]
1312
pub mod existing {
1413
/// The error when looking up a value that doesn't exist, for example via [`File::value()`][crate::File::value()].
1514
#[derive(Debug, thiserror::Error)]

gix-config/src/parse/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub use events_type::{Events, FrontMatterEvents};
2323
mod comment;
2424
mod error;
2525
///
26-
#[allow(clippy::empty_docs)]
2726
pub mod section;
2827

2928
#[cfg(test)]

gix-config/src/parse/section/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use bstr::BStr;
55
use crate::parse::{Event, Section};
66

77
///
8-
#[allow(clippy::empty_docs)]
98
pub mod header;
109

1110
pub(crate) mod unvalidated;
@@ -49,7 +48,6 @@ mod types {
4948
macro_rules! generate_case_insensitive {
5049
($name:ident, $module:ident, $err_doc:literal, $validate:ident, $cow_inner_type:ty, $comment:literal) => {
5150
///
52-
#[allow(clippy::empty_docs)]
5351
pub mod $module {
5452
/// The error returned when `TryFrom` is invoked to create an instance.
5553
#[derive(Debug, thiserror::Error, Copy, Clone)]

gix-credentials/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ pub struct Program {
2121
}
2222

2323
///
24-
#[allow(clippy::empty_docs)]
2524
pub mod helper;
2625

2726
///
28-
#[allow(clippy::empty_docs)]
2927
pub mod program;
3028

3129
///
32-
#[allow(clippy::empty_docs)]
3330
pub mod protocol;
3431

3532
/// Call the `git credential` helper program performing the given `action`, which reads all context from the git configuration

gix-credentials/src/program/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,5 @@ impl Program {
144144
}
145145

146146
///
147-
#[allow(clippy::empty_docs)]
148147
pub mod main;
149148
pub use main::function::main;

gix-credentials/src/protocol/context/serde.rs

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ mod write {
4949
}
5050

5151
///
52-
#[allow(clippy::empty_docs)]
5352
pub mod decode {
5453
use bstr::{BString, ByteSlice};
5554

gix-credentials/src/protocol/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,4 @@ pub fn helper_outcome_to_result(outcome: Option<helper::Outcome>, action: helper
8383
}
8484

8585
///
86-
#[allow(clippy::empty_docs)]
8786
pub mod context;

gix-date/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
#![forbid(unsafe_code)]
1212

1313
///
14-
#[allow(clippy::empty_docs)]
1514
pub mod time;
1615

1716
///
18-
#[allow(clippy::empty_docs)]
1917
pub mod parse;
2018
pub use parse::function::parse;
2119

gix-date/src/time/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl From<CustomFormat> for Format {
4040
}
4141

4242
///
43-
#[allow(clippy::empty_docs)]
4443
pub mod format;
4544
mod init;
4645
mod write;

gix-diff/src/blob/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use bstr::BString;
66
pub use imara_diff::*;
77

88
///
9-
#[allow(clippy::empty_docs)]
109
pub mod pipeline;
1110

1211
///
13-
#[allow(clippy::empty_docs)]
1412
pub mod platform;
1513

1614
/// Information about the diff performed to detect similarity.

gix-diff/src/blob/pipeline.rs

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ impl Mode {
111111
}
112112

113113
///
114-
#[allow(clippy::empty_docs)]
115114
pub mod convert_to_diffable {
116115
use std::collections::TryReserveError;
117116

gix-diff/src/blob/platform.rs

-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub struct Resource<'a> {
9090
}
9191

9292
///
93-
#[allow(clippy::empty_docs)]
9493
pub mod resource {
9594
use crate::blob::{
9695
pipeline,
@@ -151,7 +150,6 @@ pub mod resource {
151150
}
152151

153152
///
154-
#[allow(clippy::empty_docs)]
155153
pub mod set_resource {
156154
use bstr::BString;
157155

@@ -181,7 +179,6 @@ pub mod set_resource {
181179
}
182180

183181
///
184-
#[allow(clippy::empty_docs)]
185182
pub mod prepare_diff {
186183
use bstr::BStr;
187184

@@ -248,7 +245,6 @@ pub mod prepare_diff {
248245
}
249246

250247
///
251-
#[allow(clippy::empty_docs)]
252248
pub mod prepare_diff_command {
253249
use std::ops::{Deref, DerefMut};
254250

0 commit comments

Comments
 (0)