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

Re: git gc changes ownerships of files linux

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 11, 2024, 16:43 UTC
Message-ID
<xmqqcyt39cju.fsf@gitster.g>
In-Reply-To
<20240211154345.GA28699@tb-raspi4>
Torsten Bögershausen <tboegi@web.de> writes:
Show 6 quoted lines
> Briam, Hm, I wonder what this function (in path.c) does:
>
> int adjust_shared_perm(const char *path)
>
> According to my understanding, it was included into the Git codebase
> to work around the missing "setgid" feature in Linux (and probably cygwin).

No. "g+s on directory" is required and depended upon for getting the correct group ownership. We do not do anything to chown(2) a filesystem entry to force what group it is owned by there.

What adjust_shared_perm() does is to counter what the screwed-up umask settings the user may have causes. If you are a member of a group and working in a directory owned by the group with other members, you want to make sure others in the group can access the files and the directories in the project. Their umask should be loosened to at least 027 and preferrably to 007 to give group members the same access as you do. Yet people do not loosen their umask when starting work in such a group owned directory that is supposed to be shared, as it would be extremely cumbersome to do [*]. These users end up creating files with overly tight permission bits, e.g. 0644 or 0700, and we go in with adjust_shared_perm() to fix these modes.

You definitely must set up your initial directory with g+s if you are usihng the group-writable shared directory model (which I would actually be surprised to see in 2020---is a shared machine with more than one user-account still a thing???); adjust_shared_perm() will not help you there.

[Footnote]
* Unless, of course, you use some sort of "hook" in the shell to
  notice you switched to a certain directory and run command
  there---some people achieve this by aliasing their "cd", "pushd",
  and "popd".
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 5 of 8 in “git gc changes ownerships of files linux”
  1. K_VFeb 10, 2024
  2. Torsten BögershausenFeb 11, 2024
  3. brian m. carlsonFeb 11, 2024
  4. Torsten BögershausenFeb 11, 2024
  5. Junio C HamanoFeb 11, 2024
  6. Torsten BögershausenFeb 11, 2024
  7. brian m. carlsonFeb 11, 2024
  8. rsbecker@nexbridge.comFeb 11, 2024

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.