MCPcopy Create free account
hub / github.com/HairlessVillager/minecommit / build_path_to_oid

Function build_path_to_oid

minecommit/src/odb/git.rs:144–159  ·  view source on GitHub ↗

Build a path → oid map for a commit using `git ls-tree -r`.

(
    git_dir: &PathBuf,
    commit_sha: &str,
)

Source from the content-addressed store, hash-verified

142
143/// Build a path → oid map for a commit using `git ls-tree -r`.
144fn build_path_to_oid(
145 git_dir: &PathBuf,
146 commit_sha: &str,
147) -> Result<HashMap<String, gix::ObjectId>> {
148 let cmd = git_cmd(git_dir, ["ls-tree", "-r", "--", commit_sha]);
149 Ok(exec(cmd, None)
150 .context("failed to run ls-tree")?
151 .lines()
152 .filter_map(|line| {
153 let oid_str = line.get(12..52)?;
154 let path = line.get(53..)?.trim();
155 let oid: gix::ObjectId = oid_str.parse().ok()?;
156 Some((path.to_string(), oid))
157 })
158 .collect())
159}
160
161impl OdbReader for LocalGitOdb {
162 fn get(&self, key: &str) -> Result<Vec<u8>> {

Callers 1

from_commitMethod · 0.85

Calls 3

git_cmdFunction · 0.85
execFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected