Skip to contentSkip to conversation

optimize set_shared_perm()

RFC New Torsten Bögershausen 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

RFC 1/1 optimize set_shared_perm()

optimize set_shared_perm() in path.c:

- sometimes the chown() function is called even when not needed. (This can be provoced by running t1301, and adding some debug code)

Save a chmod from 400 to 400, or from 600->600 on these files:
.git/info/refs+
.git/objects/info/packs+

Save chmod on directories from 2770 to 2770:
.git/refs
.git/refs/heads
.git/refs/tags

- as all callers use mode == 0 when caling set_shared_perm(), the function can be simplified.
- all callers use the macro adjust_shared_perm(path) from cache.h Convert adjust_shared_perm() from a macro into a function prototype

---
 cache.h |  3 +--
 path.c  | 75 +++++++++++++++++++++++++++++++++++------------------------------
 2 files changed, 41 insertions(+), 37 deletions(-)

While investigating why cygwin 1.7 failes in t1301, and cygwin 1.5 passes, I came across a small refactoring.

My apologizes if the refactoring in line 431 is wrong:

	if (((shared_repository < 0
	      ? (orig_mode & (FORCE_DIR_SET_GID | 0777))
	      : (orig_mode & mode)) != mode) &&
	    chmod(path, (mode & ~S_IFMT)) < 0)
cache.h +1 -2
index 2b192d2..9ea9c70 100644
@@ -700,8 +700,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);
path.c +40 -35

100 lines not on this page · raw message

Signature · 1 line
1.8.1.1