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

Function write_worktree_linking_files

worktree.c:1092–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090}
1091
1092void write_worktree_linking_files(const char *dotgit, const char *gitdir,
1093 int use_relative_paths)
1094{
1095 struct strbuf path = STRBUF_INIT;
1096 struct strbuf repo = STRBUF_INIT;
1097 struct strbuf tmp = STRBUF_INIT;
1098
1099 strbuf_addstr(&path, dotgit);
1100 strbuf_strip_suffix(&path, "/.git");
1101 strbuf_realpath(&path, path.buf, 1);
1102 strbuf_addstr(&repo, gitdir);
1103 strbuf_strip_suffix(&repo, "/gitdir");
1104 strbuf_realpath(&repo, repo.buf, 1);
1105
1106 if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
1107 if (upgrade_repository_format(the_repository, 1) < 0)
1108 die(_("unable to upgrade repository format to support relative worktrees"));
1109 if (repo_config_set_gently(the_repository, "extensions.relativeWorktrees", "true"))
1110 die(_("unable to set extensions.relativeWorktrees setting"));
1111 the_repository->repository_format_relative_worktrees = 1;
1112 }
1113
1114 if (use_relative_paths) {
1115 write_file(gitdir, "%s/.git", relative_path(path.buf, repo.buf, &tmp));
1116 write_file(dotgit, "gitdir: %s", relative_path(repo.buf, path.buf, &tmp));
1117 } else {
1118 write_file(gitdir, "%s/.git", path.buf);
1119 write_file(dotgit, "gitdir: %s", repo.buf);
1120 }
1121
1122 strbuf_release(&path);
1123 strbuf_release(&repo);
1124 strbuf_release(&tmp);
1125}

Callers 5

update_worktree_locationFunction · 0.85
repair_gitfileFunction · 0.85
repair_worktree_at_pathFunction · 0.85
add_worktreeFunction · 0.85

Calls 9

strbuf_addstrFunction · 0.85
strbuf_strip_suffixFunction · 0.85
strbuf_realpathFunction · 0.85
repo_config_set_gentlyFunction · 0.85
write_fileFunction · 0.85
relative_pathFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected