From: Junio C Hamano Date: Sat, 4 Nov 2006 20:24:05 +0000 (-0800) Subject: adjust_shared_perm: chmod() only when needed. X-Git-Tag: v1.4.4-rc1~1^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fe732edee10f9b241c8df9b4ea081a4f33ad3968;p=git.git 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 --- diff --git a/path.c b/path.c index bb89fb02d..d2c076d7c 100644 --- a/path.c +++ b/path.c @@ -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; }