Skip to content

Commit

Permalink
write index without output path to memory only.
Browse files Browse the repository at this point in the history
That way the actual performance can be measured more easily, removing IO
entirely.
  • Loading branch information
Byron committed Oct 12, 2022
1 parent bb81abe commit c8d0345
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub fn from_tree(
index_path: Option<PathBuf>,
force: bool,
repo: git::Repository,
mut out: impl std::io::Write,
) -> anyhow::Result<()> {
spec.push("^{tree}");
let spec = git::path::os_str_into_bstr(&spec)?;
Expand All @@ -29,6 +28,7 @@ pub fn from_tree(
}
None => {
let index = git::index::File::from_state(index, std::path::PathBuf::new());
let mut out = Vec::with_capacity(512 * 1024);
index.write_to(&mut out, options)?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ pub fn main() -> Result<()> {
progress,
progress_keep_open,
None,
move |_progress, out, _err| {
core::repository::index::from_tree(spec, index_output_path, force, repository(Mode::Strict)?, out)
move |_progress, _out, _err| {
core::repository::index::from_tree(spec, index_output_path, force, repository(Mode::Strict)?)
},
),
},
Expand Down
3 changes: 2 additions & 1 deletion src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ pub mod index {
#[clap(long, short = 'f')]
force: bool,
/// Path to the index file to be written.
/// If none is given it will be written to stdout, avoiding to overwrite the repository index just yet.
/// If none is given it will be kept in memory only as a way to measure performance. One day we will probably write the index
/// back by default, but that requires us to write more of the index to work.
#[clap(long, short = 'i')]
index_output_path: Option<PathBuf>,
/// A revspec that points to the to generate the index from.
Expand Down

0 comments on commit c8d0345

Please sign in to comment.