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

Function safe_create_dir_in_gitdir

path.c:803–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

801}
802
803int safe_create_dir_in_gitdir(struct repository *repo, const char *path)
804{
805 if (mkdir(path, 0777)) {
806 int saved_errno = errno;
807 struct stat st;
808 struct strbuf sb = STRBUF_INIT;
809
810 if (errno != EEXIST)
811 return -1;
812 /*
813 * Are we looking at a path in a symlinked worktree
814 * whose original repository does not yet have it?
815 * e.g. .git/rr-cache pointing at its original
816 * repository in which the user hasn't performed any
817 * conflict resolution yet?
818 */
819 if (lstat(path, &st) || !S_ISLNK(st.st_mode) ||
820 strbuf_readlink(&sb, path, st.st_size) ||
821 !is_absolute_path(sb.buf) ||
822 mkdir(sb.buf, 0777)) {
823 strbuf_release(&sb);
824 errno = saved_errno;
825 return -1;
826 }
827 strbuf_release(&sb);
828 }
829 return adjust_shared_perm(repo, path);
830}
831
832static enum scld_error safe_create_leading_directories_1(struct repository *repo,
833 char *path)

Callers 4

do_plain_rerereFunction · 0.85
is_rerere_enabledFunction · 0.85
init_basic_stateFunction · 0.85

Calls 4

strbuf_readlinkFunction · 0.85
is_absolute_pathFunction · 0.85
strbuf_releaseFunction · 0.85
adjust_shared_permFunction · 0.85

Tested by

no test coverage detected