Whether `path` may not be recorded, from a sandbox or otherwise. Refused in two cases: the path is not a plain relative path, or it names the repository's own machinery. The first is not a nicety. A submitted change lands in `TREE`, and the next materialize or view switch writes `root.join(path)` — so `../../elsewhere/x` escapes the working tree, with no local user in the loop when a remote token
(path: &str)
| 166 | /// An empty path is not a path: a `FileOps` group for a token-level operation |
| 167 | /// names an inode and carries no path, and there is nothing to escape with. |
| 168 | pub(crate) fn forbidden_path(path: &str) -> bool { |
| 169 | if path.is_empty() { |
| 170 | return false; |
| 171 | } |
| 172 | let relative = std::path::Path::new(path); |
| 173 | if relative.is_absolute() { |
| 174 | return true; |
| 175 | } |
| 176 | // `components()` collapses repeated separators, so `src//main.rs` would |
| 177 | // read here as two plain names — and then reach `TREE` as a path no |
| 178 | // materialization can ever put a file at, because the write normalizes it |
| 179 | // back to `src/main.rs`. |
| 180 | if path.contains("//") || path.ends_with('/') { |
| 181 | return true; |
| 182 | } |
| 183 | relative.components().any(|part| match part { |
| 184 | // Not `Normal` means empty, `.`, `..`, or a root/prefix: none of which |
| 185 | // a tracked file may have. |
| 186 | std::path::Component::Normal(name) => { |
| 187 | name == crate::DOT_DIR |
| 188 | || name == super::SANDBOX_POINTER |
| 189 | || name == super::SANDBOX_CACHE_DIR |
| 190 | } |
| 191 | _ => true, |
| 192 | }) |
| 193 | } |
| 194 | |
| 195 | /// Where a materialized entry may land: inside `dir`, and nowhere else. |
| 196 | /// |
no test coverage detected