MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / detect_git_boundaries

Function detect_git_boundaries

atomic-cli/src/commands/git/parallel.rs:1800–1838  ·  view source on GitHub ↗

Detect explicit Git closure boundaries (CB-9A §7).

(git: &GitRepository)

Source from the content-addressed store, hash-verified

1798
1799/// Detect explicit Git closure boundaries (CB-9A §7).
1800pub(crate) fn detect_git_boundaries(git: &GitRepository) -> CliResult<Vec<GitClosureBoundary>> {
1801 let mut boundaries = Vec::new();
1802 let git_dir = git.path();
1803 if git_dir.join("shallow").exists() {
1804 boundaries.push(GitClosureBoundary::Shallow);
1805 }
1806 let config = git
1807 .config()
1808 .map_err(|error| git_error(format!("cannot read Git configuration: {error}")))?;
1809 if config.get_string("extensions.partialclone").is_ok() {
1810 boundaries.push(GitClosureBoundary::Promisor);
1811 } else if let Ok(mut entries) = config.entries(Some("remote.*.promisor")) {
1812 while let Some(entry) = entries.next() {
1813 let is_promisor =
1814 entry.is_ok_and(|entry| entry.value().is_ok_and(|value| value == "true"));
1815 if is_promisor {
1816 boundaries.push(GitClosureBoundary::Promisor);
1817 break;
1818 }
1819 }
1820 }
1821 if git_dir.join("info").join("grafts").exists() {
1822 boundaries.push(GitClosureBoundary::Grafts);
1823 }
1824 if git
1825 .references()
1826 .map_err(|error| git_error(format!("cannot list Git references: {error}")))?
1827 .filter_map(|reference| reference.ok())
1828 .any(|reference| {
1829 reference
1830 .name()
1831 .map(|name| name.starts_with("refs/replace/"))
1832 .unwrap_or(false)
1833 })
1834 {
1835 boundaries.push(GitClosureBoundary::ReplaceRefs);
1836 }
1837 Ok(boundaries)
1838}
1839
1840/// The Git shallow boundary set: hex OIDs listed in `<gitdir>/shallow`.
1841pub(crate) fn shallow_boundary_oids(git: &GitRepository) -> HashSet<String> {

Calls 9

entriesMethod · 0.80
valueMethod · 0.80
git_errorFunction · 0.70
pathMethod · 0.45
existsMethod · 0.45
pushMethod · 0.45
nextMethod · 0.45
okMethod · 0.45
nameMethod · 0.45