path: remove redundant function calls

We fetch the exact same setting up to four times.
We fix this by evaluating it once, storing it in a local variable,
and referencing that variable.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
K Jayatheerth
2026-03-02 19:51:38 +05:30
committed by Junio C Hamano
parent 68c14c2a03
commit c815ab0acd

10
path.c
View File

@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,
int mode)
{
int tweak;
if (repo_settings_get_shared_repository(repo) < 0)
tweak = -repo_settings_get_shared_repository(repo);
int shared_repo = repo_settings_get_shared_repository(repo);
if (shared_repo < 0)
tweak = -shared_repo;
else
tweak = repo_settings_get_shared_repository(repo);
tweak = shared_repo;
if (!(mode & S_IWUSR))
tweak &= ~0222;
if (mode & S_IXUSR)
/* Copy read bits to execute bits */
tweak |= (tweak & 0444) >> 2;
if (repo_settings_get_shared_repository(repo) < 0)
if (shared_repo < 0)
mode = (mode & ~0777) | tweak;
else
mode |= tweak;