Skip to content

Commit 3c56875

Browse files
committed
t3010: update to demonstrate "ls-files -k" optimization pitfalls
An earlier draft of the previous step used cache_name_exists() to check the directory we were looking at, which missed the second case described in its log message. Demonstrate why it is not sufficient. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2eac2a4 commit 3c56875

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

t/t3010-ls-files-killed-modified.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This test prepares the following in the cache:
1111
path1 - a symlink
1212
path2/file2 - a file in a directory
1313
path3/file3 - a file in a directory
14+
pathx/ju - a file in a directory
1415
1516
and the following on the filesystem:
1617
@@ -21,6 +22,7 @@ and the following on the filesystem:
2122
path4 - a file
2223
path5 - a symlink
2324
path6/file6 - a file in a directory
25+
pathx/ju/nk - a file in a directory to be killed
2426
2527
git ls-files -k should report that existing filesystem
2628
objects except path4, path5 and path6/file6 to be killed.
@@ -44,16 +46,17 @@ then
4446
else
4547
date > path1
4648
fi
47-
mkdir path2 path3
49+
mkdir path2 path3 pathx
4850
date >path2/file2
4951
date >path3/file3
52+
>pathx/ju
5053
: >path7
5154
date >path8
5255
: >path9
5356
date >path10
5457
test_expect_success \
5558
'git update-index --add to add various paths.' \
56-
"git update-index --add -- path0 path1 path?/file? path7 path8 path9 path10"
59+
"git update-index --add -- path0 path1 path?/file? pathx/ju path7 path8 path9 path10"
5760

5861
rm -fr path? ;# leave path10 alone
5962
date >path2
@@ -65,14 +68,15 @@ else
6568
date > path3
6669
date > path5
6770
fi
68-
mkdir path0 path1 path6
71+
mkdir -p path0 path1 path6 pathx/ju
6972
date >path0/file0
7073
date >path1/file1
7174
date >path6/file6
7275
date >path7
7376
: >path8
7477
: >path9
7578
touch path10
79+
>pathx/ju/nk
7680

7781
test_expect_success \
7882
'git ls-files -k to show killed files.' \
@@ -82,6 +86,7 @@ path0/file0
8286
path1/file1
8387
path2
8488
path3
89+
pathx/ju/nk
8590
EOF
8691

8792
test_expect_success \
@@ -98,6 +103,7 @@ path2/file2
98103
path3/file3
99104
path7
100105
path8
106+
pathx/ju
101107
EOF
102108

103109
test_expect_success \

0 commit comments

Comments
 (0)