exa/src/fs/feature/mod.rs
Benjamin Sago 040dbb2414 Use a global Git cache
This commit adds a cache for Git repositories based on the path being queried.

Its only immediate effect is that when you query the same directory twice (such as /testcases/git /testcases/git), it won’t need to check that the second one is a Git directory the second time. So, a minuscule optimisation for something you’d never do anyway? Wrong! It’s going to let us combine multiple entries over the same repository later, letting us use --tree and --recurse, because now Git scanning is behind a factory.
2017-08-28 18:11:38 +01:00

42 lines
877 B
Rust

// Extended attribute support
pub mod xattr;
// Git support
#[cfg(feature="git")] pub mod git;
#[cfg(not(feature="git"))]
pub mod git {
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
use fs::fields;
pub struct GitCache;
impl FromIterator<PathBuf> for GitCache {
fn from_iter<I: IntoIterator<Item=PathBuf>>(_iter: I) -> Self {
GitCache
}
}
impl GitCache {
pub fn get(&self, _index: &Path) -> Option<Git> {
panic!("Tried to query a Git cache, but Git support is disabled")
}
}
pub struct Git;
impl Git {
pub fn status(&self, _: &Path) -> fields::Git {
panic!("Tried to get a Git status, but Git support is disabled")
}
pub fn dir_status(&self, path: &Path) -> fields::Git {
self.status(path)
}
}
}