| 1648 | static char *resolve_path_owner(const char *path, char *derived); /* #1690, defined below */ |
| 1649 | |
| 1650 | static 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. */ |
| 1674 | static const char *cache_dir(char *buf, size_t bufsz); |
no test coverage detected