MCPcopy Index your code
hub / github.com/git/git / prepare_include_condition_pattern

Function prepare_include_condition_pattern

config.c:199–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static 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
238static int include_by_gitdir(const struct key_value_info *kvi,
239 const struct config_options *opts,

Callers 1

include_by_gitdirFunction · 0.85

Calls 9

interpolate_pathFunction · 0.85
strbuf_addstrFunction · 0.85
errorFunction · 0.85
strbuf_realpathFunction · 0.85
strbuf_spliceFunction · 0.85
is_absolute_pathFunction · 0.85
strbuf_insertstrFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected