Skip to content

Commit

Permalink
frame for printing index information (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 23, 2022
1 parent eba101a commit 9ea98fd
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion git-bitmap/src/ewah.rs
Expand Up @@ -119,6 +119,6 @@ mod access {
pub struct Vec {
num_bits: u32,
bits: std::vec::Vec<u64>,
/// RLW is an offset into the `bits` buffer, so `1` translates into &bits[1] essentially.
/// RLW is an offset into the `bits` buffer, so `1` translates into &bits\[1] essentially.
rlw: usize,
}
5 changes: 4 additions & 1 deletion git-repository/Cargo.toml
Expand Up @@ -14,7 +14,7 @@ test = true

[features]
default = ["max-performance", "one-stop-shop"]
unstable = []
unstable = ["git-index"]
serde1 = ["git-pack/serde1", "git-object/serde1", "git-protocol/serde1", "git-transport/serde1", "git-ref/serde1", "git-odb/serde1"]
# enable when https://github.com/RustCrypto/asm-hashes/issues/17 is fixed
# max-performance = ["git-features/parallel", "git-features/zlib-ng-compat", "git-features/fast-sha1"]
Expand Down Expand Up @@ -54,6 +54,9 @@ git-transport = { version = "^0.15.0", path = "../git-transport", optional = tru
git-diff = { version = "^0.13.0", path = "../git-diff", optional = true }
git-features = { version = "^0.19.0", path = "../git-features", features = ["progress"] }

# unstable only
git-index = { version ="^0.1.0", path = "../git-index", optional = true }

signal-hook = { version = "0.3.9", default-features = false }
thiserror = "1.0.26"
clru = "0.5.0"
Expand Down
6 changes: 5 additions & 1 deletion git-repository/src/lib.rs
Expand Up @@ -86,6 +86,7 @@
//! * [`url`]
//! * [`actor`]
//! * [`bstr`][bstr]
//! * [`index`]
//! * [`objs`]
//! * [`odb`]
//! * [`pack`][odb::pack]
Expand Down Expand Up @@ -118,6 +119,8 @@ pub use git_features::{parallel, progress, progress::Progress, threading};
pub use git_hash as hash;
#[doc(inline)]
pub use git_hash::{oid, ObjectId};
#[cfg(all(feature = "unstable", feature = "git-index"))]
pub use git_index as index;
pub use git_lock as lock;
pub use git_object as objs;
pub use git_object::bstr;
Expand Down Expand Up @@ -151,9 +154,10 @@ pub mod prelude {
pub mod path;

mod repository;
use git_features::threading::OwnShared;
pub use repository::{discover, init, open};

use git_features::threading::OwnShared;

/// The standard type for a store to handle git references.
pub type RefStore = git_ref::file::Store;
/// A handle for finding objects in an object database, abstracting away caches for thread-local use.
Expand Down
18 changes: 18 additions & 0 deletions gitoxide-core/src/index.rs
@@ -0,0 +1,18 @@
use git_repository as git;
use std::path::Path;

#[allow(unused)]
pub fn entries(
index_path: impl AsRef<Path>,
out: impl std::io::Write,
object_hash: git::hash::Kind,
) -> anyhow::Result<()> {
let file = git::index::File::at(
index_path.as_ref(),
git::index::decode::Options {
object_hash,
..Default::default()
},
)?;
todo!("print entries")
}
1 change: 1 addition & 0 deletions gitoxide-core/src/lib.rs
Expand Up @@ -40,6 +40,7 @@ pub mod net;
pub mod commitgraph;
#[cfg(feature = "estimate-hours")]
pub mod hours;
pub mod index;
#[cfg(feature = "organize")]
pub mod organize;
pub mod pack;
Expand Down
14 changes: 14 additions & 0 deletions src/plumbing/main.rs
Expand Up @@ -12,6 +12,7 @@ use clap::Parser;
use gitoxide_core as core;
use gitoxide_core::pack::verify;

use crate::plumbing::options::index;
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
use crate::plumbing::options::remote;
use crate::{
Expand Down Expand Up @@ -73,6 +74,19 @@ pub fn main() -> Result<()> {
})?;

match cmd {
Subcommands::Index(subcommands) => match subcommands {
index::Subcommands::Entries {
object_hash,
index_path,
} => prepare_and_run(
"index-entries",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, _err| core::index::entries(index_path, out, object_hash),
),
},
Subcommands::Repository(subcommands) => match subcommands {
repo::Subcommands::Verify {
args:
Expand Down
25 changes: 25 additions & 0 deletions src/plumbing/options.rs
Expand Up @@ -56,6 +56,9 @@ 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
#[clap(subcommand)]
Index(index::Subcommands),
/// Subcommands for interacting with entire git repositories
#[clap(subcommand)]
Repository(repo::Subcommands),
Expand Down Expand Up @@ -344,6 +347,28 @@ pub mod repo {
}
}

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

use clap::AppSettings;

#[derive(Debug, clap::Parser)]
#[clap(alias = "index")]
pub enum Subcommands {
/// Print all entries to standard output
#[clap(setting = AppSettings::DisableVersionFlag)]
Entries {
/// The object format to assume when reading files that don't inherently know about it, or when writing files.
#[clap(long, default_value = "sha1", possible_values(&["sha1"]))]
object_hash: git_repository::hash::Kind,

/// The path too the index file.
index_path: PathBuf,
},
}
}

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

0 comments on commit 9ea98fd

Please sign in to comment.