Skip to content

Commit ca267ae

Browse files
derrickstoleegitster
authored andcommitted
t3705: test that 'sparse_entry' is unstaged
The tests in t3705-add-sparse-checkout.sh check to see how 'git add' behaves with paths outside the sparse-checkout definition. These currently check to see if a given warning is present but not that the index is not updated with the sparse entries. Add a new 'test_sparse_entry_unstaged' helper to be sure 'git add' is behaving correctly. We need to modify setup_sparse_entry to actually commit the sparse_entry file so it exists at HEAD and as an entry in the index, but its exact contents are not staged in the index. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 516680b commit ca267ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/t3705-add-sparse-checkout.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ setup_sparse_entry () {
1919
fi &&
2020
git add sparse_entry &&
2121
git update-index --skip-worktree sparse_entry &&
22+
git commit --allow-empty -m "ensure sparse_entry exists at HEAD" &&
2223
SPARSE_ENTRY_BLOB=$(git rev-parse :sparse_entry)
2324
}
2425

@@ -36,6 +37,11 @@ setup_gitignore () {
3637
EOF
3738
}
3839

40+
test_sparse_entry_unstaged () {
41+
git diff --staged -- sparse_entry >diff &&
42+
test_must_be_empty diff
43+
}
44+
3945
test_expect_success 'setup' "
4046
cat >sparse_error_header <<-EOF &&
4147
The following pathspecs didn't match any eligible path, but they do match index
@@ -55,6 +61,7 @@ test_expect_success 'git add does not remove sparse entries' '
5561
setup_sparse_entry &&
5662
rm sparse_entry &&
5763
test_must_fail git add sparse_entry 2>stderr &&
64+
test_sparse_entry_unstaged &&
5865
test_cmp error_and_hint stderr &&
5966
test_sparse_entry_unchanged
6067
'
@@ -73,6 +80,7 @@ test_expect_success 'git add . does not remove sparse entries' '
7380
rm sparse_entry &&
7481
setup_gitignore &&
7582
test_must_fail git add . 2>stderr &&
83+
test_sparse_entry_unstaged &&
7684
7785
cat sparse_error_header >expect &&
7886
echo . >>expect &&
@@ -88,6 +96,7 @@ do
8896
setup_sparse_entry &&
8997
echo modified >sparse_entry &&
9098
test_must_fail git add $opt sparse_entry 2>stderr &&
99+
test_sparse_entry_unstaged &&
91100
test_cmp error_and_hint stderr &&
92101
test_sparse_entry_unchanged
93102
'
@@ -98,6 +107,7 @@ test_expect_success 'git add --refresh does not update sparse entries' '
98107
git ls-files --debug sparse_entry | grep mtime >before &&
99108
test-tool chmtime -60 sparse_entry &&
100109
test_must_fail git add --refresh sparse_entry 2>stderr &&
110+
test_sparse_entry_unstaged &&
101111
test_cmp error_and_hint stderr &&
102112
git ls-files --debug sparse_entry | grep mtime >after &&
103113
test_cmp before after
@@ -106,6 +116,7 @@ test_expect_success 'git add --refresh does not update sparse entries' '
106116
test_expect_success 'git add --chmod does not update sparse entries' '
107117
setup_sparse_entry &&
108118
test_must_fail git add --chmod=+x sparse_entry 2>stderr &&
119+
test_sparse_entry_unstaged &&
109120
test_cmp error_and_hint stderr &&
110121
test_sparse_entry_unchanged &&
111122
! test -x sparse_entry
@@ -116,6 +127,7 @@ test_expect_success 'git add --renormalize does not update sparse entries' '
116127
setup_sparse_entry "LINEONE\r\nLINETWO\r\n" &&
117128
echo "sparse_entry text=auto" >.gitattributes &&
118129
test_must_fail git add --renormalize sparse_entry 2>stderr &&
130+
test_sparse_entry_unstaged &&
119131
test_cmp error_and_hint stderr &&
120132
test_sparse_entry_unchanged
121133
'
@@ -124,6 +136,7 @@ test_expect_success 'git add --dry-run --ignore-missing warn on sparse path' '
124136
setup_sparse_entry &&
125137
rm sparse_entry &&
126138
test_must_fail git add --dry-run --ignore-missing sparse_entry 2>stderr &&
139+
test_sparse_entry_unstaged &&
127140
test_cmp error_and_hint stderr &&
128141
test_sparse_entry_unchanged
129142
'
@@ -148,6 +161,7 @@ test_expect_success 'do not warn when pathspec matches dense entries' '
148161
test_expect_success 'add obeys advice.updateSparsePath' '
149162
setup_sparse_entry &&
150163
test_must_fail git -c advice.updateSparsePath=false add sparse_entry 2>stderr &&
164+
test_sparse_entry_unstaged &&
151165
test_cmp sparse_entry_error stderr
152166
153167
'

0 commit comments

Comments
 (0)