| 197 | } |
| 198 | |
| 199 | static int prepare_include_condition_pattern(const struct key_value_info *kvi, |
| 200 | struct strbuf *pat, |
| 201 | size_t *out) |
| 202 | { |
| 203 | struct strbuf path = STRBUF_INIT; |
| 204 | char *expanded; |
| 205 | size_t prefix = 0; |
| 206 | |
| 207 | expanded = interpolate_path(pat->buf, 1); |
| 208 | if (expanded) { |
| 209 | strbuf_reset(pat); |
| 210 | strbuf_addstr(pat, expanded); |
| 211 | free(expanded); |
| 212 | } |
| 213 | |
| 214 | if (pat->buf[0] == '.' && is_dir_sep(pat->buf[1])) { |
| 215 | const char *slash; |
| 216 | |
| 217 | if (!kvi || kvi->origin_type != CONFIG_ORIGIN_FILE) |
| 218 | return error(_("relative config include " |
| 219 | "conditionals must come from files")); |
| 220 | |
| 221 | strbuf_realpath(&path, kvi->filename, 1); |
| 222 | slash = find_last_dir_sep(path.buf); |
| 223 | if (!slash) |
| 224 | BUG("how is this possible?"); |
| 225 | strbuf_splice(pat, 0, 1, path.buf, slash - path.buf); |
| 226 | prefix = slash - path.buf + 1 /* slash */; |
| 227 | } else if (!is_absolute_path(pat->buf)) |
| 228 | strbuf_insertstr(pat, 0, "**/"); |
| 229 | |
| 230 | add_trailing_starstar_for_dir(pat); |
| 231 | |
| 232 | *out = prefix; |
| 233 | |
| 234 | strbuf_release(&path); |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | static int include_by_gitdir(const struct key_value_info *kvi, |
| 239 | const struct config_options *opts, |
no test coverage detected