Skip to content

Commit 3a429d3

Browse files
tboegigitster
authored andcommitted
path.c: simplify adjust_shared_perm()
All calls to set_shared_perm() use mode == 0, so simplify the function. Because all callers use the macro adjust_shared_perm(path) from cache.h to call this function, convert it to a proper function, losing set_shared_perm(). Since path.c has much more functions than just mkpath() these days, drop the stale comment about it. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0117c2f commit 3a429d3

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

cache.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,7 @@ enum sharedrepo {
713713
PERM_EVERYBODY = 0664
714714
};
715715
int git_config_perm(const char *var, const char *value);
716-
int set_shared_perm(const char *path, int mode);
717-
#define adjust_shared_perm(path) set_shared_perm((path), 0)
716+
int adjust_shared_perm(const char *path);
718717
int safe_create_leading_directories(char *path);
719718
int safe_create_leading_directories_const(const char *path);
720719
int mkdir_in_gitdir(const char *path);

path.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
/*
2-
* I'm tired of doing "vsnprintf()" etc just to open a
3-
* file, so here's a "return static buffer with printf"
4-
* interface for paths.
5-
*
6-
* It's obviously not thread-safe. Sue me. But it's quite
7-
* useful for doing things like
8-
*
9-
* f = open(mkpath("%s/%s.git", base, name), O_RDONLY);
10-
*
11-
* which is what it's designed for.
2+
* Utilities for paths and pathnames
123
*/
134
#include "cache.h"
145
#include "strbuf.h"
@@ -405,21 +396,17 @@ const char *enter_repo(const char *path, int strict)
405396
return NULL;
406397
}
407398

408-
int set_shared_perm(const char *path, int mode)
399+
int adjust_shared_perm(const char *path)
409400
{
410-
int tweak, shared, orig_mode;
401+
int tweak, shared, orig_mode, mode;
411402

412403
if (!shared_repository) {
413-
if (mode)
414-
return chmod(path, mode & ~S_IFMT);
415404
return 0;
416405
}
417-
if (!mode) {
418-
if (get_st_mode_bits(path, &mode) < 0)
419-
return -1;
420-
orig_mode = mode;
421-
} else
422-
orig_mode = 0;
406+
if (get_st_mode_bits(path, &mode) < 0)
407+
return -1;
408+
409+
orig_mode = mode;
423410
if (shared_repository < 0)
424411
shared = -shared_repository;
425412
else

0 commit comments

Comments
 (0)