Skip to content

Commit

Permalink
move index to 'free' (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 22, 2022
1 parent 1cdecbc commit 83585bd
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 124 deletions.
146 changes: 73 additions & 73 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use gitoxide_core::pack::verify;
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
use crate::plumbing::options::remote;
use crate::{
plumbing::options::{commitgraph, free, index, repo, Args, Subcommands},
plumbing::options::{commitgraph, free, repo, Args, Subcommands},
shared::pretty::prepare_and_run,
};

Expand Down Expand Up @@ -77,79 +77,79 @@ pub fn main() -> Result<()> {
})?;

match cmd {
Subcommands::Index(index::Platform {
object_hash,
index_path,
cmd,
}) => match cmd {
index::Subcommands::CheckoutExclusive {
directory,
empty_files,
repository,
keep_going,
} => prepare_and_run(
"index-checkout",
verbose,
progress,
progress_keep_open,
None,
move |progress, _out, err| {
core::index::checkout_exclusive(
index_path,
directory,
repository,
err,
progress,
&should_interrupt,
core::index::checkout_exclusive::Options {
index: core::index::Options { object_hash, format },
empty_files,
keep_going,
thread_limit,
},
)
},
),
index::Subcommands::Info { no_details } => prepare_and_run(
"index-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::index::information(
index_path,
out,
err,
core::index::information::Options {
index: core::index::Options { object_hash, format },
extension_details: !no_details,
},
)
},
),
index::Subcommands::Entries => prepare_and_run(
"index-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::index::entries(index_path, out, core::index::Options { object_hash, format })
},
),
index::Subcommands::Verify => prepare_and_run(
"index-verify",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::index::verify(index_path, out, core::index::Options { object_hash, format })
},
),
},
Subcommands::Free(subcommands) => match subcommands {
free::Subcommands::Index(free::index::Platform {
object_hash,
index_path,
cmd,
}) => match cmd {
free::index::Subcommands::CheckoutExclusive {
directory,
empty_files,
repository,
keep_going,
} => prepare_and_run(
"index-checkout",
verbose,
progress,
progress_keep_open,
None,
move |progress, _out, err| {
core::index::checkout_exclusive(
index_path,
directory,
repository,
err,
progress,
&should_interrupt,
core::index::checkout_exclusive::Options {
index: core::index::Options { object_hash, format },
empty_files,
keep_going,
thread_limit,
},
)
},
),
free::index::Subcommands::Info { no_details } => prepare_and_run(
"index-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::index::information(
index_path,
out,
err,
core::index::information::Options {
index: core::index::Options { object_hash, format },
extension_details: !no_details,
},
)
},
),
free::index::Subcommands::Entries => prepare_and_run(
"index-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::index::entries(index_path, out, core::index::Options { object_hash, format })
},
),
free::index::Subcommands::Verify => prepare_and_run(
"index-verify",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::index::verify(index_path, out, core::index::Options { object_hash, format })
},
),
},
free::Subcommands::Mailmap { cmd } => match cmd {
free::mailmap::Platform { path, cmd } => match cmd {
free::mailmap::Subcommands::Verify => prepare_and_run(
Expand Down
102 changes: 51 additions & 51 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ pub enum Subcommands {
/// Subcommands for interacting with commit-graphs
#[clap(subcommand)]
CommitGraph(commitgraph::Subcommands),
/// Subcommands for interacting with a worktree index, typically at .git/index
Index(index::Platform),
/// Subcommands for interacting with entire git repositories
Repository(repo::Platform),
/// Subcommands that need no git repository to run.
Expand All @@ -79,6 +77,57 @@ pub mod free {
/// Subcommands for interacting with pack files and indices
#[clap(subcommand)]
Pack(pack::Subcommands),
/// Subcommands for interacting with a worktree index, typically at .git/index
Index(index::Platform),
}

pub mod index {
use std::path::PathBuf;

#[derive(Debug, clap::Parser)]
pub struct Platform {
/// The object format to assume when reading files that don't inherently know about it, or when writing files.
#[clap(long, default_value_t = git_repository::hash::Kind::default(), possible_values(&["SHA1"]))]
pub object_hash: git_repository::hash::Kind,

/// The path to the index file.
#[clap(short = 'i', long, default_value = ".git/index")]
pub index_path: PathBuf,

/// Subcommands
#[clap(subcommand)]
pub cmd: Subcommands,
}

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Validate constraints and assumptions of an index along with its integrity.
Verify,
/// Print all entries to standard output
Entries,
/// Print information about the index structure
Info {
/// Do not extract specific extension information to gain only a superficial idea of the index's composition.
#[clap(long)]
no_details: bool,
},
/// Checkout the index into a directory with exclusive write access, similar to what would happen during clone.
CheckoutExclusive {
/// The path to `.git` repository from which objects can be obtained to write the actual files referenced
/// in the index. Use this measure the impact on extracting objects on overall performance.
#[clap(long, short = 'r')]
repository: Option<PathBuf>,
/// Ignore errors and keep checking out as many files as possible, and report all errors at the end of the operation.
#[clap(long, short = 'k')]
keep_going: bool,
/// Enable to query the object database yet write only empty files. This is useful to measure the overhead of ODB query
/// compared to writing the bytes to disk.
#[clap(long, short = 'e', requires = "repository")]
empty_files: bool,
/// The directory into which to write all index entries.
directory: PathBuf,
},
}
}

///
Expand Down Expand Up @@ -537,55 +586,6 @@ pub mod repo {
}

///
pub mod index {
use std::path::PathBuf;

#[derive(Debug, clap::Parser)]
pub struct Platform {
/// The object format to assume when reading files that don't inherently know about it, or when writing files.
#[clap(long, default_value_t = git_repository::hash::Kind::default(), possible_values(&["SHA1"]))]
pub object_hash: git_repository::hash::Kind,

/// The path to the index file.
#[clap(short = 'i', long, default_value = ".git/index")]
pub index_path: PathBuf,

/// Subcommands
#[clap(subcommand)]
pub cmd: Subcommands,
}

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Validate constraints and assumptions of an index along with its integrity.
Verify,
/// Print all entries to standard output
Entries,
/// Print information about the index structure
Info {
/// Do not extract specific extension information to gain only a superficial idea of the index's composition.
#[clap(long)]
no_details: bool,
},
/// Checkout the index into a directory with exclusive write access, similar to what would happen during clone.
CheckoutExclusive {
/// The path to `.git` repository from which objects can be obtained to write the actual files referenced
/// in the index. Use this measure the impact on extracting objects on overall performance.
#[clap(long, short = 'r')]
repository: Option<PathBuf>,
/// Ignore errors and keep checking out as many files as possible, and report all errors at the end of the operation.
#[clap(long, short = 'k')]
keep_going: bool,
/// Enable to query the object database yet write only empty files. This is useful to measure the overhead of ODB query
/// compared to writing the bytes to disk.
#[clap(long, short = 'e', requires = "repository")]
empty_files: bool,
/// The directory into which to write all index entries.
directory: PathBuf,
},
}
}

///
pub mod commitgraph {
use std::path::PathBuf;
Expand Down

0 comments on commit 83585bd

Please sign in to comment.