Skip to content

Commit 83585bd

Browse files
committed
move index to 'free' (#331)
1 parent 1cdecbc commit 83585bd

File tree

2 files changed

+124
-124
lines changed

2 files changed

+124
-124
lines changed

Diff for: src/plumbing/main.rs

+73-73
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use gitoxide_core::pack::verify;
1616
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
1717
use crate::plumbing::options::remote;
1818
use crate::{
19-
plumbing::options::{commitgraph, free, index, repo, Args, Subcommands},
19+
plumbing::options::{commitgraph, free, repo, Args, Subcommands},
2020
shared::pretty::prepare_and_run,
2121
};
2222

@@ -77,79 +77,79 @@ pub fn main() -> Result<()> {
7777
})?;
7878

7979
match cmd {
80-
Subcommands::Index(index::Platform {
81-
object_hash,
82-
index_path,
83-
cmd,
84-
}) => match cmd {
85-
index::Subcommands::CheckoutExclusive {
86-
directory,
87-
empty_files,
88-
repository,
89-
keep_going,
90-
} => prepare_and_run(
91-
"index-checkout",
92-
verbose,
93-
progress,
94-
progress_keep_open,
95-
None,
96-
move |progress, _out, err| {
97-
core::index::checkout_exclusive(
98-
index_path,
99-
directory,
100-
repository,
101-
err,
102-
progress,
103-
&should_interrupt,
104-
core::index::checkout_exclusive::Options {
105-
index: core::index::Options { object_hash, format },
106-
empty_files,
107-
keep_going,
108-
thread_limit,
109-
},
110-
)
111-
},
112-
),
113-
index::Subcommands::Info { no_details } => prepare_and_run(
114-
"index-entries",
115-
verbose,
116-
progress,
117-
progress_keep_open,
118-
None,
119-
move |_progress, out, err| {
120-
core::index::information(
121-
index_path,
122-
out,
123-
err,
124-
core::index::information::Options {
125-
index: core::index::Options { object_hash, format },
126-
extension_details: !no_details,
127-
},
128-
)
129-
},
130-
),
131-
index::Subcommands::Entries => prepare_and_run(
132-
"index-entries",
133-
verbose,
134-
progress,
135-
progress_keep_open,
136-
None,
137-
move |_progress, out, _err| {
138-
core::index::entries(index_path, out, core::index::Options { object_hash, format })
139-
},
140-
),
141-
index::Subcommands::Verify => prepare_and_run(
142-
"index-verify",
143-
verbose,
144-
progress,
145-
progress_keep_open,
146-
None,
147-
move |_progress, out, _err| {
148-
core::index::verify(index_path, out, core::index::Options { object_hash, format })
149-
},
150-
),
151-
},
15280
Subcommands::Free(subcommands) => match subcommands {
81+
free::Subcommands::Index(free::index::Platform {
82+
object_hash,
83+
index_path,
84+
cmd,
85+
}) => match cmd {
86+
free::index::Subcommands::CheckoutExclusive {
87+
directory,
88+
empty_files,
89+
repository,
90+
keep_going,
91+
} => prepare_and_run(
92+
"index-checkout",
93+
verbose,
94+
progress,
95+
progress_keep_open,
96+
None,
97+
move |progress, _out, err| {
98+
core::index::checkout_exclusive(
99+
index_path,
100+
directory,
101+
repository,
102+
err,
103+
progress,
104+
&should_interrupt,
105+
core::index::checkout_exclusive::Options {
106+
index: core::index::Options { object_hash, format },
107+
empty_files,
108+
keep_going,
109+
thread_limit,
110+
},
111+
)
112+
},
113+
),
114+
free::index::Subcommands::Info { no_details } => prepare_and_run(
115+
"index-entries",
116+
verbose,
117+
progress,
118+
progress_keep_open,
119+
None,
120+
move |_progress, out, err| {
121+
core::index::information(
122+
index_path,
123+
out,
124+
err,
125+
core::index::information::Options {
126+
index: core::index::Options { object_hash, format },
127+
extension_details: !no_details,
128+
},
129+
)
130+
},
131+
),
132+
free::index::Subcommands::Entries => prepare_and_run(
133+
"index-entries",
134+
verbose,
135+
progress,
136+
progress_keep_open,
137+
None,
138+
move |_progress, out, _err| {
139+
core::index::entries(index_path, out, core::index::Options { object_hash, format })
140+
},
141+
),
142+
free::index::Subcommands::Verify => prepare_and_run(
143+
"index-verify",
144+
verbose,
145+
progress,
146+
progress_keep_open,
147+
None,
148+
move |_progress, out, _err| {
149+
core::index::verify(index_path, out, core::index::Options { object_hash, format })
150+
},
151+
),
152+
},
153153
free::Subcommands::Mailmap { cmd } => match cmd {
154154
free::mailmap::Platform { path, cmd } => match cmd {
155155
free::mailmap::Subcommands::Verify => prepare_and_run(

Diff for: src/plumbing/options.rs

+51-51
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ pub enum Subcommands {
5858
/// Subcommands for interacting with commit-graphs
5959
#[clap(subcommand)]
6060
CommitGraph(commitgraph::Subcommands),
61-
/// Subcommands for interacting with a worktree index, typically at .git/index
62-
Index(index::Platform),
6361
/// Subcommands for interacting with entire git repositories
6462
Repository(repo::Platform),
6563
/// Subcommands that need no git repository to run.
@@ -79,6 +77,57 @@ pub mod free {
7977
/// Subcommands for interacting with pack files and indices
8078
#[clap(subcommand)]
8179
Pack(pack::Subcommands),
80+
/// Subcommands for interacting with a worktree index, typically at .git/index
81+
Index(index::Platform),
82+
}
83+
84+
pub mod index {
85+
use std::path::PathBuf;
86+
87+
#[derive(Debug, clap::Parser)]
88+
pub struct Platform {
89+
/// The object format to assume when reading files that don't inherently know about it, or when writing files.
90+
#[clap(long, default_value_t = git_repository::hash::Kind::default(), possible_values(&["SHA1"]))]
91+
pub object_hash: git_repository::hash::Kind,
92+
93+
/// The path to the index file.
94+
#[clap(short = 'i', long, default_value = ".git/index")]
95+
pub index_path: PathBuf,
96+
97+
/// Subcommands
98+
#[clap(subcommand)]
99+
pub cmd: Subcommands,
100+
}
101+
102+
#[derive(Debug, clap::Subcommand)]
103+
pub enum Subcommands {
104+
/// Validate constraints and assumptions of an index along with its integrity.
105+
Verify,
106+
/// Print all entries to standard output
107+
Entries,
108+
/// Print information about the index structure
109+
Info {
110+
/// Do not extract specific extension information to gain only a superficial idea of the index's composition.
111+
#[clap(long)]
112+
no_details: bool,
113+
},
114+
/// Checkout the index into a directory with exclusive write access, similar to what would happen during clone.
115+
CheckoutExclusive {
116+
/// The path to `.git` repository from which objects can be obtained to write the actual files referenced
117+
/// in the index. Use this measure the impact on extracting objects on overall performance.
118+
#[clap(long, short = 'r')]
119+
repository: Option<PathBuf>,
120+
/// Ignore errors and keep checking out as many files as possible, and report all errors at the end of the operation.
121+
#[clap(long, short = 'k')]
122+
keep_going: bool,
123+
/// Enable to query the object database yet write only empty files. This is useful to measure the overhead of ODB query
124+
/// compared to writing the bytes to disk.
125+
#[clap(long, short = 'e', requires = "repository")]
126+
empty_files: bool,
127+
/// The directory into which to write all index entries.
128+
directory: PathBuf,
129+
},
130+
}
82131
}
83132

84133
///
@@ -537,55 +586,6 @@ pub mod repo {
537586
}
538587

539588
///
540-
pub mod index {
541-
use std::path::PathBuf;
542-
543-
#[derive(Debug, clap::Parser)]
544-
pub struct Platform {
545-
/// The object format to assume when reading files that don't inherently know about it, or when writing files.
546-
#[clap(long, default_value_t = git_repository::hash::Kind::default(), possible_values(&["SHA1"]))]
547-
pub object_hash: git_repository::hash::Kind,
548-
549-
/// The path to the index file.
550-
#[clap(short = 'i', long, default_value = ".git/index")]
551-
pub index_path: PathBuf,
552-
553-
/// Subcommands
554-
#[clap(subcommand)]
555-
pub cmd: Subcommands,
556-
}
557-
558-
#[derive(Debug, clap::Subcommand)]
559-
pub enum Subcommands {
560-
/// Validate constraints and assumptions of an index along with its integrity.
561-
Verify,
562-
/// Print all entries to standard output
563-
Entries,
564-
/// Print information about the index structure
565-
Info {
566-
/// Do not extract specific extension information to gain only a superficial idea of the index's composition.
567-
#[clap(long)]
568-
no_details: bool,
569-
},
570-
/// Checkout the index into a directory with exclusive write access, similar to what would happen during clone.
571-
CheckoutExclusive {
572-
/// The path to `.git` repository from which objects can be obtained to write the actual files referenced
573-
/// in the index. Use this measure the impact on extracting objects on overall performance.
574-
#[clap(long, short = 'r')]
575-
repository: Option<PathBuf>,
576-
/// Ignore errors and keep checking out as many files as possible, and report all errors at the end of the operation.
577-
#[clap(long, short = 'k')]
578-
keep_going: bool,
579-
/// Enable to query the object database yet write only empty files. This is useful to measure the overhead of ODB query
580-
/// compared to writing the bytes to disk.
581-
#[clap(long, short = 'e', requires = "repository")]
582-
empty_files: bool,
583-
/// The directory into which to write all index entries.
584-
directory: PathBuf,
585-
},
586-
}
587-
}
588-
589589
///
590590
pub mod commitgraph {
591591
use std::path::PathBuf;

0 commit comments

Comments
 (0)