Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial merge-base support #1557

Merged
merged 14 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,4 @@ borrow_as_ptr = "allow" # x2
unnecessary_join = "allow" # x1
stable_sort_primitive = "allow" # x1
no_effect_underscore_binding = "allow" # x1
empty_docs = "allow"
31 changes: 31 additions & 0 deletions gitoxide-core/src/repository/merge_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::OutputFormat;
use anyhow::bail;

pub fn merge_base(
mut repo: gix::Repository,
first: String,
others: Vec<String>,
mut out: impl std::io::Write,
format: OutputFormat,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
bail!("Only 'human' format is currently supported");
}
repo.object_cache_size_if_unset(50 * 1024 * 1024);
let first_id = repo.rev_parse_single(first.as_str())?;
let other_ids: Vec<_> = others
.iter()
.cloned()
.map(|other| repo.rev_parse_single(other.as_str()).map(gix::Id::detach))
.collect::<Result<_, _>>()?;

let cache = repo.commit_graph_if_enabled()?;
let bases = repo.merge_bases_many_with_cache(first_id, &other_ids, cache.as_ref())?;
if bases.is_empty() {
bail!("No base found for {first} and {others}", others = others.join(", "))
}
for id in bases {
writeln!(&mut out, "{id}")?;
}
Ok(())
}
2 changes: 2 additions & 0 deletions gitoxide-core/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ mod fsck;
pub use fsck::function as fsck;
pub mod index;
pub mod mailmap;
mod merge_base;
pub use merge_base::merge_base;
pub mod odb;
pub mod remote;
pub mod revision;
Expand Down
1 change: 0 additions & 1 deletion gix-actor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use gix_date::Time;

mod identity;
///
#[allow(clippy::empty_docs)]
pub mod signature;

/// A person with name and email.
Expand Down
1 change: 0 additions & 1 deletion gix-actor/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,5 @@ pub(crate) mod write {
}

///
#[allow(clippy::empty_docs)]
pub mod decode;
pub use decode::function::decode;
4 changes: 0 additions & 4 deletions gix-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ use kstring::{KString, KStringRef};

mod assignment;
///
#[allow(clippy::empty_docs)]
pub mod name;
///
#[allow(clippy::empty_docs)]
pub mod state;

///
#[allow(clippy::empty_docs)]
pub mod search;

///
#[allow(clippy::empty_docs)]
pub mod parse;

