adjust_shared_perm: chmod() only when needed.

When widening permission for files and directories in a 'shared'
repository for a user with inappropriate umask() setting for
shared work, make sure we call chmod() only when we actually
need to.

The primary idea owes credit to Johannes.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2006-11-04 12:24:05 -08:00
parent 49b8b2926f
commit fe732edee1

2
path.c
View File

@ -279,7 +279,7 @@ int adjust_shared_perm(const char *path)
: 0));
if (S_ISDIR(mode))
mode |= S_ISGID;
if (chmod(path, mode) < 0)
if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
return -2;
return 0;
}