What causes git's post-receive umask to be different from the user's umask?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 13:48:07

You need to locate the startup scripts used by the shell when invoked from the post-receive hook, in non-interactive mode.

If your hook script starts with #!/bin/sh, then look at man sh and look for mentions of rcfiles like .profile, /etc/profile, .bashrc or similar. The man page of the shell used should explain what files are sourced in case of interactive and non-interactive shells. You're looking for the files used in non-interactive mode.

If this is still not clear from the man page, you can find what /bin/sh links to using namei /bin/sh, and run the command with --help.

To verify what you understood from the scripts used in the startup sequence, you can add some debugging lines in the suspected script files, for example:

{ echo this is file x; umask; } >> /tmp/debug.log

And then get the post-receive hook triggered and look at /tmp/debug.log.

So it turns out it does matter that I am using gitolite. Why? Because there is a setting in the gitolite configuration that dictates the umask of new files. Oddly I never had to change this setting in previous gitolite installs, but perhaps the default has been changed. In any way, here is how I finally sorted it out:

Open the ~/.gitolite.rc file:

Locate this line:

$REPO_UMASK = 0077;

And change it to the setting of choice, eg:

$REPO_UMASK = 0002;

Things finally worked afterwards!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!