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

Function read_branches_file

remote.c:381–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381static void read_branches_file(struct repository *repo, struct remote *remote)
382{
383 char *frag, *to_free = NULL;
384 struct strbuf buf = STRBUF_INIT;
385 FILE *f = fopen_or_warn(repo_git_path_append(repo, &buf,
386 "branches/%s", remote->name), "r");
387
388 if (!f)
389 goto out;
390
391 warn_about_deprecated_remote_type("branches", remote);
392
393 strbuf_getline_lf(&buf, f);
394 fclose(f);
395 strbuf_trim(&buf);
396 if (!buf.len)
397 goto out;
398
399 remote->configured_in_repo = 1;
400 remote->origin = REMOTE_BRANCHES;
401
402 /*
403 * The branches file would have URL and optionally
404 * #branch specified. The default (or specified) branch is
405 * fetched and stored in the local branch matching the
406 * remote name.
407 */
408 frag = strchr(buf.buf, '#');
409 if (frag)
410 *(frag++) = '\0';
411 else
412 frag = to_free = repo_default_branch_name(repo, 0);
413
414 add_url_alias(repo->remote_state, remote, buf.buf);
415 refspec_appendf(&remote->fetch, "refs/heads/%s:refs/heads/%s",
416 frag, remote->name);
417
418 /*
419 * Cogito compatible push: push current HEAD to remote #branch
420 * (master if missing)
421 */
422 refspec_appendf(&remote->push, "HEAD:refs/heads/%s", frag);
423 remote->fetch_tags = 1; /* always auto-follow */
424
425out:
426 strbuf_release(&buf);
427 free(to_free);
428}
429#endif /* WITH_BREAKING_CHANGES */
430
431static int handle_config(const char *key, const char *value,

Callers 1

remotes_remote_get_1Function · 0.85

Calls 9

fopen_or_warnFunction · 0.85
repo_git_path_appendFunction · 0.85
strbuf_getline_lfFunction · 0.85
strbuf_trimFunction · 0.85
repo_default_branch_nameFunction · 0.85
add_url_aliasFunction · 0.85
refspec_appendfFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected