summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2018-11-18 19:04:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-18 23:29:02 (GMT)
commitc9d6c78870defec48dfa8bc1fd37ea51379e737d (patch)
tree2cf4f25e1de236f2381fe67d7b097218c9dd19be /read-cache.c
parentcae598d9980661a978e2df4fb338518f7bf09572 (diff)
downloadgit-c9d6c78870defec48dfa8bc1fd37ea51379e737d.zip
git-c9d6c78870defec48dfa8bc1fd37ea51379e737d.tar.gz
git-c9d6c78870defec48dfa8bc1fd37ea51379e737d.tar.bz2
read-cache: make the split index obey umask settings
Make the split index write out its .git/sharedindex_* files with the same permissions as .git/index. This only changes the behavior when core.sharedRepository isn't set, i.e. the user's umask settings will be respected. This hasn't been the case ever since the split index was originally implemented in c18b80a0e8 ("update-index: new options to enable/disable split index mode", 2014-06-13). A mkstemp()-like function has always been used to create it. First mkstemp() itself, and then later our own mkstemp()-like in f6ecc62dbf ("write_shared_index(): use tempfile module", 2015-08-10) A related bug was fixed in df801f3f9f ("read-cache: use shared perms when writing shared index", 2017-06-25). Since then the split index has respected core.sharedRepository. However, using that setting should not be required simply to make git obey the user's umask setting. It's intended for the use-case of overriding whatever that umask is set to. This fixes cases where the user has e.g. set his umask to 022 on a shared server in anticipation of other user's needing to run "status", "log" etc. in his repository. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index 7b1354d..2fc2acb 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2774,7 +2774,8 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
struct tempfile *temp;
int saved_errno;
- temp = mks_tempfile(git_path("sharedindex_XXXXXX"));
+ /* Same initial permissions as the main .git/index file */
+ temp = mks_tempfile_sm(git_path("sharedindex_XXXXXX"), 0, 0666);
if (!temp) {
oidclr(&si->base_oid);
ret = do_write_locked_index(istate, lock, flags);