MCPcopy Create free account
hub / github.com/git/git / compute_alternate_path

Function compute_alternate_path

odb.c:274–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274char *compute_alternate_path(const char *path, struct strbuf *err)
275{
276 char *ref_git = NULL;
277 const char *repo;
278 int seen_error = 0;
279
280 ref_git = real_pathdup(path, 0);
281 if (!ref_git) {
282 seen_error = 1;
283 strbuf_addf(err, _("path '%s' does not exist"), path);
284 goto out;
285 }
286
287 repo = read_gitfile(ref_git);
288 if (!repo)
289 repo = read_gitfile(mkpath("%s/.git", ref_git));
290 if (repo) {
291 free(ref_git);
292 ref_git = xstrdup(repo);
293 }
294
295 if (!repo && is_directory(mkpath("%s/.git/objects", ref_git))) {
296 char *ref_git_git = mkpathdup("%s/.git", ref_git);
297 free(ref_git);
298 ref_git = ref_git_git;
299 } else if (!is_directory(mkpath("%s/objects", ref_git))) {
300 struct strbuf sb = STRBUF_INIT;
301 seen_error = 1;
302 if (get_common_dir(&sb, ref_git)) {
303 strbuf_addf(err,
304 _("reference repository '%s' as a linked "
305 "checkout is not supported yet."),
306 path);
307 goto out;
308 }
309
310 strbuf_addf(err, _("reference repository '%s' is not a "
311 "local repository."), path);
312 goto out;
313 }
314
315 if (!access(mkpath("%s/shallow", ref_git), F_OK)) {
316 strbuf_addf(err, _("reference repository '%s' is shallow"),
317 path);
318 seen_error = 1;
319 goto out;
320 }
321
322 if (!access(mkpath("%s/info/grafts", ref_git), F_OK)) {
323 strbuf_addf(err,
324 _("reference repository '%s' is grafted"),
325 path);
326 seen_error = 1;
327 goto out;
328 }
329
330out:
331 if (seen_error) {

Callers 2

add_one_referenceFunction · 0.85

Calls 7

real_pathdupFunction · 0.85
strbuf_addfFunction · 0.85
mkpathFunction · 0.85
xstrdupFunction · 0.85
is_directoryFunction · 0.85
mkpathdupFunction · 0.85
get_common_dirFunction · 0.85

Tested by

no test coverage detected