The checked `GIT_SHA_INDEX` row for one SHA. A row is usable only when the mapped change is registered, loadable, decodes to exactly its claimed identity, and its unhashed provenance names this SHA. Anything else is a stale/missing/ambiguous/malicious entry and reports `None` — the same treatment as a cold cache.
(&self, sha: &str)
| 615 | /// names this SHA. Anything else is a stale/missing/ambiguous/malicious |
| 616 | /// entry and reports `None` — the same treatment as a cold cache. |
| 617 | pub fn checked_git_sha(&self, sha: &str) -> Result<Option<Hash>, RepositoryError> { |
| 618 | use atomic_core::pristine::{GitShaIndexTxnT, GraphTxnT}; |
| 619 | let txn = self.pristine.read_txn().map_err(pristine_map)?; |
| 620 | let Some(change_id) = txn.get_by_git_sha(sha).map_err(pristine_map)? else { |
| 621 | return Ok(None); |
| 622 | }; |
| 623 | let Some(hash) = txn.get_external(change_id).map_err(pristine_map)? else { |
| 624 | return Ok(None); |
| 625 | }; |
| 626 | drop(txn); |
| 627 | if !self.has_change(&hash) { |
| 628 | return Ok(None); |
| 629 | } |
| 630 | let Ok(change) = self.load_change(&hash) else { |
| 631 | return Ok(None); |
| 632 | }; |
| 633 | let names_sha = change |
| 634 | .unhashed |
| 635 | .as_ref() |
| 636 | .and_then(|unhashed| unhashed.get("git")) |
| 637 | .and_then(|git| git.get("sha")) |
| 638 | .and_then(|value| value.as_str()) |
| 639 | .map(|claimed| claimed == sha) |
| 640 | .unwrap_or(false); |
| 641 | if names_sha { |
| 642 | Ok(Some(hash)) |
| 643 | } else { |
| 644 | Ok(None) |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | /// The raw `GIT_SHA_INDEX` row for one SHA: the mapped change must be |
| 649 | /// registered, loadable, and decode to exactly its claimed identity. |