Skip to content

Commit 6c10e09

Browse files
committed
sub-command to print multi-index entries (#301)
1 parent 21c2dd5 commit 6c10e09

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Please see _'Development Status'_ for a listing of all crates and their capabili
3939
* [x] **info** - print information about the file
4040
* [x] **create** - create a multi-index from pack indices
4141
* [x] **verify** - check the file for consistency
42+
* [x] **entries** - list all entries of the file
4243
- **index**
4344
* [x] [create](https://asciinema.org/a/352941) - create an index file by streaming a pack file as done during clone
4445
* [x] support for thin packs (as needed for fetch/pull)

git-worktree/src/index/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ where
6363
}
6464
Err(err) => {
6565
if options.keep_going {
66-
files.fail(format!("{}: {}", entry_path, err));
6766
errors.push(ErrorRecord {
6867
path: entry_path.into(),
6968
error: Box::new(err),

gitoxide-core/src/pack/multi_index.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::bail;
12
use std::{io::BufWriter, path::PathBuf, sync::atomic::AtomicBool};
23

34
use crate::OutputFormat;
@@ -68,3 +69,14 @@ pub fn info(
6869
)?;
6970
Ok(())
7071
}
72+
73+
pub fn entries(multi_index_path: PathBuf, format: OutputFormat, mut out: impl std::io::Write) -> anyhow::Result<()> {
74+
if format != OutputFormat::Human {
75+
bail!("Only human format is supported right now");
76+
}
77+
let file = git::odb::pack::multi_index::File::at(&multi_index_path)?;
78+
for entry in file.iter() {
79+
writeln!(out, "{} {} {}", entry.oid, entry.pack_index, entry.pack_offset)?;
80+
}
81+
Ok(())
82+
}

src/plumbing/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ pub fn main() -> Result<()> {
378378
)
379379
.map(|_| ()),
380380
pack::Subcommands::MultiIndex(multi_index::Platform { multi_index_path, cmd }) => match cmd {
381+
pack::multi_index::Subcommands::Entries => prepare_and_run(
382+
"pack-multi-index-entries",
383+
verbose,
384+
progress,
385+
progress_keep_open,
386+
core::pack::multi_index::PROGRESS_RANGE,
387+
move |_progress, out, _err| core::pack::multi_index::entries(multi_index_path, format, out),
388+
),
381389
pack::multi_index::Subcommands::Info => prepare_and_run(
382390
"pack-multi-index-info",
383391
verbose,

src/plumbing/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ pub mod pack {
267267

268268
#[derive(Debug, clap::Subcommand)]
269269
pub enum Subcommands {
270+
/// Display all entries of a multi-index: <oid> <pack-id> <pack-offset>
271+
Entries,
270272
/// Print general information about a multi-index file
271273
Info,
272274
/// Verify a multi-index quickly without inspecting objects themselves

0 commit comments

Comments
 (0)