Skip to content

Commit

Permalink
Make git-index non-optional and part of the standard setup. (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 1, 2022
1 parent ebb788c commit c2e84a4
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 21 deletions.
8 changes: 4 additions & 4 deletions git-repository/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ max-performance = [ "git-features/fast-sha1",
"git-pack/pack-cache-lru-dynamic"]
## Re-export stability tier 2 crates for convenience and make `Repository` struct fields with types from these crates publicly accessible.
## Doing so is less stable than the stability tier 1 that `git-repository` is a member of.
unstable = ["git-index", "git-mailmap", "git-glob", "git-credentials", "git-attributes"]
unstable = ["git-mailmap", "git-credentials"]
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
cache-efficiency-debug = ["git-features/cache-efficiency-debug"]

Expand Down Expand Up @@ -102,10 +102,10 @@ git-mailmap = { version = "^0.3.0", path = "../git-mailmap", optional = true }
git-features = { version = "^0.22.0", path = "../git-features", features = ["progress", "once_cell"] }

# unstable only
git-attributes = { version = "^0.3.0", path = "../git-attributes", optional = true }
git-glob = { version = "^0.3.1", path = "../git-glob", optional = true }
git-attributes = { version = "^0.3.0", path = "../git-attributes" }
git-glob = { version = "^0.3.1", path = "../git-glob" }
git-credentials = { version = "^0.3.0", path = "../git-credentials", optional = true }
git-index = { version = "^0.4.0", path = "../git-index", optional = true }
git-index = { version = "^0.4.0", path = "../git-index" }
git-worktree = { version = "^0.4.0", path = "../git-worktree" }

signal-hook = { version = "0.3.9", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion git-repository/src/config/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ impl Cache {
}

/// Return a path by using the `$XDF_CONFIG_HOME` or `$HOME/.config/…` environment variables locations.
#[cfg_attr(not(feature = "git-index"), allow(dead_code))]
pub fn xdg_config_path(
&self,
resource_file_name: &str,
Expand Down
3 changes: 0 additions & 3 deletions git-repository/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ pub(crate) struct Cache {
/// The object kind to pick if a prefix is ambiguous.
pub object_kind_hint: Option<spec::parse::ObjectKindHint>,
/// If true, we are on a case-insensitive file system.
#[cfg_attr(not(feature = "git-index"), allow(dead_code))]
pub ignore_case: bool,
/// The path to the user-level excludes file to ignore certain files in the worktree.
#[cfg_attr(not(feature = "git-index"), allow(dead_code))]
pub excludes_file: Option<std::path::PathBuf>,
/// Define how we can use values obtained with `xdg_config(…)` and its `XDG_CONFIG_HOME` variable.
#[cfg_attr(not(feature = "git-index"), allow(dead_code))]
xdg_config_home_env: permission::env_var::Resource,
/// Define how we can use values obtained with `xdg_config(…)`. and its `HOME` variable.
home_env: permission::env_var::Resource,
Expand Down
6 changes: 3 additions & 3 deletions git-repository/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
// This also means that their major version changes affect our major version, but that's alright as we directly expose their
// APIs/instances anyway.
pub use git_actor as actor;
#[cfg(all(feature = "unstable", feature = "git-attributes"))]
#[cfg(all(feature = "unstable"))]
pub use git_attributes as attrs;
#[cfg(all(feature = "unstable", feature = "git-credentials"))]
pub use git_credentials as credentials;
Expand All @@ -137,11 +137,11 @@ pub use git_diff as diff;
use git_features::threading::OwnShared;
#[cfg(feature = "unstable")]
pub use git_features::{parallel, progress, progress::Progress, threading};
#[cfg(all(feature = "unstable", feature = "git-glob"))]
#[cfg(feature = "unstable")]
pub use git_glob as glob;
pub use git_hash as hash;
#[doc(inline)]
#[cfg(all(feature = "unstable", feature = "git-index"))]
#[cfg(feature = "unstable")]
pub use git_index as index;
pub use git_lock as lock;
pub use git_object as objs;
Expand Down
2 changes: 1 addition & 1 deletion git-repository/src/mailmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use git_mailmap::*;

///
pub mod load {
/// The error returned by [`crate::Repository::load_mailmap_into()`].
/// The error returned by [`crate::Repository::open_mailmap_into()`].
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion git-repository/src/repository/snapshots.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
impl crate::Repository {
// TODO: tests
/// Similar to [`load_mailmap_into()`][crate::Repository::load_mailmap_into()], but ignores all errors and returns at worst
/// Similar to [`open_mailmap_into()`][crate::Repository::open_mailmap_into()], but ignores all errors and returns at worst
/// an empty mailmap, e.g. if there is no mailmap or if there were errors loading them.
///
/// This represents typical usage within git, which also works with what's there without considering a populated mailmap
Expand Down
1 change: 0 additions & 1 deletion git-repository/src/repository/worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl crate::Repository {
/// It will use the `index.threads` configuration key to learn how many threads to use.
/// Note that it may fail if there is no index.
// TODO: test
#[cfg(feature = "git-index")]
pub fn open_index(&self) -> Result<git_index::File, worktree::open_index::Error> {
use std::convert::{TryFrom, TryInto};
let thread_limit = self
Expand Down
1 change: 0 additions & 1 deletion git-repository/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::head;

/// A worktree checkout containing the files of the repository in consumable form.
pub struct Worktree<'repo> {
#[cfg_attr(not(feature = "git-index"), allow(dead_code))]
pub(crate) parent: &'repo Repository,
/// The root path of the checkout.
pub(crate) path: &'repo std::path::Path,
Expand Down
2 changes: 0 additions & 2 deletions git-repository/src/worktree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub(crate) fn id(git_dir: &std::path::Path, has_common_dir: bool) -> Option<&BSt
pub mod proxy;

///
#[cfg(feature = "git-index")]
pub mod open_index {
use crate::bstr::BString;

Expand Down Expand Up @@ -102,7 +101,6 @@ pub mod open_index {
}

///
#[cfg(feature = "git-index")]
pub mod excludes {
use std::path::PathBuf;

Expand Down
9 changes: 5 additions & 4 deletions git-repository/tests/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ mod worktree;

#[test]
fn size_in_memory() {
assert_eq!(
std::mem::size_of::<Repository>(),
696,
"size of Repository shouldn't change without us noticing, it's meant to be cloned"
let expected = [688, 696];
assert!(
expected.contains(&std::mem::size_of::<Repository>()),
"size of Repository shouldn't change without us noticing, it's meant to be cloned: should have been within {:?}",
expected
);
}

0 comments on commit c2e84a4

Please sign in to comment.