Complete Git ancestry of `sha` (the commit itself and every transitive parent), memoized. The walk uses the live Git object database, so it stays exact across batch boundaries and incremental imports.
(
&mut self,
git: &GitRepository,
sha: &str,
)
| 830 | /// database, so it stays exact across batch boundaries and incremental |
| 831 | /// imports. |
| 832 | fn ancestry_of( |
| 833 | &mut self, |
| 834 | git: &GitRepository, |
| 835 | sha: &str, |
| 836 | ) -> CliResult<std::sync::Arc<HashSet<String>>> { |
| 837 | if let Some(cached) = self.ancestry.get(sha) { |
| 838 | return Ok(cached.clone()); |
| 839 | } |
| 840 | let oid = git2::Oid::from_str(sha) |
| 841 | .map_err(|e| git_error(format!("cannot parse commit oid '{sha}': {e}")))?; |
| 842 | let commit = git.find_commit(oid).map_err(|e| CliError::GitError { |
| 843 | message: format!("cannot read commit {sha} for ancestry: {e}"), |
| 844 | })?; |
| 845 | let mut set: HashSet<String> = HashSet::new(); |
| 846 | set.insert(sha.to_string()); |
| 847 | for parent in commit.parent_ids() { |
| 848 | let parent_ancestry = self.ancestry_of(git, &parent.to_string())?; |
| 849 | set.extend(parent_ancestry.iter().cloned()); |
| 850 | } |
| 851 | let shared = std::sync::Arc::new(set); |
| 852 | self.ancestry.insert(sha.to_string(), shared.clone()); |
| 853 | Ok(shared) |
| 854 | } |
| 855 | |
| 856 | /// The complete interpreted closure of one Git commit (CB-9B review R1): |
| 857 | /// every Atomic change whose content makes up the commit's interpreted |
no test coverage detected