File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,15 @@ test_completion ()
61
61
test_cmp expected out
62
62
}
63
63
64
+ # Like test_completion, but reads expectation from stdin,
65
+ # which is convenient when it is multiline. We also process "_" into
66
+ # spaces to make test vectors more readable.
67
+ test_completion_long ()
68
+ {
69
+ tr _ " " > expected &&
70
+ test_completion " $1 "
71
+ }
72
+
64
73
newline=$' \n '
65
74
66
75
test_expect_success ' __gitcomp - trailing space - options' '
@@ -228,4 +237,55 @@ test_expect_success 'general options plus command' '
228
237
test_completion "git --no-replace-objects check" "checkout "
229
238
'
230
239
240
+ test_expect_success ' setup for ref completion' '
241
+ echo content >file1 &&
242
+ echo more >file2 &&
243
+ git add . &&
244
+ git commit -m one &&
245
+ git branch mybranch &&
246
+ git tag mytag
247
+ '
248
+
249
+ test_expect_success ' checkout completes ref names' '
250
+ test_completion_long "git checkout m" <<-\EOF
251
+ master_
252
+ mybranch_
253
+ mytag_
254
+ EOF
255
+ '
256
+
257
+ test_expect_success ' show completes all refs' '
258
+ test_completion_long "git show m" <<-\EOF
259
+ master_
260
+ mybranch_
261
+ mytag_
262
+ EOF
263
+ '
264
+
265
+ test_expect_success ' <ref>: completes paths' '
266
+ test_completion_long "git show mytag:f" <<-\EOF
267
+ file1_
268
+ file2_
269
+ EOF
270
+ '
271
+
272
+ test_expect_success ' complete tree filename with spaces' '
273
+ echo content >"name with spaces" &&
274
+ git add . &&
275
+ git commit -m spaces &&
276
+ test_completion_long "git show HEAD:nam" <<-\EOF
277
+ name with spaces_
278
+ EOF
279
+ '
280
+
281
+ test_expect_failure ' complete tree filename with metacharacters' '
282
+ echo content >"name with \${meta}" &&
283
+ git add . &&
284
+ git commit -m meta &&
285
+ test_completion_long "git show HEAD:nam" <<-\EOF
286
+ name with ${meta}_
287
+ name with spaces_
288
+ EOF
289
+ '
290
+
231
291
test_done
You can’t perform that action at this time.
0 commit comments