| 215 | } |
| 216 | |
| 217 | static bool expand_git_path(const char *path, char *out, size_t out_sz) { |
| 218 | if (!path || !path[0] || !out || out_sz == 0) { |
| 219 | return false; |
| 220 | } |
| 221 | char normalized[CBM_SZ_4K]; |
| 222 | snprintf(normalized, sizeof(normalized), "%s", path); |
| 223 | cbm_normalize_path_sep(normalized); |
| 224 | |
| 225 | if (normalized[0] != '~') { |
| 226 | snprintf(out, out_sz, "%s", normalized); |
| 227 | cbm_normalize_path_sep(out); |
| 228 | return out[0] != '\0'; |
| 229 | } |
| 230 | |
| 231 | if (normalized[1] != '\0' && normalized[1] != '/') { |
| 232 | return false; /* ~user expansion is intentionally not supported. */ |
| 233 | } |
| 234 | |
| 235 | const char *home = cbm_get_home_dir(); |
| 236 | if (!home || home[0] == '\0') { |
| 237 | return false; |
| 238 | } |
| 239 | if (normalized[1] == '\0') { |
| 240 | snprintf(out, out_sz, "%s", home); |
| 241 | cbm_normalize_path_sep(out); |
| 242 | } else { |
| 243 | path_join(out, out_sz, home, normalized + GIT_TILDE_PREFIX_LEN); |
| 244 | } |
| 245 | return out[0] != '\0'; |
| 246 | } |
| 247 | |
| 248 | static bool read_core_excludes_file(const char *config_path, char *out, size_t out_sz) { |
| 249 | FILE *f = cbm_fopen(config_path, "r"); |
no test coverage detected