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 <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Torsten Bögershausen committed
Mar 30, 2013 at 10:53 UTC
3a429d3b8d03c98fbc775eb34a54b7b2bd74e02b
2 files changed
+8
-22
cache.h
+1
-2
@@ -713,8 +713,7 @@ enum sharedrepo {
713
PERM_EVERYBODY = 0664
714
};
715
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);
717
int safe_create_leading_directories(char *path);
718
int safe_create_leading_directories_const(const char *path);
719
int mkdir_in_gitdir(const char *path);
path.c
+7
-20
@@ -1,14 +1,5 @@
1
/*
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
3
*/
4
#include "cache.h"
5
#include "strbuf.h"
@@ -405,21 +396,17 @@ const char *enter_repo(const char *path, int strict)
396
return NULL;
397
}
398
408
-int set_shared_perm(const char *path, int mode)
399
+int adjust_shared_perm(const char *path)
400
{
410
- int tweak, shared, orig_mode;
401
+ int tweak, shared, orig_mode, mode;
402
403
if (!shared_repository) {
413
- if (mode)
414
- return chmod(path, mode & ~S_IFMT);
404
return 0;
405
}
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;
410
if (shared_repository < 0)
411
shared = -shared_repository;
412
else