Skip to content

Commit 9fc9555

Browse files
committed
Merge branch 'cc/shared-index-permbits'
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
2 parents 9da9fff + c9d6c78 commit 9fc9555

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

read-cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,8 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
31793179
struct tempfile *temp;
31803180
int saved_errno;
31813181

3182-
temp = mks_tempfile(git_path("sharedindex_XXXXXX"));
3182+
/* Same initial permissions as the main .git/index file */
3183+
temp = mks_tempfile_sm(git_path("sharedindex_XXXXXX"), 0, 0666);
31833184
if (!temp) {
31843185
oidclr(&si->base_oid);
31853186
ret = do_write_locked_index(istate, lock, flags);

t/t1700-split-index.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,26 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"
384384
test $(ls .git/sharedindex.* | wc -l) -le 2
385385
'
386386

387+
test_expect_success POSIXPERM 'same mode for index & split index' '
388+
git init same-mode &&
389+
(
390+
cd same-mode &&
391+
test_commit A &&
392+
test_modebits .git/index >index_mode &&
393+
test_must_fail git config core.sharedRepository &&
394+
git -c core.splitIndex=true status &&
395+
shared=$(ls .git/sharedindex.*) &&
396+
case "$shared" in
397+
*" "*)
398+
# we have more than one???
399+
false ;;
400+
*)
401+
test_modebits "$shared" >split_index_mode &&
402+
test_cmp index_mode split_index_mode ;;
403+
esac
404+
)
405+
'
406+
387407
while read -r mode modebits
388408
do
389409
test_expect_success POSIXPERM "split index respects core.sharedrepository $mode" '

0 commit comments

Comments
 (0)