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>
Junio C Hamano committed
Nov 4, 2006 at 12:24 UTC
fe732edee10f9b241c8df9b4ea081a4f33ad3968
1 file changed
+1
-1
path.c
+1
-1
@@ -279,7 +279,7 @@ int adjust_shared_perm(const char *path)
279
: 0));
280
if (S_ISDIR(mode))
281
mode |= S_ISGID;
282
- if (chmod(path, mode) < 0)
282
+ if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
283
return -2;
284
return 0;
285
}