/// Parse attribute assignments line by line from `bytes`, and fail the operation on error.
Expand Down
1 change: 0 additions & 1 deletion gix-bitmap/src/ewah.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
///
#[allow(clippy::empty_docs)]
pub mod decode {
/// The error returned by [`decode()`][super::decode()].
#[derive(Debug, thiserror::Error)]
Expand Down
2 changes: 0 additions & 2 deletions gix-chunk/src/file/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::ops::Range;
use crate::file::Index;

///
#[allow(clippy::empty_docs)]
pub mod offset_by_kind {
use std::fmt::{Display, Formatter};

Expand All @@ -28,7 +27,6 @@ pub mod offset_by_kind {
}

///
#[allow(clippy::empty_docs)]
pub mod data_by_kind {
/// The error returned by [`Index::data_by_id()`][super::Index::data_by_id()].
#[derive(Debug, thiserror::Error)]
Expand Down
3 changes: 0 additions & 3 deletions gix-chunk/src/file/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
///
#[allow(clippy::empty_docs)]
pub mod decode;
///
#[allow(clippy::empty_docs)]
pub mod index;

///
#[allow(clippy::empty_docs)]
pub mod write;

/// The offset to a chunk as seen relative to the beginning of the file containing it.
Expand Down
2 changes: 0 additions & 2 deletions gix-chunk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub type Id = [u8; 4];
pub const SENTINEL: Id = [0u8; 4];

///
#[allow(clippy::empty_docs)]
pub mod range {
use std::ops::Range;

Expand All @@ -34,5 +33,4 @@ pub mod range {
}

///
#[allow(clippy::empty_docs)]
pub mod file;
1 change: 0 additions & 1 deletion gix-command/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ pub fn extract_interpreter(executable: &Path) -> Option<shebang::Data> {
}

///
#[allow(clippy::empty_docs)]
pub mod shebang {
use bstr::{BStr, ByteSlice};
use std::ffi::OsString;
Expand Down
1 change: 0 additions & 1 deletion gix-commitgraph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub fn at(path: impl AsRef<Path>) -> Result<Graph, init::Error> {
mod access;
pub mod file;
///
#[allow(clippy::empty_docs)]
pub mod init;
pub mod verify;

Expand Down
3 changes: 0 additions & 3 deletions gix-config-value/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ impl Error {

mod boolean;
///
#[allow(clippy::empty_docs)]
pub mod color;
///
#[allow(clippy::empty_docs)]
pub mod integer;
///
#[allow(clippy::empty_docs)]
pub mod path;

mod types;
Expand Down
1 change: 0 additions & 1 deletion gix-config-value/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use bstr::BStr;
use crate::Path;

///
#[allow(clippy::empty_docs)]
pub mod interpolate {
use std::path::PathBuf;

Expand Down
1 change: 0 additions & 1 deletion gix-config/src/file/includes/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl Default for Options<'_> {
}

///
#[allow(clippy::empty_docs)]
pub mod conditional {
/// Options to handle conditional includes like `includeIf.<condition>.path`.
#[derive(Clone, Copy, Default)]
Expand Down
1 change: 0 additions & 1 deletion gix-config/src/file/init/comfort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl File<'static> {
}

///
#[allow(clippy::empty_docs)]
pub mod from_git_dir {
use crate::file::init;

Expand Down
2 changes: 0 additions & 2 deletions gix-config/src/file/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ pub use types::{Error, Options};

mod comfort;
///
#[allow(clippy::empty_docs)]
pub mod from_env;
///
#[allow(clippy::empty_docs)]
pub mod from_paths;

impl<'a> File<'a> {
Expand Down
5 changes: 0 additions & 5 deletions gix-config/src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,19 @@ mod mutable;
pub use mutable::{multi_value::MultiValueMut, section::SectionMut, value::ValueMut};

///
#[allow(clippy::empty_docs)]
pub mod init;

mod access;
mod impls;
///
#[allow(clippy::empty_docs)]
pub mod includes;
mod meta;
mod util;

///
#[allow(clippy::empty_docs)]
pub mod section;

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

///
#[allow(clippy::empty_docs)]
pub mod set_raw_value {
/// The error returned by [`File::set_raw_value(…)`][crate::File::set_raw_value()].
#[derive(Debug, thiserror::Error)]
Expand Down
3 changes: 0 additions & 3 deletions gix-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
pub mod file;

///
#[allow(clippy::empty_docs)]
pub mod lookup;
pub mod parse;
///
#[allow(clippy::empty_docs)]
pub mod value;
pub use gix_config_value::{color, integer, path, Boolean, Color, Integer, Path};

Expand All @@ -53,5 +51,4 @@ pub use key::{AsKey, KeyRef};
mod types;
pub use types::{File, Source};
///
#[allow(clippy::empty_docs)]
pub mod source;
1 change: 0 additions & 1 deletion gix-config/src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub enum Error<E> {
}

///
#[allow(clippy::empty_docs)]
pub mod existing {
/// The error when looking up a value that doesn't exist, for example via [`File::value()`][crate::File::value()].
#[derive(Debug, thiserror::Error)]
Expand Down
1 change: 0 additions & 1 deletion gix-config/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub use events_type::{Events, FrontMatterEvents};
mod comment;
mod error;
///
#[allow(clippy::empty_docs)]
pub mod section;

#[cfg(test)]
Expand Down
2 changes: 0 additions & 2 deletions gix-config/src/parse/section/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use bstr::BStr;
use crate::parse::{Event, Section};

///
#[allow(clippy::empty_docs)]
pub mod header;

pub(crate) mod unvalidated;
Expand Down Expand Up @@ -49,7 +48,6 @@ mod types {
macro_rules! generate_case_insensitive {
($name:ident, $module:ident, $err_doc:literal, $validate:ident, $cow_inner_type:ty, $comment:literal) => {
///
#[allow(clippy::empty_docs)]
pub mod $module {
/// The error returned when `TryFrom` is invoked to create an instance.
#[derive(Debug, thiserror::Error, Copy, Clone)]
Expand Down
3 changes: 0 additions & 3 deletions gix-credentials/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ pub struct Program {
}

///
#[allow(clippy::empty_docs)]
pub mod helper;

///
#[allow(clippy::empty_docs)]
pub mod program;

///
#[allow(clippy::empty_docs)]
pub mod protocol;

/// Call the `git credential` helper program performing the given `action`, which reads all context from the git configuration
Expand Down
1 change: 0 additions & 1 deletion gix-credentials/src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,5 @@ impl Program {
}

///
#[allow(clippy::empty_docs)]
pub mod main;
pub use main::function::main;
1 change: 0 additions & 1 deletion gix-credentials/src/protocol/context/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ mod write {
}

///
#[allow(clippy::empty_docs)]
pub mod decode {
use bstr::{BString, ByteSlice};

Expand Down
1 change: 0 additions & 1 deletion gix-credentials/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,4 @@ pub fn helper_outcome_to_result(outcome: Option<helper::Outcome>, action: helper
}

///
#[allow(clippy::empty_docs)]
pub mod context;
2 changes: 0 additions & 2 deletions gix-date/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
#![forbid(unsafe_code)]

///
#[allow(clippy::empty_docs)]
pub mod time;

///
#[allow(clippy::empty_docs)]
pub mod parse;
pub use parse::function::parse;

Expand Down
1 change: 0 additions & 1 deletion gix-date/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl From<CustomFormat> for Format {
}

///
#[allow(clippy::empty_docs)]
pub mod format;
mod init;
mod write;
Expand Down
2 changes: 0 additions & 2 deletions gix-diff/src/blob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ use bstr::BString;
pub use imara_diff::*;

///
#[allow(clippy::empty_docs)]
pub mod pipeline;

///
#[allow(clippy::empty_docs)]
pub mod platform;

/// Information about the diff performed to detect similarity.
Expand Down
1 change: 0 additions & 1 deletion gix-diff/src/blob/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl Mode {
}

///
#[allow(clippy::empty_docs)]
pub mod convert_to_diffable {
use std::collections::TryReserveError;

Expand Down
4 changes: 0 additions & 4 deletions gix-diff/src/blob/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub struct Resource<'a> {
}

///
#[allow(clippy::empty_docs)]
pub mod resource {
use crate::blob::{
pipeline,
Expand Down Expand Up @@ -151,7 +150,6 @@ pub mod resource {
}

///
#[allow(clippy::empty_docs)]
pub mod set_resource {
use bstr::BString;

Expand Down Expand Up @@ -181,7 +179,6 @@ pub mod set_resource {
}

///
#[allow(clippy::empty_docs)]
pub mod prepare_diff {
use bstr::BStr;

Expand Down Expand Up @@ -248,7 +245,6 @@ pub mod prepare_diff {
}

///
#[allow(clippy::empty_docs)]
pub mod prepare_diff_command {
use std::ops::{Deref, DerefMut};

Expand Down
Loading
Loading