250
git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
251
test_cmp expected actual
252
'
253
+
254
+ test_expect_success "grep $L with grep.patterntype=basic" '
255
+ echo "ab:a+bc" >expected &&
256
+ git -c grep.patterntype=basic grep "a+b*c" ab >actual &&
257
+ test_cmp expected actual
258
+ '
259
+
260
+ test_expect_success "grep $L with grep.patterntype=extended" '
261
+ echo "ab:abc" >expected &&
262
+ git -c grep.patterntype=extended grep "a+b*c" ab >actual &&
263
+ test_cmp expected actual
264
+ '
265
+
266
+ test_expect_success "grep $L with grep.patterntype=fixed" '
267
+ echo "ab:a+b*c" >expected &&
268
+ git -c grep.patterntype=fixed grep "a+b*c" ab >actual &&
269
+ test_cmp expected actual
270
+ '
271
+
272
+ test_expect_success LIBPCRE "grep $L with grep.patterntype=perl" '
273
+ echo "ab:a+b*c" >expected &&
274
+ git -c grep.patterntype=perl grep "a\x{2b}b\x{2a}c" ab >actual &&
275
+ test_cmp expected actual
276
+ '
277
+
278
+ test_expect_success "grep $L with grep.patternType=default and grep.extendedRegexp=true" '
279
+ echo "ab:abc" >expected &&
280
+ git \
281
+ -c grep.patternType=default \
282
+ -c grep.extendedRegexp=true \
283
+ grep "a+b*c" ab >actual &&
284
+ test_cmp expected actual
285
+ '
286
+
287
+ test_expect_success "grep $L with grep.extendedRegexp=true and grep.patternType=default" '
288
+ echo "ab:abc" >expected &&
289
+ git \
290
+ -c grep.extendedRegexp=true \
291
+ -c grep.patternType=default \
292
+ grep "a+b*c" ab >actual &&
293
+ test_cmp expected actual
294
+ '
295
+
296
+ test_expect_success 'grep $L with grep.patternType=extended and grep.extendedRegexp=false' '
297
+ echo "ab:abc" >expected &&
298
+ git \
299
+ -c grep.patternType=extended \
300
+ -c grep.extendedRegexp=false \
301
+ grep "a+b*c" ab >actual &&
302
+ test_cmp expected actual
303
+ '
304
+
305
+ test_expect_success 'grep $L with grep.patternType=basic and grep.extendedRegexp=true' '
306
+ echo "ab:a+bc" >expected &&
307
+ git \
308
+ -c grep.patternType=basic \
309
+ -c grep.extendedRegexp=true \
310
+ grep "a+b*c" ab >actual &&
311
+ test_cmp expected actual
312
+ '
313
+
314
+ test_expect_success 'grep $L with grep.extendedRegexp=false and grep.patternType=extended' '
315
+ echo "ab:abc" >expected &&
316
+ git \
317
+ -c grep.extendedRegexp=false \
318
+ -c grep.patternType=extended \
319
+ grep "a+b*c" ab >actual &&
320
+ test_cmp expected actual
321
+ '
322
+
323
+ test_expect_success 'grep $L with grep.extendedRegexp=true and grep.patternType=basic' '
324
+ echo "ab:a+bc" >expected &&
325
+ git \
326
+ -c grep.extendedRegexp=true \
327
+ -c grep.patternType=basic \
328
+ grep "a+b*c" ab >actual &&
329
+ test_cmp expected actual
330
+ '
331
done
332
333
cat >expected <<EOF
850
test_must_fail git grep -G "a["
851
'
852
853
+test_expect_success 'grep invalidpattern properly dies with grep.patternType=basic' '
854
+ test_must_fail git -c grep.patterntype=basic grep "a["
855
+'
856
+
857
test_expect_success 'grep -E invalidpattern properly dies ' '
858
test_must_fail git grep -E "a["
859
'
860
861
+test_expect_success 'grep invalidpattern properly dies with grep.patternType=extended' '
862
+ test_must_fail git -c grep.patterntype=extended grep "a["
863
+'
864
+
865
test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '
866
test_must_fail git grep -P "a["
867
'
868
869
+test_expect_success LIBPCRE 'grep invalidpattern properly dies with grep.patternType=perl' '
870
+ test_must_fail git -c grep.patterntype=perl grep "a["
871
+'
872
+
873
test_expect_success 'grep -G -E -F pattern' '
874
echo "ab:a+b*c" >expected &&
875
git grep -G -E -F "a+b*c" ab >actual &&
876
test_cmp expected actual
877
'
878
879
+test_expect_success 'grep pattern with grep.patternType=basic, =extended, =fixed' '
880
+ echo "ab:a+b*c" >expected &&
881
+ git \
882
+ -c grep.patterntype=basic \
883
+ -c grep.patterntype=extended \
884
+ -c grep.patterntype=fixed \
885
+ grep "a+b*c" ab >actual &&
886
+ test_cmp expected actual
887
+'
888
+
889
test_expect_success 'grep -E -F -G pattern' '
890
echo "ab:a+bc" >expected &&
891
git grep -E -F -G "a+b*c" ab >actual &&
892
test_cmp expected actual
893
'
894
895
+test_expect_success 'grep pattern with grep.patternType=extended, =fixed, =basic' '
896
+ echo "ab:a+bc" >expected &&
897
+ git \
898
+ -c grep.patterntype=extended \
899
+ -c grep.patterntype=fixed \
900
+ -c grep.patterntype=basic \
901
+ grep "a+b*c" ab >actual &&
902
+ test_cmp expected actual
903
+'
904
+
905
test_expect_success 'grep -F -G -E pattern' '
906
echo "ab:abc" >expected &&
907
git grep -F -G -E "a+b*c" ab >actual &&
908
test_cmp expected actual
909
'
910
911
+test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =extended' '
912
+ echo "ab:abc" >expected &&
913
+ git \
914
+ -c grep.patterntype=fixed \
915
+ -c grep.patterntype=basic \
916
+ -c grep.patterntype=extended \
917
+ grep "a+b*c" ab >actual &&
918
+ test_cmp expected actual
919
+'
920
+
921
test_expect_success 'grep -G -F -P -E pattern' '
922
>empty &&
923
test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
924
test_cmp empty actual
925
'
926
927
+test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =perl, =extended' '
928
+ >empty &&
929
+ test_must_fail git \
930
+ -c grep.patterntype=fixed \
931
+ -c grep.patterntype=basic \
932
+ -c grep.patterntype=perl \
933
+ -c grep.patterntype=extended \
934
+ grep "a\x{2b}b\x{2a}c" ab >actual &&
935
+ test_cmp empty actual
936
+'
937
+
938
test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
939
echo "ab:a+b*c" >expected &&
940
git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
941
test_cmp expected actual
942
'
943
944
+test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' '
945
+ echo "ab:a+b*c" >expected &&
946
+ git \
947
+ -c grep.patterntype=fixed \
948
+ -c grep.patterntype=basic \
949
+ -c grep.patterntype=extended \
950
+ -c grep.patterntype=perl \
951
+ grep "a\x{2b}b\x{2a}c" ab >actual &&
952
+ test_cmp expected actual
953
+'
954
+
955
+test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=fixed' '
956
+ echo "ab:a+b*c" >expected &&
957
+ git \
958
+ -c grep.patterntype=fixed \
959
+ grep -P "a\x{2b}b\x{2a}c" ab >actual &&
960
+ test_cmp expected actual
961
+'
962
+
963
+test_expect_success 'grep -F pattern with grep.patternType=basic' '
964
+ echo "ab:a+b*c" >expected &&
965
+ git \
966
+ -c grep.patterntype=basic \
967
+ grep -F "*c" ab >actual &&
968
+ test_cmp expected actual
969
+'
970
+
971
+test_expect_success 'grep -G pattern with grep.patternType=fixed' '
972
+ {
973
+ echo "ab:a+b*c"
974
+ echo "ab:a+bc"
975
+ } >expected &&
976
+ git \
977
+ -c grep.patterntype=fixed \
978
+ grep -G "a+b" ab >actual &&
979
+ test_cmp expected actual
980
+'
981
+
982
+test_expect_success 'grep -E pattern with grep.patternType=fixed' '
983
+ {
984
+ echo "ab:a+b*c"
985
+ echo "ab:a+bc"
986
+ echo "ab:abc"
987
+ } >expected &&
988
+ git \
989
+ -c grep.patterntype=fixed \
990
+ grep -E "a+" ab >actual &&
991
+ test_cmp expected actual
992
+'
993
+
994
test_config() {
995
git config "$1" "$2" &&
996
test_when_finished "git config --unset $1"