X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=path.c;h=5168b5f17dfc63bfaf5386e779806fba052edf49;hb=1a82e79315ed633f6b0b1fc4076054950c5380d3;hp=334b2bd195f56ac6aaf9f9b8a36fe59115cd758c;hpb=423325a2d24638ddcc82ce47be5e40be550f4507;p=git.git diff --git a/path.c b/path.c index 334b2bd1..5168b5f1 100644 --- a/path.c +++ b/path.c @@ -250,3 +250,26 @@ char *enter_repo(char *path, int strict) return NULL; } + +int adjust_shared_perm(const char *path) +{ + struct stat st; + int mode; + + if (!shared_repository) + return 0; + if (lstat(path, &st) < 0) + return -1; + mode = st.st_mode; + if (mode & S_IRUSR) + mode |= S_IRGRP; + if (mode & S_IWUSR) + mode |= S_IWGRP; + if (mode & S_IXUSR) + mode |= S_IXGRP; + if (S_ISDIR(mode)) + mode |= S_ISGID; + if (chmod(path, mode) < 0) + return -2; + return 0; +}