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

confused about preserved permissions

From
MKmartin f krafft <madduck@madduck.net>
Date
Aug 20, 2007, 16:44 UTC
Message-ID
<20070820164411.GA15637@piper.oerlikon.madduck.net>
Hello,

I am a bit confused about how git stores and restores permissions. I went to the web but found little other than this post from Linus in 2005:

  http://www.gelato.unsw.edu.au/archives/git/0504/0870.html

where he basically says that git will *not* save permissions and that it also does not save symlinks. I thus discarded the information as being outdated. I have also looked into the source, but the following question is more about git design than implementation.

Let me illustrate the source of my confusion:
  $ git init
  Initialized empty Git repository in .git/
  $ umask
  002
  $ date > file1; ls -l file1
  -rw-rw-r-- 1 madduck madduck 30 2007-08-20 18:15 file1
  $ git add file1; git commit -m.
  Created initial commit 5762460: .
  1 files changed, 1 insertions(+), 0 deletions(-)
  create mode 100644 file1

file1 is mode 664, but gut says "create mode 100644 file1", independently of whether I use --shared when initialising, or what value I set it to. Why does it override the group write bit?

But it gets worse:
  $ git checkout -b t
  Switched to a new branch "t"
  $ git rm file1; git commit -m.
  rm 'file1'
  Created commit a813b4e: .
  1 files changed, 0 insertions(+), 1 deletions(-)
  delete mode 100644 file1
  $ umask 007
  $ git checkout master
  Switched to branch "master"
  $ ls -l file1
  -rw-rw----  1 madduck madduck    30 2007-08-20 18:15 file1

So git doesn't even restore 644 when I switch branches, nor on initial clone, or on re-checkout after removing the local copy.

Am I doing something wrong?

Why does git bother saving a mode when later it never seems to use it again?

And is there a way to tell git not to mess with the permissions in the worktree when switching branches? I am not sure what's causing it since the inode of files does not seem to change, so git apparently explicitly fchmod()'s files.

I'd be grateful for any documentation to read in addition to the code. I saw core.filemode, but that's only about the x bit, it seems.

Thanks,
-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
"vista is evidentally latvian for "hen", and "perating system", that
 is, OS without the o, means "system for making eggs."  so vista is at
 least useful come breakfast time?"
                                                      -- kit la touche
 
spamtraps: madduck.bogus@madduck.net
Next: Pierre Habouzit
Message 1 of 39 in “confused about preserved permissions”
  1. martin f krafftAug 20, 2007
  2. Pierre HabouzitAug 20, 2007
  3. martin f krafftAug 20, 2007
  4. Mike HommeyAug 20, 2007
  5. David KastrupAug 20, 2007
  6. Mike HommeyAug 20, 2007
  7. David KastrupAug 20, 2007
  8. René ScharfeAug 21, 2007
  9. Documentation: update tar.umask defaultRené Scharfe, Aug 21, 2007
  10. Mike HommeyAug 21, 2007
  11. René ScharfeAug 22, 2007
  12. Alex RiesenAug 20, 2007
  13. Benoit SIGOUREAug 22, 2007
  14. Johannes SixtAug 22, 2007
  15. Junio C HamanoAug 22, 2007
  16. martin f krafftAug 23, 2007
  17. David KastrupAug 23, 2007
  18. martin f krafftAug 23, 2007
  19. Benoit SIGOUREAug 23, 2007
  20. Junio C HamanoAug 23, 2007
  21. David KastrupAug 23, 2007
  22. Jan HudecSep 3, 2007
  23. Junio C HamanoAug 23, 2007
  24. Mike HommeyAug 20, 2007
  25. Jan HudecAug 20, 2007
  26. Mike HommeyAug 20, 2007
  27. Alex RiesenAug 20, 2007
  28. Mike HommeyAug 20, 2007
  29. Jan HudecAug 20, 2007
  30. David KastrupAug 20, 2007
  31. Mike HommeyAug 20, 2007
  32. Jan HudecAug 20, 2007
  33. David KastrupAug 20, 2007
  34. Mike HommeyAug 20, 2007
  35. David KastrupAug 20, 2007
  36. Shawn O. PearceAug 21, 2007
  37. Junio C HamanoAug 21, 2007
  38. Mike HommeyAug 21, 2007
  39. David KastrupAug 21, 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.