Build a path → oid map for a commit using `git ls-tree -r`.
(
git_dir: &PathBuf,
commit_sha: &str,
)
| 142 | |
| 143 | /// Build a path → oid map for a commit using `git ls-tree -r`. |
| 144 | fn 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 | |
| 161 | impl OdbReader for LocalGitOdb { |
| 162 | fn get(&self, key: &str) -> Result<Vec<u8>> { |
no test coverage detected