MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / git_explicit_work_dir

Function git_explicit_work_dir

src/hooks/cursor_shell.rs:314–342  ·  view source on GitHub ↗
(tokens: &[String], cwd: &Path)

Source from the content-addressed store, hash-verified

312}
313
314fn git_explicit_work_dir(tokens: &[String], cwd: &Path) -> Option<PathBuf> {
315 let mut i = 1;
316 let mut explicit_work_dir = None;
317 while i < tokens.len() {
318 let token = &tokens[i];
319 match token.as_str() {
320 "-C" | "--work-tree" => {
321 let value = tokens.get(i + 1)?;
322 explicit_work_dir = Some(resolve_shell_path(cwd, value));
323 i += 2;
324 }
325 "-c" | "--git-dir" | "--namespace" | "--config-env" => i += 2,
326 _ if token.starts_with("--work-tree=") => {
327 let value = token.trim_start_matches("--work-tree=");
328 explicit_work_dir = Some(resolve_shell_path(cwd, value));
329 i += 1;
330 }
331 _ if token.starts_with("--git-dir=")
332 || token.starts_with("--namespace=")
333 || token.starts_with("--config-env=") =>
334 {
335 i += 1;
336 }
337 _ if token.starts_with('-') => i += 1,
338 _ => break,
339 }
340 }
341 explicit_work_dir
342}
343
344fn resolve_shell_path(cwd: &Path, value: &str) -> PathBuf {
345 let path = Path::new(value);

Callers 2

Calls 2

resolve_shell_pathFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected