1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const HEADER_READ_UNCOMPRESSED_BYTES: usize = 512;
use std::path::{Path, PathBuf};
use git_features::fs;
#[derive(Clone, PartialEq, Eq)]
pub struct Store {
pub(crate) path: PathBuf,
pub(crate) object_hash: git_hash::Kind,
}
impl Store {
pub fn at(objects_directory: impl Into<PathBuf>, object_hash: git_hash::Kind) -> Store {
Store {
path: objects_directory.into(),
object_hash,
}
}
pub fn path(&self) -> &Path {
&self.path
}
pub fn object_hash(&self) -> git_hash::Kind {
self.object_hash
}
}
fn hash_path(id: &git_hash::oid, mut root: PathBuf) -> PathBuf {
let mut hex = git_hash::Kind::hex_buf();
let hex_len = id.hex_to_buf(hex.as_mut());
let buf = std::str::from_utf8(&hex[..hex_len]).expect("ascii only in hex");
root.push(&buf[..2]);
root.push(&buf[2..]);
root
}
pub mod find;
pub mod iter;
pub mod verify;
pub struct Iter {
inner: fs::walkdir::DirEntryIter,
hash_hex_len: usize,
}
pub mod write;