@@ -66,11 +66,11 @@ test_check_ignore () {
66
66
67
67
init_vars &&
68
68
rm -f " $HOME /stdout" " $HOME /stderr" " $HOME /cmd" &&
69
- echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \
69
+ echo git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $ args \
70
70
> " $HOME /cmd" &&
71
71
echo " $expect_code " > " $HOME /expected-exit-code" &&
72
72
test_expect_code " $expect_code " \
73
- git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $args \
73
+ git $global_args check-ignore $quiet_opt $verbose_opt $non_matching_opt $no_index_opt $ args \
74
74
> " $HOME /stdout" 2> " $HOME /stderr" &&
75
75
test_cmp " $HOME /expected-stdout" " $HOME /stdout" &&
76
76
stderr_empty_on_success " $expect_code "
@@ -87,26 +87,36 @@ test_check_ignore () {
87
87
# check-ignore --verbose output is the same as normal output except
88
88
# for the extra first column.
89
89
#
90
+ # A parameter is used to determine if the tests are run with the
91
+ # normal case (using the index), or with the --no-index option.
92
+ #
90
93
# Arguments:
91
94
# - (optional) prereqs for this test, e.g. 'SYMLINKS'
92
95
# - test name
93
96
# - output to expect from the fourth verbosity mode (the output
94
97
# from the other verbosity modes is automatically inferred
95
98
# from this value)
96
99
# - code to run (should invoke test_check_ignore)
97
- test_expect_success_multi () {
100
+ # - index option: --index or --no-index
101
+ test_expect_success_multiple () {
98
102
prereq=
99
- if test $# -eq 4
103
+ if test $# -eq 5
100
104
then
101
105
prereq=$1
102
106
shift
103
107
fi
108
+ if test " $4 " = " --index"
109
+ then
110
+ no_index_opt=
111
+ else
112
+ no_index_opt=$4
113
+ fi
104
114
testname=" $1 " expect_all=" $2 " code=" $3 "
105
115
106
116
expect_verbose=$( echo " $expect_all " | grep -v ' ^:: ' )
107
117
expect=$( echo " $expect_verbose " | sed -e ' s/.* //' )
108
118
109
- test_expect_success $prereq " $testname " '
119
+ test_expect_success $prereq " $testname ${no_index_opt : + with $no_index_opt } " '
110
120
expect "$expect" &&
111
121
eval "$code"
112
122
'
@@ -116,7 +126,8 @@ test_expect_success_multi () {
116
126
then
117
127
for quiet_opt in ' -q' ' --quiet'
118
128
do
119
- test_expect_success $prereq " $testname ${quiet_opt: + with $quiet_opt } " "
129
+ opts=" ${no_index_opt: +$no_index_opt } $quiet_opt "
130
+ test_expect_success $prereq " $testname ${opts: + with $opts } " "
120
131
expect '' &&
121
132
$code
122
133
"
@@ -126,7 +137,7 @@ test_expect_success_multi () {
126
137
127
138
for verbose_opt in ' -v' ' --verbose'
128
139
do
129
- for non_matching_opt in ' ' ' -n' ' --non-matching'
140
+ for non_matching_opt in ' ' ' -n' ' --non-matching'
130
141
do
131
142
if test -n " $non_matching_opt "
132
143
then
@@ -139,12 +150,21 @@ test_expect_success_multi () {
139
150
expect '$my_expect ' &&
140
151
$code
141
152
"
142
- opts=" $verbose_opt$non_matching_opt "
153
+ opts=" ${no_index_opt : + $no_index_opt } $ verbose_opt${ non_matching_opt: + $non_matching_opt } "
143
154
test_expect_success $prereq " $testname ${opts: + with $opts } " " $test_code "
144
155
done
145
156
done
146
157
verbose_opt=
147
158
non_matching_opt=
159
+ no_index_opt=
160
+ }
161
+
162
+ test_expect_success_multi () {
163
+ test_expect_success_multiple " $@ " " --index"
164
+ }
165
+
166
+ test_expect_success_no_index_multi () {
167
+ test_expect_success_multiple " $@ " " --no-index"
148
168
}
149
169
150
170
test_expect_success ' setup' '
@@ -288,7 +308,7 @@ test_expect_success_multi 'needs work tree' '' '
288
308
289
309
# First make sure that the presence of a file in the working tree
290
310
# does not impact results, but that the presence of a file in the
291
- # index does.
311
+ # index does unless the --no-index option is used .
292
312
293
313
for subdir in ' ' ' a/'
294
314
do
303
323
" :: ${subdir} non-existent" \
304
324
" test_check_ignore '${subdir} non-existent' 1"
305
325
326
+ test_expect_success_no_index_multi " non-existent file $where not ignored" \
327
+ " :: ${subdir} non-existent" \
328
+ " test_check_ignore '${subdir} non-existent' 1"
329
+
306
330
test_expect_success_multi " non-existent file $where ignored" \
307
331
" .gitignore:1:one ${subdir} one" \
308
332
" test_check_ignore '${subdir} one'"
309
333
334
+ test_expect_success_no_index_multi " non-existent file $where ignored" \
335
+ " .gitignore:1:one ${subdir} one" \
336
+ " test_check_ignore '${subdir} one'"
337
+
310
338
test_expect_success_multi " existing untracked file $where not ignored" \
311
339
" :: ${subdir} not-ignored" \
312
340
" test_check_ignore '${subdir} not-ignored' 1"
313
341
342
+ test_expect_success_no_index_multi " existing untracked file $where not ignored" \
343
+ " :: ${subdir} not-ignored" \
344
+ " test_check_ignore '${subdir} not-ignored' 1"
345
+
314
346
test_expect_success_multi " existing tracked file $where not ignored" \
315
347
" :: ${subdir} ignored-but-in-index" \
316
348
" test_check_ignore '${subdir} ignored-but-in-index' 1"
317
349
350
+ test_expect_success_no_index_multi " existing tracked file $where shown as ignored" \
351
+ " .gitignore:2:ignored-* ${subdir} ignored-but-in-index" \
352
+ " test_check_ignore '${subdir} ignored-but-in-index'"
353
+
318
354
test_expect_success_multi " existing untracked file $where ignored" \
319
355
" .gitignore:2:ignored-* ${subdir} ignored-and-untracked" \
320
356
" test_check_ignore '${subdir} ignored-and-untracked'"
321
357
358
+ test_expect_success_no_index_multi " existing untracked file $where ignored" \
359
+ " .gitignore:2:ignored-* ${subdir} ignored-and-untracked" \
360
+ " test_check_ignore '${subdir} ignored-and-untracked'"
361
+
322
362
test_expect_success_multi " mix of file types $where " \
323
363
" :: ${subdir} non-existent
324
364
.gitignore:1:one ${subdir} one
325
365
:: ${subdir} not-ignored
326
366
:: ${subdir} ignored-but-in-index
367
+ .gitignore:2:ignored-* ${subdir} ignored-and-untracked" \
368
+ " test_check_ignore '
369
+ ${subdir} non-existent
370
+ ${subdir} one
371
+ ${subdir} not-ignored
372
+ ${subdir} ignored-but-in-index
373
+ ${subdir} ignored-and-untracked'
374
+ "
375
+
376
+ test_expect_success_no_index_multi " mix of file types $where " \
377
+ " :: ${subdir} non-existent
378
+ .gitignore:1:one ${subdir} one
379
+ :: ${subdir} not-ignored
380
+ .gitignore:2:ignored-* ${subdir} ignored-but-in-index
327
381
.gitignore:2:ignored-* ${subdir} ignored-and-untracked" \
328
382
" test_check_ignore '
329
383
${subdir} non-existent
0 commit comments