Skip to content

Commit

Permalink
adjust_shared_perm: chmod() only when needed.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Nov 6, 2006
1 parent 49b8b29 commit fe732ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion path.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit fe732ed

Please sign in to comment.