@@ -63,7 +63,7 @@ test_expect_success 'setup (initial)' '
63
63
'
64
64
test_expect_success ' status works (initial)' '
65
65
git add -i </dev/null >output &&
66
- grep "+1/-0 *+2/-0 file" output
66
+ test_grep "+1/-0 *+2/-0 file" output
67
67
'
68
68
69
69
test_expect_success ' setup expected' '
@@ -86,7 +86,7 @@ test_expect_success 'revert works (initial)' '
86
86
git add file &&
87
87
test_write_lines r 1 | git add -i &&
88
88
git ls-files >output &&
89
- ! grep . output
89
+ test_grep ! . output
90
90
'
91
91
92
92
test_expect_success ' add untracked (multiple)' '
@@ -109,7 +109,7 @@ test_expect_success 'setup (commit)' '
109
109
'
110
110
test_expect_success ' status works (commit)' '
111
111
git add -i </dev/null >output &&
112
- grep "+1/-0 *+2/-0 file" output
112
+ test_grep "+1/-0 *+2/-0 file" output
113
113
'
114
114
115
115
test_expect_success ' update can stage deletions' '
@@ -141,7 +141,7 @@ test_expect_success 'revert works (commit)' '
141
141
git add file &&
142
142
test_write_lines r 1 | git add -i &&
143
143
git add -i </dev/null >output &&
144
- grep "unchanged *+3/-0 file" output
144
+ test_grep "unchanged *+3/-0 file" output
145
145
'
146
146
147
147
test_expect_success ' reject multi-key input' '
@@ -185,7 +185,7 @@ test_expect_success 'setup fake editor' '
185
185
test_expect_success ' bad edit rejected' '
186
186
git reset &&
187
187
test_write_lines e n d | git add -p >output &&
188
- grep "hunk does not apply" output
188
+ test_grep "hunk does not apply" output
189
189
'
190
190
191
191
test_expect_success ' setup patch' '
@@ -198,7 +198,7 @@ test_expect_success 'setup patch' '
198
198
test_expect_success ' garbage edit rejected' '
199
199
git reset &&
200
200
test_write_lines e n d | git add -p >output &&
201
- grep "hunk does not apply" output
201
+ test_grep "hunk does not apply" output
202
202
'
203
203
204
204
test_expect_success ' setup patch' '
@@ -313,8 +313,8 @@ test_expect_success FILEMODE 'stage mode and hunk' '
313
313
chmod +x file &&
314
314
printf "y\\ny\\n" | git add -p &&
315
315
git diff --cached file >out &&
316
- grep "new mode" out &&
317
- grep "+content" out &&
316
+ test_grep "new mode" out &&
317
+ test_grep "+content" out &&
318
318
git diff file >out &&
319
319
test_must_be_empty out
320
320
'
@@ -636,7 +636,7 @@ test_expect_success 'split hunk "add -p (edit)"' '
636
636
printf "%s\n" s e q n q q |
637
637
EDITOR=: git add -p &&
638
638
git diff >actual &&
639
- ! grep "^+15" actual
639
+ test_grep ! "^+15" actual
640
640
'
641
641
642
642
test_expect_success ' split hunk "add -p (no, yes, edit)"' '
@@ -648,7 +648,7 @@ test_expect_success 'split hunk "add -p (no, yes, edit)"' '
648
648
EDITOR=: git add -p 2>error &&
649
649
test_must_be_empty error &&
650
650
git diff >actual &&
651
- ! grep "^+31" actual
651
+ test_grep ! "^+31" actual
652
652
'
653
653
654
654
test_expect_success ' split hunk with incomplete line at end' '
@@ -682,7 +682,7 @@ test_expect_success 'edit, adding lines to the first hunk' '
682
682
EDITOR=./fake_editor.sh git add -p 2>error &&
683
683
test_must_be_empty error &&
684
684
git diff --cached >actual &&
685
- grep "^+22" actual
685
+ test_grep "^+22" actual
686
686
'
687
687
688
688
test_expect_success ' patch mode ignores unmerged entries' '
@@ -696,7 +696,7 @@ test_expect_success 'patch mode ignores unmerged entries' '
696
696
test_must_fail git merge side &&
697
697
echo changed >non-conflict.t &&
698
698
echo y | git add -p >output &&
699
- ! grep a/conflict.t output &&
699
+ test_grep ! a/conflict.t output &&
700
700
cat >expected <<-\EOF &&
701
701
* Unmerged path conflict.t
702
702
diff --git a/non-conflict.t b/non-conflict.t
@@ -728,7 +728,7 @@ test_expect_success 'diffs can be colorized' '
728
728
729
729
# We do not want to depend on the exact coloring scheme
730
730
# git uses for diffs, so just check that we saw some kind of color.
731
- grep "$(printf "\\033")" output
731
+ test_grep "$(printf "\\033")" output
732
732
'
733
733
734
734
test_expect_success ' colors can be overridden' '
@@ -743,7 +743,7 @@ test_expect_success 'colors can be overridden' '
743
743
-c color.interactive.error=blue \
744
744
add -i 2>err.raw <input &&
745
745
test_decode_color <err.raw >err &&
746
- grep "<BLUE>Huh (trigger)?<RESET>" err &&
746
+ test_grep "<BLUE>Huh (trigger)?<RESET>" err &&
747
747
748
748
test_write_lines help quit >input &&
749
749
force_color git \
@@ -863,7 +863,7 @@ test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
863
863
printf y >y &&
864
864
force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
865
865
test_decode_color <output.raw >output &&
866
- grep "old<" output
866
+ test_grep "old<" output
867
867
'
868
868
869
869
test_expect_success ' diffFilter filters diff' '
@@ -876,7 +876,7 @@ test_expect_success 'diffFilter filters diff' '
876
876
877
877
# avoid depending on the exact coloring or content of the prompts,
878
878
# and just make sure we saw our diff prefixed
879
- grep foo:.*content output
879
+ test_grep foo:.*content output
880
880
'
881
881
882
882
test_expect_success ' detect bogus diffFilter output' '
@@ -886,7 +886,7 @@ test_expect_success 'detect bogus diffFilter output' '
886
886
test_config interactive.diffFilter "sed 6d" &&
887
887
printf y >y &&
888
888
force_color test_must_fail git add -p <y >output 2>&1 &&
889
- grep "mismatched output" output
889
+ test_grep "mismatched output" output
890
890
'
891
891
892
892
test_expect_success ' handle iffy colored hunk headers' '
@@ -896,7 +896,7 @@ test_expect_success 'handle iffy colored hunk headers' '
896
896
printf n >n &&
897
897
force_color git -c interactive.diffFilter="sed s/.*@@.*/XX/" \
898
898
add -p >output 2>&1 <n &&
899
- grep "^XX$" output
899
+ test_grep "^XX$" output
900
900
'
901
901
902
902
test_expect_success ' handle very large filtered diff' '
@@ -1002,7 +1002,7 @@ test_expect_success 'add -p does not expand argument lists' '
1002
1002
# update it, but we want to be sure that our "." pathspec
1003
1003
# was not expanded into the argument list of any command.
1004
1004
# So look only for "not-changed".
1005
- ! grep -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
1005
+ test_grep ! -E "^trace: (built-in|exec|run_command): .*not-changed" trace.out
1006
1006
'
1007
1007
1008
1008
test_expect_success ' hunk-editing handles custom comment char' '
@@ -1072,21 +1072,21 @@ test_expect_success 'setup different kinds of dirty submodules' '
1072
1072
1073
1073
test_expect_success ' status ignores dirty submodules (except HEAD)' '
1074
1074
git -C for-submodules add -i </dev/null >output &&
1075
- grep dirty-head output &&
1076
- grep dirty-both-ways output &&
1077
- ! grep dirty-otherwise output
1075
+ test_grep dirty-head output &&
1076
+ test_grep dirty-both-ways output &&
1077
+ test_grep ! dirty-otherwise output
1078
1078
'
1079
1079
1080
1080
test_expect_success ' handle submodules' '
1081
1081
echo 123 >>for-submodules/dirty-otherwise/initial.t &&
1082
1082
1083
1083
force_color git -C for-submodules add -p dirty-otherwise >output 2>&1 &&
1084
- grep "No changes" output &&
1084
+ test_grep "No changes" output &&
1085
1085
1086
1086
force_color git -C for-submodules add -p dirty-head >output 2>&1 <y &&
1087
1087
git -C for-submodules ls-files --stage dirty-head >actual &&
1088
1088
rev="$(git -C for-submodules/dirty-head rev-parse HEAD)" &&
1089
- grep "$rev" actual
1089
+ test_grep "$rev" actual
1090
1090
'
1091
1091
1092
1092
test_expect_success ' set up pathological context' '
0 commit comments