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

Re: Error converting from 1.4.4.1 to 1.5.0?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 14, 2007, 22:32 UTC
Message-ID
<Pine.LNX.4.63.0702142321390.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vire4l76a.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 14 Feb 2007, Junio C Hamano wrote:
Show 15 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Wed, 14 Feb 2007, Junio C Hamano wrote:
> >
> >> By the way, I sometimes think it might be worth doing this:
> >> 
> >> 	$ chmod a-r .git/
> >> 
> >> We always access files by explicit paths and never ask "ls .git/foo*" to 
> >> find what are under .git/ directory.
> >
> > If so, please make it unconfigurable. I use tab-completion in the git 
> > directory quite often.
> 
> Do you mean "configurable"?
No. I meant "unconfigurable", since the sane default _would_ be a-r.

But then, I see that I was silly. This chmod is done on git-init time, and easy to undo _if_ you want it.

So, colour me a supporter of that feature.
> I wonder what you are doing inside .git directory in the first place.  
> I never chdir() into it myself, but that may be because I practicaly 
> live inside Emacs.

:-) Lucky you. Since long time, I became a vi user, not out of fun, but out of necessity. I had to work on many machines which had vi installed, but not emacs. On some, my quota was not large enough to compile the beast, so I eventually gave in.

Back to the subject: Sometimes I just want to look if a certain file is present. But I cannot be bothered to really type out ".git/index.lock", but rather I do ".g<TAB>/i<TAB>.<TAB>"...

Anyway, here is a minimal (completely untested) patch to do what you proposed:

-- snipsnap --
[PATCH] init: create GIT_DIR non-readable

We access all files in GIT_DIR by name, so we do not really need it to be readable. However, it is less easy to corrupt the repository unintentionally when it is not readable.

Those who want to be able to see the contents of GIT_DIR, always can just do a `chown u+r $GIT_DIR`.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 builtin-init-db.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 12e43d0..8496269 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -18,7 +18,7 @@
 
 static void safe_create_dir(const char *dir, int share)
 {
-	if (mkdir(dir, 0777) < 0) {
+	if (mkdir(dir, share ? 0777 : 0333) < 0) {
 		if (errno != EEXIST) {
 			perror(dir);
 			exit(1);
Previous: Junio C HamanoNext: Jakub Narebski
Message 14 of 39 in “Error converting from 1.4.4.1 to 1.5.0?”
  1. Bill LearFeb 14, 2007
  2. Bill LearFeb 14, 2007
  3. Junio C HamanoFeb 14, 2007
  4. Bill LearFeb 14, 2007
  5. Junio C HamanoFeb 14, 2007
  6. Bill LearFeb 14, 2007
  7. Bill LearFeb 14, 2007
  8. Linus TorvaldsFeb 14, 2007
  9. Bill LearFeb 14, 2007
  10. Junio C HamanoFeb 14, 2007
  11. Junio C HamanoFeb 14, 2007
  12. Johannes SchindelinFeb 14, 2007
  13. Junio C HamanoFeb 14, 2007
  14. Johannes SchindelinFeb 14, 2007
  15. Jakub NarebskiFeb 15, 2007
  16. Olivier GalibertFeb 15, 2007
  17. Johannes SchindelinFeb 15, 2007
  18. Johannes SchindelinFeb 14, 2007
  19. Nicolas PitreFeb 14, 2007
  20. Bill LearFeb 14, 2007
  21. OT: data destruction classics (was: Re: Error converting from 1.4.4.1 to 1.5.0?)Simon 'corecode' Schubert, Feb 15, 2007
  22. Shawn O. PearceFeb 15, 2007
  23. Linus TorvaldsFeb 15, 2007
  24. Johannes SchindelinFeb 15, 2007
  25. Michael K. EdwardsFeb 15, 2007
  26. Bill LearFeb 15, 2007
  27. Andy ParkinsFeb 15, 2007
  28. Mark WoodingFeb 15, 2007
  29. Linus TorvaldsFeb 14, 2007
  30. Linus TorvaldsFeb 14, 2007
  31. Uwe Kleine-KönigFeb 15, 2007
  32. Junio C HamanoFeb 14, 2007
  33. Bill LearFeb 14, 2007
  34. Nicolas PitreFeb 14, 2007
  35. Junio C HamanoFeb 14, 2007
  36. Linus TorvaldsFeb 14, 2007
  37. Linus TorvaldsFeb 14, 2007
  38. Bill LearFeb 14, 2007
  39. Linus TorvaldsFeb 14, 2007

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.