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

Re: git /objects directory created 755 by default?

From
Junio C Hamano <junkio@cox.net>
Date
Dec 21, 2005, 01:37 UTC
Message-ID
<7vlkyffcxp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vacevgwqr.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 11 quoted lines
> Martin Langhoff <martin.langhoff@gmail.com> writes:
>
>> Since git changed to creating the objects subdirectories "on demand",
>> these are created 755 regardless of the user's umask. This is quite
>> inconvenient in ("cvs style") team-shared repositories, which work
>> great otherwise.
>
> Hmph.
>
> I have 002 as umask. .git/objects or .git/objects/[0-9a-f]{2}
> directories are created 0775 for me.

Martin, is this happening when your developers push into the shared repo? If so, do your developers use git-shell? Do their umask set properly even when they come over ssh and gets into noninteractive shell? What do they see when they do this?

	$ ssh shared.repo.machine.example.com umask

the answer may wall be "What do you think I am, A shell?", or 0022.

The git-shell command is designed to be not git aware (it does not know how a git repository looks like, nor does not know all the commands it can handle right now happen to take the repository directory as their first parameter). If we do not mind butchering things, we could introduce:

	[shell]
        	umask = 0002

to the configuration file, and do something like this (not even compile tested, and I am not sure what else it breaks):

---
diff --git a/shell.c b/shell.c
index cd31618..33898f8 100644
--- a/shell.c
+++ b/shell.c
@@ -1,15 +1,34 @@
 #include "cache.h"
 #include "quote.h"
 
-static int do_generic_cmd(const char *me, char *arg)
+static int shell_umask = 0002; /* default */
+
+static int slurp_repository_umask(const char *var, const char *value)
+{
+	if (!strcmp(var, "shell.umask"))
+		shell_umask = git_config_int(value);
+	else
+		return git_default_config(var, value);
+	return 0;
+}
+
+/*
+ * These commands take arg == git repository directory.
+ */
+static int do_git_repo_cmd(const char *me, char *arg)
 {
 	const char *my_argv[4];
 
 	if (!arg || !(arg = sq_dequote(arg)))
 		die("bad argument");
 
+	if (!enter_repo(arg, 0))
+		die("'%s': Nah -- not a git repository", arg);
+	git_config(slurp_repository_umask);
+	umask(shell_umask);
+
 	my_argv[0] = me;
-	my_argv[1] = arg;
+	my_argv[1] = ".";
 	my_argv[2] = NULL;
 
 	return execvp(me, (char**) my_argv);
@@ -19,8 +38,8 @@ static struct commands {
 	const char *name;
 	int (*exec)(const char *me, char *arg);
 } cmd_list[] = {
-	{ "git-receive-pack", do_generic_cmd },
-	{ "git-upload-pack", do_generic_cmd },
+	{ "git-receive-pack", do_git_repo_cmd },
+	{ "git-upload-pack", do_git_repo_cmd },
 	{ NULL },
 };
 
Previous: Junio C HamanoNext: Martin Langhoff
Message 3 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.