The CLI owns the separate Git coordination boundary, including ordinary status/diff adoption. Release it before issuing an observation-only RPC; the handler then independently verifies its workspace lease. Forensic flags and record dry-run never enter this mutating boundary.
(allow_git_operation: bool)
| 96 | /// the handler then independently verifies its workspace lease. Forensic |
| 97 | /// flags and record dry-run never enter this mutating boundary. |
| 98 | pub(crate) fn prepare_service_query(allow_git_operation: bool) -> CliResult<bool> { |
| 99 | let Ok(root) = super::find_repository_root() else { |
| 100 | return Ok(true); |
| 101 | }; |
| 102 | let repo = Repository::open_readonly_wait(&root, atomic_repository::database_lock_wait()) |
| 103 | .map_err(CliError::Repository)?; |
| 104 | if !repo.shim_workspace_active().map_err(CliError::Repository)? { |
| 105 | return Ok(true); |
| 106 | } |
| 107 | drop(repo); |
| 108 | if let Some(remediation) = |
| 109 | Repository::preflight_workspace_boundary(&root).map_err(CliError::Repository)? |
| 110 | { |
| 111 | if allow_git_operation |
| 112 | && matches!( |
| 113 | &remediation, |
| 114 | WorkspaceRemediation::GitOperationInProgress { .. } |
| 115 | ) |
| 116 | { |
| 117 | return Ok(false); |
| 118 | } |
| 119 | return Err(remediation_error(remediation)); |
| 120 | } |
| 121 | let mut repo = Repository::open_for_workspace_transaction_wait( |
| 122 | &root, |
| 123 | atomic_repository::database_lock_wait(), |
| 124 | ) |
| 125 | .map_err(CliError::Repository)?; |
| 126 | match repo |
| 127 | .begin_workspace_txn(WorkspaceTxnMode::Reconcile) |
| 128 | .map_err(CliError::Repository)? |
| 129 | { |
| 130 | WorkspaceTxnStart::Ready(_) => Ok(true), |
| 131 | // The wire cannot carry the #207 Git-operation diagnostic. Its native |
| 132 | // renderer still reports this state without changing the working copy. |
| 133 | WorkspaceTxnStart::Remediation(WorkspaceRemediation::GitOperationInProgress { .. }) |
| 134 | if allow_git_operation => |
| 135 | { |
| 136 | Ok(false) |
| 137 | } |
| 138 | WorkspaceTxnStart::Remediation(remediation) => Err(remediation_error(remediation)), |
| 139 | } |
| 140 | } |
no test coverage detected