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

Re: Storing permissions

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 17, 2005, 16:10 UTC
Message-ID
<Pine.LNX.4.58.0504170857580.7211@ppc970.osdl.org>
In-Reply-To
<42620092.9040402@dwheeler.com>
On Sun, 17 Apr 2005, David A. Wheeler wrote:
> 
> There's a minor reason to write out ALL the perm bit data, but
> only care about a few bits coming back in: Some people use
> SCM systems as a generalized backup system

Yes. I was actually thinking about having system config files in a git repository when I started it, since I noticed how nicely it would do exactly that.

However, since the mode bits also end up being part of the name of the tree object (ie they are most certainly part of the hash), it's really basically impossible to only care about one bit but writing out many bits: it's the same issue of having multiple "identical" blocks with different names.

It's ok if it happens occasionally (it _will_ happen at the point of a tree conversion to the new format, for example), but it's not ok if it happens all the time - which it would, since some people have umask 002 (and individual groups) and others have umask 022 (and shared groups), and I can imagine that some anal people have umask 0077 ("I don't want to play with others").

The trees would constantly bounce between a million different combinations (since _some_ files would be checked out with the "other" mode).

At least if you always honor umask or always totally ignore umask, you get a nice repetable thing. We tried the "always ignore" umask thing, and the problem with that is that while _git_ ended up always doing a "fchmod()" to reset the whole permission mask, anybody who created files any other way and then checked them in would end up using umask.

One solution is to tell git with a command line flag and/or config file entry that "for this repo, I want you to honor all bits". That should be easy enough to add at some point, and then you really get what you want.

That said, git won't be really good at doing system backup. I actually _do_ save a full 32-bit of "mode" (hey, you could have "immutable" bits etc set), but anybody who does anything fancy at all with mtime would be screwed, for example.

Also, right now we don't actually save any other type of file than regular/directory, so you'd have to come up with a good save-format for symlinks (easy, I guess - just make a "link" blob) and device nodes (that one probably should be saved in the "cache_entry" itself, possibly encoded where the sha1 hash normally is).

Also, I made a design decision that git only cares about non-dotfiles. Git literally never sees or looks at _anything_ that starts with a ".". I think that's absolutely the right thing to do for an SCM (if you hide your files, I really don't think you should expect the SCM to see it), but it's obviously not the right thing for a backup thing.

(It _might_ be the right thing for a system config file, though, eg tracking something like "/etc" with git might be ok, modulo the other issues).

			Linus
Previous: Daniel BarkalowNext: David A. Wheeler
Message 14 of 25 in “Storing permissions”
  1. Martin MaresApr 16, 2005
  2. Paul JacksonApr 16, 2005
  3. Junio C HamanoApr 16, 2005
  4. Paul JacksonApr 17, 2005
  5. David A. WheelerApr 17, 2005
  6. Morten WelinderApr 17, 2005
  7. Paul JacksonApr 17, 2005
  8. Linus TorvaldsApr 17, 2005
  9. Paul JacksonApr 17, 2005
  10. Linus TorvaldsApr 17, 2005
  11. David A. WheelerApr 17, 2005
  12. Paul JacksonApr 17, 2005
  13. Daniel BarkalowApr 17, 2005
  14. Linus TorvaldsApr 17, 2005
  15. David A. WheelerApr 17, 2005
  16. Symlinks [was Re: Storing permissions]Morten Welinder, Apr 17, 2005
  17. Zack BrownDec 7, 2005
  18. Andreas EricssonDec 7, 2005
  19. Zack BrownDec 7, 2005
  20. Petr BaudisDec 7, 2005
  21. Johannes SchindelinDec 7, 2005
  22. Junio C HamanoDec 7, 2005
  23. Zack BrownDec 7, 2005
  24. Junio C HamanoDec 7, 2005
  25. H. Peter AnvinDec 8, 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.