From 592c0c5ea7b3ac1f2b072566bedead801716c8a2 Mon Sep 17 00:00:00 2001 From: Mark Hinkle Date: Sat, 14 Nov 2026 21:25:53 -0500 Subject: [PATCH 1/3] Cover shim import with a Git-tracked .atomicignore Signed-off-by: Mark Hinkle Agent-Vendor: codex --- .../git_shim_branch_reconcile_regression.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/atomic-cli/tests/it/git_shim_branch_reconcile_regression.rs b/atomic-cli/tests/it/git_shim_branch_reconcile_regression.rs index aa0a92af..34b5e803 100644 --- a/atomic-cli/tests/it/git_shim_branch_reconcile_regression.rs +++ b/atomic-cli/tests/it/git_shim_branch_reconcile_regression.rs @@ -101,6 +101,42 @@ fn assert_clean_and_verified(root: &Path, home: &Path) { assert!(git(root, &["status", "--porcelain"]).is_empty()); } +#[test] +fn tracked_atomicignore_matches_git_head_after_import() { + for mode in ["--stream", "--no-stream"] { + let root = tempfile::tempdir().unwrap(); + let home = tempfile::tempdir().unwrap(); + let root = root.path(); + let home = home.path(); + let ignore = b"build/\n"; + git(root, &["init", "-q", "-b", "main"]); + fs::write(root.join(".atomicignore"), ignore).unwrap(); + fs::write(root.join("tracked.txt"), b"baseline\n").unwrap(); + git(root, &["add", ".atomicignore", "tracked.txt"]); + git( + root, + &["commit", "-qm", "baseline with tracked Atomic ignore"], + ); + let head = git(root, &["rev-parse", "HEAD"]); + + atomic_ok(root, home, &["git", "import", mode, "--no-vault"]); + atomic_ok(root, home, &["git", "shim", "verify"]); + + assert_eq!(git(root, &["rev-parse", "HEAD"]), head, "{mode}"); + assert_eq!( + git(root, &["ls-files", "--error-unmatch", ".atomicignore"]), + ".atomicignore", + "{mode}" + ); + assert_eq!( + fs::read(root.join(".atomicignore")).unwrap(), + ignore, + "{mode}" + ); + assert!(git(root, &["status", "--porcelain"]).is_empty(), "{mode}"); + } +} + #[test] fn literal_percent_path_reconciles_without_stale_checkpoint() { let (root, home) = shim_repo(); From 323b936d099d57a3a01735b1ebf05749fcff6857 Mon Sep 17 00:00:00 2001 From: Mark Hinkle Date: Sat, 14 Nov 2026 21:25:53 -0500 Subject: [PATCH 2/3] Preserve Git-tracked .atomicignore in shim projections Signed-off-by: Mark Hinkle Agent-Vendor: codex --- atomic-cli/src/commands/git/import.rs | 15 +++-- .../src/repository/project_tree.rs | 60 +++++++++++++------ 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/atomic-cli/src/commands/git/import.rs b/atomic-cli/src/commands/git/import.rs index 8e7d1cf4..be3d87c0 100644 --- a/atomic-cli/src/commands/git/import.rs +++ b/atomic-cli/src/commands/git/import.rs @@ -1344,7 +1344,7 @@ impl Import { // then the unambiguous Git HEAD-tree detection, the exact one the // preflight plan above used. The value is persisted immediately // after init so every later command reads the recorded policy. - let fresh_vault_tracked = if repo_exists { + let fresh_exclusions = if repo_exists { None } else { Some( @@ -1354,7 +1354,7 @@ impl Import { "cannot resolve the shim vault policy: {error}" )) }, - )? == atomic_repository::ExclusionPolicy::IncludeVault, + )?, ) }; @@ -1383,8 +1383,8 @@ impl Import { // (RFC §6.2): explicit and durable, so the conversion policy is // frozen for every later command instead of re-detected against a // moving HEAD. - if let Some(tracked) = fresh_vault_tracked { - super::parallel::record_imported_vault_policy(&repo, tracked)?; + if let Some(exclusions) = fresh_exclusions { + super::parallel::record_imported_vault_policy(&repo, exclusions.includes_vault())?; } // Enter the shared workspace boundary. Import is also the bootstrap @@ -1549,6 +1549,7 @@ impl Import { self.kind.as_deref(), self.no_vault, working_copy, + fresh_exclusions.is_some_and(|policy| policy.includes_atomic_ignore()), )?; } @@ -1712,6 +1713,7 @@ impl Import { self.kind.as_deref(), self.no_vault, working_copy, + fresh_exclusions.is_some_and(|policy| policy.includes_atomic_ignore()), )?; } @@ -2031,9 +2033,10 @@ fn init_atomicignore_and_vault( kind: Option<&str>, no_vault: bool, working_copy: WorkingCopyId, + git_tracks_atomic_ignore: bool, ) -> CliResult<()> { - // Step 1: .atomicignore - { + // Git import already recorded a tracked .atomicignore. + if !git_tracks_atomic_ignore { let ignore_path = workdir.join(".atomicignore"); if !ignore_path.exists() { // Use explicit --kind if provided, otherwise auto-detect from project files diff --git a/atomic-repository/src/repository/project_tree.rs b/atomic-repository/src/repository/project_tree.rs index ff188021..61242e1c 100644 --- a/atomic-repository/src/repository/project_tree.rs +++ b/atomic-repository/src/repository/project_tree.rs @@ -244,14 +244,29 @@ pub enum ExclusionReason { pub enum ExclusionPolicy { ShimPrivate, IncludeVault, + IncludeAtomicIgnore, + IncludeVaultAndAtomicIgnore, } impl ExclusionPolicy { + pub fn includes_vault(self) -> bool { + matches!(self, Self::IncludeVault | Self::IncludeVaultAndAtomicIgnore) + } + + pub fn includes_atomic_ignore(self) -> bool { + matches!( + self, + Self::IncludeAtomicIgnore | Self::IncludeVaultAndAtomicIgnore + ) + } + pub fn exclusion(self, path: &RepoPath) -> Option { - if atomic_private_path(path.as_bytes()) { + if atomic_private_path(path.as_bytes()) + && (path.as_bytes() != b".atomicignore" || !self.includes_atomic_ignore()) + { Some(ExclusionReason::AtomicPrivate) } else if path.components().next().unwrap_or_default() == b".vault" - && self == Self::ShimPrivate + && !self.includes_vault() { Some(ExclusionReason::VaultPrivate) } else { @@ -296,7 +311,7 @@ impl ExclusionPolicy { // repository) — the HEAD tree decides. match Repository::canonical_dot_dir(workdir) { Ok(dot_dir) => dot_dir, - Err(_) => return Ok(Self::from_git_head(git)), + Err(_) => return Ok(Self::from_git_head(git, None)), } }; let config_path = dot_dir.join("config.toml"); @@ -309,30 +324,35 @@ impl ExclusionPolicy { )) })?; if let Some(vault) = config.git.shim.vault { - return Ok(match vault { - atomic_config::ShimVaultPolicy::Tracked => Self::IncludeVault, - atomic_config::ShimVaultPolicy::Private => Self::ShimPrivate, - }); + return Ok(Self::from_git_head( + git, + Some(matches!(vault, atomic_config::ShimVaultPolicy::Tracked)), + )); } } } - Ok(Self::from_git_head(git)) + Ok(Self::from_git_head(git, None)) } - /// Auto-detect from the Git HEAD tree: does the tracked root tree hold - /// a `.vault` entry? An unborn or detached-without-commit HEAD reads - /// as untracked. - fn from_git_head(git: &git2::Repository) -> Self { - let tracks_vault = git + /// Resolve tracked root paths from Git HEAD, honoring the vault override. + fn from_git_head(git: &git2::Repository, vault_override: Option) -> Self { + let tree = git .head() .ok() .and_then(|head| head.peel_to_commit().ok()) - .and_then(|commit| commit.tree().ok()) - .is_some_and(|tree| tree.get_name(".vault").is_some()); - if tracks_vault { - Self::IncludeVault - } else { - Self::ShimPrivate + .and_then(|commit| commit.tree().ok()); + let tracked = |name| { + tree.as_ref() + .is_some_and(|tree| tree.get_name(name).is_some()) + }; + match ( + vault_override.unwrap_or_else(|| tracked(".vault")), + tracked(".atomicignore"), + ) { + (false, false) => Self::ShimPrivate, + (true, false) => Self::IncludeVault, + (false, true) => Self::IncludeAtomicIgnore, + (true, true) => Self::IncludeVaultAndAtomicIgnore, } } } @@ -584,6 +604,8 @@ impl ConversionPolicy { encoder.u8(match self.exclusions { ExclusionPolicy::ShimPrivate => 0, ExclusionPolicy::IncludeVault => 1, + ExclusionPolicy::IncludeAtomicIgnore => 2, + ExclusionPolicy::IncludeVaultAndAtomicIgnore => 3, }); encoder.u8(match self.losses { LossPolicy::Refuse => 0, From 6a42921f0a1e1bf983842ca25ce41639eca41fa6 Mon Sep 17 00:00:00 2001 From: Mark Hinkle Date: Sat, 14 Nov 2026 21:32:06 -0500 Subject: [PATCH 3/3] Clarify Git HEAD tracking for .atomicignore Signed-off-by: Mark Hinkle Agent-Vendor: codex --- atomic-cli/src/commands/git/import.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/atomic-cli/src/commands/git/import.rs b/atomic-cli/src/commands/git/import.rs index be3d87c0..186d3e5b 100644 --- a/atomic-cli/src/commands/git/import.rs +++ b/atomic-cli/src/commands/git/import.rs @@ -1379,10 +1379,9 @@ impl Import { repo }; - // Record the detected vault policy for a freshly created repository - // (RFC §6.2): explicit and durable, so the conversion policy is - // frozen for every later command instead of re-detected against a - // moving HEAD. + // Persist the detected vault policy for a freshly created repository + // (RFC §6.2). The independent .atomicignore policy follows Git HEAD + // so the projection includes the file exactly when Git tracks it. if let Some(exclusions) = fresh_exclusions { super::parallel::record_imported_vault_policy(&repo, exclusions.includes_vault())?; }