forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy patht4070-diff-auto-refresh-index.sh
executable file
·46 lines (36 loc) · 1.17 KB
/
t4070-diff-auto-refresh-index.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# Copyright (c) 2025 Benjamin Woodruff
#
test_description='diff.autoRefreshIndex config option'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh
test_expect_success 'index is updated when autoRefreshIndex is true' '
>tracked &&
git add tracked &&
# stat() must change (but not file contents) to trigger an index update
test_set_magic_mtime tracked &&
# check the mtime of .git/index does not change without autoRefreshIndex
test_set_magic_mtime .git/index &&
git config diff.autoRefreshIndex false &&
git diff &&
test_is_magic_mtime .git/index &&
# but it does change when autoRefreshIndex is true (the default)
git config diff.autoRefreshIndex true &&
git diff &&
! test_is_magic_mtime .git/index
'
test_expect_success '--no-optional-locks overrides autoRefreshIndex' '
>tracked &&
git add tracked &&
test_set_magic_mtime tracked &&
# `--no-optional-locks` overrides `autoRefreshIndex`
test_set_magic_mtime .git/index &&
git config diff.autoRefreshIndex true &&
git --no-optional-locks diff &&
# sanity check that without `--no-optional-locks` it still updates
test_is_magic_mtime .git/index &&
git diff &&
! test_is_magic_mtime .git/index
'
test_done