MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / normalize_project_arg

Function normalize_project_arg

src/mcp/mcp.c:1650–1671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1648static char *resolve_path_owner(const char *path, char *derived); /* #1690, defined below */
1649
1650static char *normalize_project_arg(char *project) {
1651 if (!project) {
1652 return project;
1653 }
1654 char *normalized = NULL;
1655 bool bare = !strchr(project, '/') && !strchr(project, '\\');
1656 if (bare) {
1657 if (has_non_ascii_byte(project)) {
1658 normalized = cbm_project_name_sanitize(project);
1659 }
1660 } else {
1661 project = canonicalize_repo_path_if_exists(project);
1662 normalized = cbm_project_name_from_path(project);
1663 if (normalized) {
1664 normalized = resolve_path_owner(project, normalized);
1665 }
1666 }
1667 /* Keep exactly one of the two strings and release the other. */
1668 bool use_normalized = normalized && (!bare || bare_project_encoding_usable(normalized));
1669 free(use_normalized ? project : normalized);
1670 return use_normalized ? normalized : project;
1671}
1672
1673/* Forward decls — defined below alongside store resolution. */
1674static const char *cache_dir(char *buf, size_t bufsz);

Callers 1

get_project_argFunction · 0.85

Calls 6

has_non_ascii_byteFunction · 0.85
resolve_path_ownerFunction · 0.85

Tested by

no test coverage detected