[PATCH 1/2] optimize set_shared_perm() in path.c:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All calls to set_shared_perm() use mode == 0, so simplify the function.

All callers use the macro adjust_shared_perm(path) from cache.h,
convert adjust_shared_perm() from a macro into a function prototype

Since path.c has much more functions than just mkpath(),
improve a stale comment about path.c

Signed-off-by: Torsten Bögershausen <tboegi@xxxxxx>
---
 cache.h |  3 +--
 path.c  | 27 +++++++--------------------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/cache.h b/cache.h
index c12957b..e1e8ce8 100644
--- a/cache.h
+++ b/cache.h
@@ -719,8 +719,7 @@ enum sharedrepo {
 	PERM_EVERYBODY      = 0664
 };
 int git_config_perm(const char *var, const char *value);
-int set_shared_perm(const char *path, int mode);
-#define adjust_shared_perm(path) set_shared_perm((path), 0)
+int adjust_shared_perm(const char *path);
 int safe_create_leading_directories(char *path);
 int safe_create_leading_directories_const(const char *path);
 int mkdir_in_gitdir(const char *path);
diff --git a/path.c b/path.c
index 2fdccc2..427312e 100644
--- a/path.c
+++ b/path.c
@@ -1,14 +1,5 @@
 /*
- * I'm tired of doing "vsnprintf()" etc just to open a
- * file, so here's a "return static buffer with printf"
- * interface for paths.
- *
- * It's obviously not thread-safe. Sue me. But it's quite
- * useful for doing things like
- *
- *   f = open(mkpath("%s/%s.git", base, name), O_RDONLY);
- *
- * which is what it's designed for.
+ * Different utilitiy functions for path and path names
  */
 #include "cache.h"
 #include "strbuf.h"
@@ -405,21 +396,17 @@ const char *enter_repo(const char *path, int strict)
 	return NULL;
 }
 
-int set_shared_perm(const char *path, int mode)
+int adjust_shared_perm(const char *path)
 {
-	int tweak, shared, orig_mode;
+	int tweak, shared, orig_mode, mode;
 
 	if (!shared_repository) {
-		if (mode)
-			return chmod(path, mode & ~S_IFMT);
 		return 0;
 	}
-	if (!mode) {
-		if (get_st_mode_bits(path, &mode) < 0)
-			return -1;
-		orig_mode = mode;
-	} else
-		orig_mode = 0;
+	if (get_st_mode_bits(path, &mode) < 0)
+		return -1;
+
+	orig_mode = mode;
 	if (shared_repository < 0)
 		shared = -shared_repository;
 	else
-- 
1.8.2.341.g543621f


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]