mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Make core.sharedRepository more generic
git init --shared=0xxx, where '0xxx' is an octal number, will create a repository with file modes set to '0xxx'. Users with a safe umask value (0077) can use this option to force file modes. For example, '0640' is a group-readable but not group-writable regardless of user's umask value. Values compatible with old Git versions are written as they were before, for compatibility reasons. That is, "1" for "group" and "2" for "everybody". "git config core.sharedRepository 0xxx" is also handled. Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a17b1d2f0b
commit
06cbe85503
31
path.c
31
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 (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 (mode & S_IXUSR)
|
||||
mode |= (shared_repository == PERM_GROUP
|
||||
? S_IXGRP
|
||||
: (shared_repository == PERM_EVERYBODY
|
||||
? (S_IXGRP|S_IXOTH)
|
||||
: 0));
|
||||
if (S_ISDIR(mode))
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user