Skip to content

Commit 7ab5c76

Browse files
committed
Flatten fsck connectivity into just fsck much like git fsck
1 parent 9c1830c commit 7ab5c76

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

gitoxide-core/src/repository/fsck.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
use anyhow::Context;
22
use gix::{objs::Kind, ObjectId};
33

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

117
repo.object_cache_size_if_unset(4 * 1024 * 1024);
@@ -31,7 +27,7 @@ pub fn connectivity(
3127
// Walk all commits, checking each one for connectivity
3228
for commit in commits {
3329
let commit = commit?;
34-
check.check_commit(&commit.id);
30+
check.check_commit(&commit.id)?;
3531
// Note that we leave parent-iteration to the commits iterator, as it will
3632
// correctly handle shallow repositories which are expected to have the commits
3733
// along the shallow boundary missing.

gitoxide-core/src/repository/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub use clone::function::clone;
3535
pub use fetch::function::fetch;
3636

3737
pub mod commitgraph;
38-
pub mod fsck;
38+
mod fsck;
39+
pub use fsck::function as fsck;
3940
pub mod index;
4041
pub mod mailmap;
4142
pub mod odb;

src/plumbing/main.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -1072,17 +1072,15 @@ pub fn main() -> Result<()> {
10721072
move |_progress, out, err| core::repository::odb::info(repository(Mode::Strict)?, format, out, err),
10731073
),
10741074
},
1075-
Subcommands::Fsck(cmd) => match cmd {
1076-
fsck::Subcommands::Connectivity { spec } => prepare_and_run(
1077-
"fsck-connectivity",
1078-
trace,
1079-
auto_verbose,
1080-
progress,
1081-
progress_keep_open,
1082-
None,
1083-
move |_progress, out, _err| core::repository::fsck::connectivity(repository(Mode::Strict)?, spec, out),
1084-
),
1085-
},
1075+
Subcommands::Fsck(fsck::Platform { spec }) => prepare_and_run(
1076+
"fsck",
1077+
trace,
1078+
auto_verbose,
1079+
progress,
1080+
progress_keep_open,
1081+
None,
1082+
move |_progress, out, _err| core::repository::fsck(repository(Mode::Strict)?, spec, out),
1083+
),
10861084
Subcommands::Mailmap(cmd) => match cmd {
10871085
mailmap::Subcommands::Entries => prepare_and_run(
10881086
"mailmap-entries",

src/plumbing/options/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ pub enum Subcommands {
8787
/// Interact with the object database.
8888
#[clap(subcommand)]
8989
Odb(odb::Subcommands),
90-
/// Perform (some) integrity checks on the repository.
91-
#[clap(subcommand)]
92-
Fsck(fsck::Subcommands),
90+
/// Check for missing objects.
91+
Fsck(fsck::Platform),
9392
/// Interact with tree objects.
9493
#[clap(subcommand)]
9594
Tree(tree::Subcommands),
@@ -493,13 +492,10 @@ pub mod odb {
493492
}
494493

495494
pub mod fsck {
496-
#[derive(Debug, clap::Subcommand)]
497-
pub enum Subcommands {
498-
/// Perform a (partial) connectivity check on the repository.
499-
Connectivity {
500-
/// A revspec to start the connectivity check from.
501-
spec: Option<String>,
502-
},
495+
#[derive(Debug, clap::Parser)]
496+
pub struct Platform {
497+
/// A revspec to start the connectivity check from.
498+
pub spec: Option<String>,
503499
}
504500
}
505501

0 commit comments

Comments
 (0)