Merge branch 'cc/shared-index-permbits'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:03 +0000 (20:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:03 +0000 (20:39 +0900)
The way .git/index and .git/sharedindex* files were initially
created gave these files different perm bits until they were
adjusted for shared repository settings. This was made consistent.

* cc/shared-index-permbits:
read-cache: make the split index obey umask settings

read-cache.c
t/t1700-split-index.sh
index 42de59a163c1f88580b88281dfc1572ca0dcd5f0..bd45dc3e24d7dc28820d26cc6e6d377f92fda46d 100644 (file)
@@ -3179,7 +3179,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);
index 0cbac64e28b26eebe2805c51748be99d647e039d..4667e1a1909a01e638b13b7264b9041805a438b6 100755 (executable)
@@ -384,6 +384,26 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"
        test $(ls .git/sharedindex.* | wc -l) -le 2
 '
 
+test_expect_success POSIXPERM 'same mode for index & split index' '
+       git init same-mode &&
+       (
+               cd same-mode &&
+               test_commit A &&
+               test_modebits .git/index >index_mode &&
+               test_must_fail git config core.sharedRepository &&
+               git -c core.splitIndex=true status &&
+               shared=$(ls .git/sharedindex.*) &&
+               case "$shared" in
+               *" "*)
+                       # we have more than one???
+                       false ;;
+               *)
+                       test_modebits "$shared" >split_index_mode &&
+                       test_cmp index_mode split_index_mode ;;
+               esac
+       )
+'
+
 while read -r mode modebits
 do
        test_expect_success POSIXPERM "split index respects core.sharedrepository $mode" '