Make mempack usage optional
@@ -64,6 +64,11 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
.help("Don't load cache")
.short("n"),
)
+ .arg(
+ clap::Arg::with_name("pack")
+ .help("Write a packfile instead of loose objects")
+ .long("pack"),
+ )
.arg(
clap::Arg::with_name("query")
.long("query")
@@ -119,7 +124,11 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
let repo = transaction.repo();
let odb = repo.odb()?;
+ let mp = if args.is_present("pack") {
let mempack = odb.add_new_mempack_backend(1000)?;
+ Some(mempack)
+ }
+ else { None };
if !args.is_present("no-cache") {
josh::cache::load(&repo.path())?;
@@ -132,6 +141,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
if args.is_present("cache-stats") {
josh::cache::print_stats();
}
+ if let Some(mempack) = mp {
let mut buf = git2::Buf::new();
mempack.dump(&repo, &mut buf).unwrap();
if buf.len() > 32 {
@@ -139,6 +149,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
w.write(&buf).unwrap();
w.commit().unwrap();
}
+ }
});
let input_ref = args.value_of("input").unwrap();
