Skip to content

Commit

Permalink
Flatten fsck connectivity into just fsck much like git fsck
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 10, 2023
1 parent 9c1830c commit 7ab5c76
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
8 changes: 2 additions & 6 deletions gitoxide-core/src/repository/fsck.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use anyhow::Context;
use gix::{objs::Kind, ObjectId};

pub fn connectivity(
mut repo: gix::Repository,
spec: Option<String>,
mut out: impl std::io::Write,
) -> anyhow::Result<()> {
pub fn function(mut repo: gix::Repository, spec: Option<String>, mut out: impl std::io::Write) -> anyhow::Result<()> {
let spec = spec.unwrap_or("HEAD".into());

repo.object_cache_size_if_unset(4 * 1024 * 1024);
Expand All @@ -31,7 +27,7 @@ pub fn connectivity(
// Walk all commits, checking each one for connectivity
for commit in commits {
let commit = commit?;
check.check_commit(&commit.id);
check.check_commit(&commit.id)?;
// Note that we leave parent-iteration to the commits iterator, as it will
// correctly handle shallow repositories which are expected to have the commits
// along the shallow boundary missing.
Expand Down
3 changes: 2 additions & 1 deletion gitoxide-core/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ pub use clone::function::clone;
pub use fetch::function::fetch;

pub mod commitgraph;
pub mod fsck;
mod fsck;
pub use fsck::function as fsck;
pub mod index;
pub mod mailmap;
pub mod odb;
Expand Down
20 changes: 9 additions & 11 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,17 +1072,15 @@ pub fn main() -> Result<()> {
move |_progress, out, err| core::repository::odb::info(repository(Mode::Strict)?, format, out, err),
),
},
Subcommands::Fsck(cmd) => match cmd {
fsck::Subcommands::Connectivity { spec } => prepare_and_run(
"fsck-connectivity",
trace,
auto_verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| core::repository::fsck::connectivity(repository(Mode::Strict)?, spec, out),
),
},
Subcommands::Fsck(fsck::Platform { spec }) => prepare_and_run(
"fsck",
trace,
auto_verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| core::repository::fsck(repository(Mode::Strict)?, spec, out),
),
Subcommands::Mailmap(cmd) => match cmd {
mailmap::Subcommands::Entries => prepare_and_run(
"mailmap-entries",
Expand Down
16 changes: 6 additions & 10 deletions src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ pub enum Subcommands {
/// Interact with the object database.
#[clap(subcommand)]
Odb(odb::Subcommands),
/// Perform (some) integrity checks on the repository.
#[clap(subcommand)]
Fsck(fsck::Subcommands),
/// Check for missing objects.
Fsck(fsck::Platform),
/// Interact with tree objects.
#[clap(subcommand)]
Tree(tree::Subcommands),
Expand Down Expand Up @@ -493,13 +492,10 @@ pub mod odb {
}

pub mod fsck {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Perform a (partial) connectivity check on the repository.
Connectivity {
/// A revspec to start the connectivity check from.
spec: Option<String>,
},
#[derive(Debug, clap::Parser)]
pub struct Platform {
/// A revspec to start the connectivity check from.
pub spec: Option<String>,
}
}

Expand Down

0 comments on commit 7ab5c76

Please sign in to comment.