git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git /objects directory created 755 by default?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 21, 2005, 15:35 UTC
Message-ID
<Pine.LNX.4.63.0512211502130.25834@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vlkyffcxp.fsf@assigned-by-dhcp.cox.net>
Hi,
On Tue, 20 Dec 2005, Junio C Hamano wrote:
> 	[shell]
>         	umask = 0002

If you don't use git-shell, because the same machine is used for other purposes, it makes sense to introduce

	[core]
		umask = 0002
How about this:

--- [PATCH] Introduce core.umask

This makes it possible to setup a shared git repository by setting
	[core]
		umask = 0002
int the template config file.
This patch makes sure even git-init-db uses it.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 init-db.c |   21 ++++++++++++++-------
 setup.c   |    4 ++++
 2 files changed, 18 insertions(+), 7 deletions(-)
faa7d4b101211ac1993d73bb3d02e8a6d2c40734
diff --git a/init-db.c b/init-db.c
index 41576bd..26812ce 100644
--- a/init-db.c
+++ b/init-db.c
@@ -164,6 +164,7 @@ static void create_default_files(const c
 	unsigned char sha1[20];
 	struct stat st1;
 	char repo_version_string[10];
+	mode_t mask, mask2;
 
 	if (len > sizeof(path)-50)
 		die("insane git directory %s", git_dir);
@@ -172,6 +173,19 @@ static void create_default_files(const c
 	if (len && path[len-1] != '/')
 		path[len++] = '/';
 
+	/* First copy the templates -- we might have the default
+	 * config file there, in which case we would want to read
+	 * from it after installing.
+	 * The config file may contain a umask...
+	 */
+	path[len] = 0;
+	umask(mask = umask(0));
+	copy_templates(path, len, template_path);
+	if (mask != (mask2 = umask(mask))) {
+		umask(mask2);
+		chmod(path, 0777 & ~mask2);
+	}
+
 	/*
 	 * Create .git/refs/{heads,tags}
 	 */
@@ -182,13 +196,6 @@ static void create_default_files(const c
 	strcpy(path + len, "refs/tags");
 	safe_create_dir(path);
 
-	/* First copy the templates -- we might have the default
-	 * config file there, in which case we would want to read
-	 * from it after installing.
-	 */
-	path[len] = 0;
-	copy_templates(path, len, template_path);
-
 	git_config(git_default_config);
 
 	/*
diff --git a/setup.c b/setup.c
index d3556ed..4e4cb46 100644
--- a/setup.c
+++ b/setup.c
@@ -180,6 +180,10 @@ int check_repository_format_version(cons
 {
        if (strcmp(var, "core.repositoryformatversion") == 0)
                repository_format_version = git_config_int(var, value);
+
+       else if (!strcmp(var, "core.umask"))
+	       umask(git_config_int(var, value));
+
        return 0;
 }
 
-- 
1.0.0
Previous: Ben CliffordNext: Junio C Hamano
Message 12 of 34 in “git /objects directory created 755 by default?”
  1. Martin LanghoffDec 20, 2005
  2. Junio C HamanoDec 20, 2005
  3. Junio C HamanoDec 21, 2005
  4. Martin LanghoffDec 21, 2005
  5. Junio C HamanoDec 21, 2005
  6. Martin LanghoffDec 21, 2005
  7. Junio C HamanoDec 21, 2005
  8. Martin LanghoffDec 21, 2005
  9. Junio C HamanoDec 21, 2005
  10. Martin LanghoffDec 21, 2005
  11. Ben CliffordDec 22, 2005
  12. Johannes SchindelinDec 21, 2005
  13. Junio C HamanoDec 21, 2005
  14. Johannes SchindelinDec 21, 2005
  15. Andreas EricssonDec 22, 2005
  16. Johannes SchindelinDec 22, 2005
  17. Andreas EricssonDec 22, 2005
  18. Johannes SchindelinDec 22, 2005
  19. Andreas EricssonDec 22, 2005
  20. Johannes SchindelinDec 22, 2005
  21. Andreas EricssonDec 22, 2005
  22. Johannes SchindelinDec 22, 2005
  23. Junio C HamanoDec 22, 2005
  24. Johannes SchindelinDec 22, 2005
  25. Junio C HamanoDec 22, 2005
  26. Johannes SchindelinDec 22, 2005
  27. Junio C HamanoDec 23, 2005
  28. Andreas EricssonDec 23, 2005
  29. Alex RiesenDec 22, 2005
  30. Johannes SchindelinDec 22, 2005
  31. Alex RiesenDec 22, 2005
  32. Johannes SchindelinDec 22, 2005
  33. Alex RiesenDec 22, 2005
  34. Johannes SchindelinDec 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.