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

Function handle_path_include

config.c:142–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140" %s\n"
141"This might be due to circular includes.");
142static int handle_path_include(const struct key_value_info *kvi,
143 const char *path,
144 struct config_include_data *inc)
145{
146 int ret = 0;
147 struct strbuf buf = STRBUF_INIT;
148 char *expanded;
149
150 if (!path)
151 return config_error_nonbool("include.path");
152
153 expanded = interpolate_path(path, 0);
154 if (!expanded)
155 return error(_("could not expand include path '%s'"), path);
156 path = expanded;
157
158 /*
159 * Use an absolute path as-is, but interpret relative paths
160 * based on the including config file.
161 */
162 if (!is_absolute_path(path)) {
163 const char *slash;
164
165 if (!kvi || kvi->origin_type != CONFIG_ORIGIN_FILE) {
166 ret = error(_("relative config includes must come from files"));
167 goto cleanup;
168 }
169
170 slash = find_last_dir_sep(kvi->filename);
171 if (slash)
172 strbuf_add(&buf, kvi->filename, slash - kvi->filename + 1);
173 strbuf_addstr(&buf, path);
174 path = buf.buf;
175 }
176
177 if (!access_or_die(path, R_OK, 0)) {
178 if (++inc->depth > MAX_INCLUDE_DEPTH)
179 die(_(include_depth_advice), MAX_INCLUDE_DEPTH, path,
180 !kvi ? "<unknown>" :
181 kvi->filename ? kvi->filename :
182 "the command line");
183 ret = git_config_from_file_with_options(git_config_include, path, inc,
184 kvi->scope, NULL);
185 inc->depth--;
186 }
187cleanup:
188 strbuf_release(&buf);
189 free(expanded);
190 return ret;
191}
192
193static void add_trailing_starstar_for_dir(struct strbuf *pat)
194{

Callers 1

git_config_includeFunction · 0.85

Calls 10

config_error_nonboolFunction · 0.85
interpolate_pathFunction · 0.85
errorFunction · 0.85
is_absolute_pathFunction · 0.85
strbuf_addFunction · 0.85
strbuf_addstrFunction · 0.85
access_or_dieFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected