Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Make core.sharedRepository more generic (version 3)

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:29

Heikki Orsila [off-list ref] writes:
Version 2 handles the directory x flags better than version 1.

Version 3 removes a warning for the o+w case, fixes a compatibility
problem with older Git's, and corrects some style issues.
These four lines should come after "---", as you will have only one commit
in the history for this topic, and the original and the version 2 won't be
there.
quoted hunk
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 2854868..f49fea0 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -400,9 +400,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		char buf[10];
 		/* We do not spell "group" and such, so that
 		 * the configuration can be read by older version
-		 * of git.
+		 * of git. Note, we use octal numbers for new share modes.
 		 */
-		sprintf(buf, "%d", shared_repository);
+		if (shared_repository <= 2)
+			sprintf(buf, "%d", shared_repository);
+		else
+			sprintf(buf, "0%o", shared_repository);
Hmmmm.  shared_repostiory variable is assigned the return value of
git_config_perm() and that function does not return OLD_* variants (which
is a good thing to do), so I do not think if it can ever be "<= 2".

When running "git init" without "--shared" or "--shared=<something>" in an
repository already initialized with git 1.5.5 or order as "shared", I
think you rewrite .git/config to use 0660.  You would need something like
this instead:

	if (shared_repository == PERM_GROUP)
        	strcpy(buf, "1");
	else if (shared_repository == PERM_EVERYBODY))
        	strcpy(buf, "2");
	else ...
+	/*
+	 * Mask filemode value. Others can not get write permission.
+	 * x flags for directories are handled separately.
+	 */
+	return i & 0664;
You are still dropping o+w even when the user explicitly asks for it, and
you are not telling that you are disobeying the user anymore.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help