| 801 | } |
| 802 | |
| 803 | int 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 | |
| 832 | static enum scld_error safe_create_leading_directories_1(struct repository *repo, |
| 833 | char *path) |
no test coverage detected