summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-04-25 19:17:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-04-25 19:17:45 (GMT)
commit36c79d2bf893b9957688a6c8c13cc0bf0589e596 (patch)
tree39c9815e82d5fffdb537ea9bfd6cf71359dec845 /path.c
parent049a226fa14fb25c03d2146c2f8f184cfea5e5bf (diff)
parent06cbe8550324e0fd2290839bf3b9a92aa53b70ab (diff)
downloadgit-36c79d2bf893b9957688a6c8c13cc0bf0589e596.zip
git-36c79d2bf893b9957688a6c8c13cc0bf0589e596.tar.gz
git-36c79d2bf893b9957688a6c8c13cc0bf0589e596.tar.bz2
Merge branch 'ho/shared'
* ho/shared: Make core.sharedRepository more generic
Diffstat (limited to 'path.c')
-rw-r--r--path.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/path.c b/path.c
index f4ed979..2ae7cd9 100644
--- a/path.c
+++ b/path.c
@@ -266,24 +266,25 @@ int adjust_shared_perm(const char *path)
if (lstat(path, &st) < 0)
return -1;
mode = st.st_mode;
- if (mode & S_IRUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IRGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IRGRP|S_IROTH)
- : 0));
-
- if (mode & S_IWUSR)
- mode |= S_IWGRP;
-
- if (mode & S_IXUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IXGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IXGRP|S_IXOTH)
- : 0));
- if (S_ISDIR(mode))
+
+ if (shared_repository) {
+ int tweak = shared_repository;
+ if (!(mode & S_IWUSR))
+ tweak &= ~0222;
+ mode = (mode & ~0777) | tweak;
+ } else {
+ /* Preserve old PERM_UMASK behaviour */
+ if (mode & S_IWUSR)
+ mode |= S_IWGRP;
+ }
+
+ if (S_ISDIR(mode)) {
mode |= FORCE_DIR_SET_GID;
+
+ /* Copy read bits to execute bits */
+ mode |= (shared_repository & 0444) >> 2;
+ }
+
if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
return -2;
return 0;