| 226 | } |
| 227 | |
| 228 | static bool expand_git_path(const char *path, char *out, size_t out_sz) { |
| 229 | if (!path || !path[0] || !out || out_sz == 0) { |
| 230 | return false; |
| 231 | } |
| 232 | char normalized[CBM_SZ_4K]; |
| 233 | snprintf(normalized, sizeof(normalized), "%s", path); |
| 234 | cbm_normalize_path_sep(normalized); |
| 235 | |
| 236 | if (normalized[0] != '~') { |
| 237 | snprintf(out, out_sz, "%s", normalized); |
| 238 | cbm_normalize_path_sep(out); |
| 239 | return out[0] != '\0'; |
| 240 | } |
| 241 | |
| 242 | if (normalized[1] != '\0' && normalized[1] != '/') { |
| 243 | return false; /* ~user expansion is intentionally not supported. */ |
| 244 | } |
| 245 | |
| 246 | const char *home = cbm_get_home_dir(); |
| 247 | if (!home || home[0] == '\0') { |
| 248 | return false; |
| 249 | } |
| 250 | if (normalized[1] == '\0') { |
| 251 | snprintf(out, out_sz, "%s", home); |
| 252 | cbm_normalize_path_sep(out); |
| 253 | } else { |
| 254 | path_join(out, out_sz, home, normalized + GIT_TILDE_PREFIX_LEN); |
| 255 | } |
| 256 | return out[0] != '\0'; |
| 257 | } |
| 258 | |
| 259 | static bool read_core_excludes_file(const char *config_path, char *out, size_t out_sz) { |
| 260 | FILE *f = cbm_fopen(config_path, "r"); |
no test coverage detected