Walk from `start` up to `stop` (inclusive), collecting every existing occurrence of `target` (a relative path like "AGENTS.md").
(target: &str, start: &Path, stop: &Path)
| 86 | /// Walk from `start` up to `stop` (inclusive), collecting every existing |
| 87 | /// occurrence of `target` (a relative path like "AGENTS.md"). |
| 88 | fn find_up(target: &str, start: &Path, stop: &Path) -> Vec<PathBuf> { |
| 89 | let mut current = normalize(start); |
| 90 | let stop = normalize(stop); |
| 91 | let mut result = Vec::new(); |
| 92 | loop { |
| 93 | let candidate = current.join(target); |
| 94 | if candidate.exists() { |
| 95 | result.push(candidate); |
| 96 | } |
| 97 | if current == stop { |
| 98 | break; |
| 99 | } |
| 100 | match current.parent() { |
| 101 | Some(p) if p != current => current = p.to_path_buf(), |
| 102 | _ => break, |
| 103 | } |
| 104 | } |
| 105 | result |
| 106 | } |
| 107 | /// Detect the worktree root by walking up from `start` looking for `.git`. |
| 108 | /// Returns the directory containing `.git`, or the filesystem root. |
| 109 | fn detect_worktree_root(start: &Path) -> PathBuf { |