diff --git a/t/Makefile b/t/Makefile index ab8a5b54aa6ce0..8b0e961386263d 100644 --- a/t/Makefile +++ b/t/Makefile @@ -139,7 +139,7 @@ check-meson: test-lint: test-lint-duplicates test-lint-executable \ test-lint-filenames ifneq ($(PERL_PATH),) -test-lint: test-lint-shell-syntax +test-lint: test-lint-shell-syntax test-lint-grep else GIT_TEST_CHAIN_LINT = 0 endif @@ -160,6 +160,9 @@ test-lint-executable: test-lint-shell-syntax: @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF) +test-lint-grep: + @'$(PERL_PATH_SQ)' check-grep.pl $(T) $(TPERF) + test-lint-filenames: @# We do *not* pass a glob to ls-files but use grep instead, to catch @# non-ASCII characters (which are quoted within double-quotes) diff --git a/t/README b/t/README index adbbd9acf4ab27..c12a1c317a1263 100644 --- a/t/README +++ b/t/README @@ -1039,6 +1039,27 @@ see test-lib-functions.sh for the full list and their options. Check whether a file has the length it is expected to. + - test_grep [!] [] + + Check whether contains a line matching , or + with '!' that no line matches. Use this instead of bare + 'grep ' in test assertions. On failure, + test_grep prints the contents of for easier debugging, + whereas a bare 'grep' would fail silently. + + For negation, pass '!' as the first argument: + + test_grep ! "^diff --git" actual + + Do not negate by writing '! test_grep', as that suppresses the + diagnostic output. + + test_grep should only be used as a test assertion. When grep + is used as a data filter (e.g. 'grep -v "^index" actual >filtered') + or inside a command substitution (e.g. '$(grep -c ...)'), plain + 'grep' is the right choice because the exit code is not the + assertion itself. + - test_path_is_file test_path_is_dir test_path_is_missing diff --git a/t/check-grep.pl b/t/check-grep.pl new file mode 100644 index 00000000000000..1a166176befa9a --- /dev/null +++ b/t/check-grep.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl + +# Detect bare 'grep' in test scripts that should use 'test_grep', +# and '! test_grep' that should be 'test_grep !' (shell negation +# suppresses the diagnostic output). Filter uses (pipelines, +# command substitutions, conditionals) are left alone. + +use strict; +use warnings; + +my $exit_code = 0; + +sub err { + my $msg = shift; + s/^\s+//; + s/\s+$//; + s/\s+/ /g; + print "$ARGV:$.: error: $msg: $_\n"; + $exit_code = 1; +} + +my $line = ''; +my $heredoc_end = ''; +my $prev_file = ''; + +while (<>) { + chomp; + + # Reset state when switching files + if ($ARGV ne $prev_file) { + $heredoc_end = ''; + $line = ''; + $prev_file = $ARGV; + } + + # Skip heredoc bodies + if ($heredoc_end) { + $heredoc_end = '' if /^\s*\Q$heredoc_end\E\s*$/; + next; + } + + $line .= $_; + # Stitch backslash-continued lines + next if $line =~ s/\\$/ /; + # Stitch pipe-continued lines so '|' is visible before 'grep' + next if $line =~ /\|\s*$/; + + $_ = $line; + + # Detect heredoc start (body starts on next line) + if (/<<-?\s*\\?[\\"']?(\w+)[\\"']?\s*(?:&&|\|\|)?\s*$/) { + $heredoc_end = $1; + } + + # '! test_grep' suppresses diagnostics; use 'test_grep !' + if (/!\s*test_grep\b/ && !/^\s*#/ && !/#.*\blint-ok\b/) { + err '! test_grep suppresses diagnostics (use test_grep !)'; + } + + # Flag bare grep that should be test_grep. + # The initial check requires whitespace (or line-start) before + # "grep" so we skip occurrences in filenames (check-grep), + # variable names ($blue_grep), and paths (/usr/bin/grep). + if (/(?:^|\s)grep\b/ && + !/^\s*#/ && + !/#.*\blint-ok\b/ && + !/\btest_grep\b/ && + !/\btest_expect_\w+\b/ && + !/\btest_perf\b/ && + !/\bgit\b[^;&|]*\bgrep\b/ && + !/\|\s*(?:!\s*)?\bgrep\b/ && + !/\bgrep\b.*\s\|\s/ && + !/\bgrep\b.*\s[<>]/ && + !/\$\(.*\bgrep\b/ && + !/`.*\bgrep\b/ && + !/\b(?:if|elif|while|until)\b.*\bgrep\b/ && + !/\bgrep\s+-\w*[clLrR]/) + { + err 'bare grep outside pipeline (use test_grep)'; + } + + $line = ''; + close ARGV if eof; +} +exit $exit_code; diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh index b1cb23880fb2bf..0d88f7b05d9299 100755 --- a/t/perf/p7519-fsmonitor.sh +++ b/t/perf/p7519-fsmonitor.sh @@ -157,7 +157,7 @@ setup_for_fsmonitor_hook () { then test_must_be_empty error # ensure no silent error else - grep "Empty last update token" error + test_grep "Empty last update token" error fi } diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 2b63e1c86cae30..e9f4cea22b81c3 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -743,7 +743,7 @@ test_expect_success 'subtest: lazy prereqs do not turn off tracing' ' test_done EOF - grep "echo trace" lazy-prereq-and-tracing/err + test_grep "echo trace" lazy-prereq-and-tracing/err ' test_expect_success 'subtest: tests clean up after themselves' ' @@ -815,7 +815,7 @@ test_expect_success 'subtest: test_atexit is run' ' test_expect_success 'test_oid provides sane info by default' ' test_oid zero >actual && - grep "^00*\$" actual && + test_grep "^00*\$" actual && rawsz="$(test_oid rawsz)" && hexsz="$(test_oid hexsz)" && # +1 accounts for the trailing newline @@ -827,7 +827,7 @@ test_expect_success 'test_oid can look up data for SHA-1' ' test_when_finished "test_detect_hash" && test_set_hash sha1 && test_oid zero >actual && - grep "^00*\$" actual && + test_grep "^00*\$" actual && rawsz="$(test_oid rawsz)" && hexsz="$(test_oid hexsz)" && test $(wc -c actual && - grep "^00*\$" actual && + test_grep "^00*\$" actual && rawsz="$(test_oid rawsz)" && hexsz="$(test_oid hexsz)" && test $(wc -c err && - grep "error: test_bool_env requires bool values" err && + test_grep "error: test_bool_env requires bool values" err && envvar=true && ! ( test_bool_env envvar invalid ) 7>err && - grep "error: test_bool_env requires bool values" err + test_grep "error: test_bool_env requires bool values" err ) ' @@ -1241,13 +1241,13 @@ test_expect_success 'test_must_fail on a failing git command with env' ' ' test_expect_success 'test_must_fail rejects a non-git command' ' - ! test_must_fail grep ^$ notafile 2>err && - grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err + ! test_must_fail test_grep ^$ notafile 2>err && + test_grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err ' test_expect_success 'test_must_fail rejects a non-git command with env' ' - ! test_must_fail env var1=a var2=b grep ^$ notafile 2>err && - grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err + ! test_must_fail env var1=a var2=b test_grep ^$ notafile 2>err && + test_grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err ' test_done diff --git a/t/t0001-init.sh b/t/t0001-init.sh index e4d32bb4d259f6..7dcd1e9d48a11a 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -278,9 +278,9 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar git init --bare --shared=0660 newdir/a/b/c && test_path_is_dir newdir/a/b/c/refs && ls -ld newdir/a newdir/a/b > lsab.out && - ! grep -v "^drwxrw[sx]r-x" lsab.out && + test_grep ! -v "^drwxrw[sx]r-x" lsab.out && ls -ld newdir/a/b/c > lsc.out && - ! grep -v "^drwxrw[sx]---" lsc.out + test_grep ! -v "^drwxrw[sx]---" lsc.out ) ' @@ -619,7 +619,7 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage is not allowed wi git init refstorage && git -C refstorage config extensions.refStorage files && test_must_fail git -C refstorage rev-parse 2>err && - grep "repo version is 0, but v1-only extension found" err + test_grep "repo version is 0, but v1-only extension found" err ' test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with files backend' ' @@ -637,7 +637,7 @@ test_expect_success DEFAULT_REPO_FORMAT 'extensions.refStorage with unknown back git -C refstorage config core.repositoryformatversion 1 && git -C refstorage config extensions.refStorage garbage && test_must_fail git -C refstorage rev-parse 2>err && - grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err + test_grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err ' test_expect_success 'init with GIT_DEFAULT_REF_FORMAT=garbage' ' @@ -848,8 +848,8 @@ test_expect_success MINGW 'redirect std handles' ' GIT_REDIRECT_STDOUT=output.txt \ GIT_REDIRECT_STDERR="2>&1" \ git rev-parse --git-dir --verify refs/invalid && - grep "^\\.git\$" output.txt && - grep "Needed a single revision" output.txt + test_grep "^\\.git\$" output.txt && + test_grep "Needed a single revision" output.txt ' test_expect_success '--initial-branch' ' @@ -862,14 +862,14 @@ test_expect_success '--initial-branch' ' git init --initial-branch=ignore initial-branch-option 2>err && test_grep "ignored --initial-branch" err && git -C initial-branch-option symbolic-ref HEAD >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'overridden default initial branch name (config)' ' test_config_global init.defaultBranch nmb && GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git init initial-branch-config && git -C initial-branch-config symbolic-ref HEAD >actual && - grep nmb actual + test_grep nmb actual ' test_expect_success 'advice on unconfigured init.defaultBranch' ' @@ -907,7 +907,7 @@ test_expect_success 'overridden default main branch name (env)' ' test_config_global init.defaultBranch nmb && GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=env git init main-branch-env && git -C main-branch-env symbolic-ref HEAD >actual && - grep env actual + test_grep env actual ' test_expect_success 'invalid default branch name' ' diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh index d77a179bddcbed..ed95faf3272e60 100755 --- a/t/t0008-ignores.sh +++ b/t/t0008-ignores.sh @@ -790,8 +790,8 @@ test_expect_success 'existing file and directory' ' >one && mkdir top-level-dir && git check-ignore one top-level-dir >actual && - grep one actual && - grep top-level-dir actual + test_grep one actual && + test_grep top-level-dir actual ' test_expect_success 'existing directory and file' ' @@ -800,8 +800,8 @@ test_expect_success 'existing directory and file' ' >one && mkdir top-level-dir && git check-ignore top-level-dir one >actual && - grep one actual && - grep top-level-dir actual + test_grep one actual && + test_grep top-level-dir actual ' test_expect_success 'exact prefix matching (with root)' ' diff --git a/t/t0009-git-dir-validation.sh b/t/t0009-git-dir-validation.sh index 33d21ed9ea1061..4cba478e50e712 100755 --- a/t/t0009-git-dir-validation.sh +++ b/t/t0009-git-dir-validation.sh @@ -35,7 +35,7 @@ test_expect_success PIPE 'setup: .git as a FIFO (named pipe) is rejected' ' cd parent/fifo-trap && mkfifo .git && test_must_fail git rev-parse --git-dir 2>stderr && - grep "not a regular file" stderr + test_grep "not a regular file" stderr ) ' @@ -47,7 +47,7 @@ test_expect_success SYMLINKS,PIPE 'setup: .git as a symlink to a FIFO is rejecte mkfifo target-fifo && ln -s target-fifo .git && test_must_fail git rev-parse --git-dir 2>stderr && - grep "not a regular file" stderr + test_grep "not a regular file" stderr ) ' @@ -58,7 +58,7 @@ test_expect_success 'setup: .git with garbage content is rejected' ' cd parent/garbage-trap && echo "garbage" >.git && test_must_fail git rev-parse --git-dir 2>stderr && - grep "invalid gitfile format" stderr + test_grep "invalid gitfile format" stderr ) ' diff --git a/t/t0012-help.sh b/t/t0012-help.sh index c33501bdcd2b9b..48d128ad043ede 100755 --- a/t/t0012-help.sh +++ b/t/t0012-help.sh @@ -131,8 +131,8 @@ test_expect_success 'git help succeeds without git.html' ' test_expect_success 'git help --user-interfaces' ' git help --user-interfaces >help.output && - grep "^ attributes " help.output && - grep "^ mailmap " help.output + test_grep "^ attributes " help.output && + test_grep "^ mailmap " help.output ' test_expect_success 'git help -c' ' diff --git a/t/t0013-sha1dc.sh b/t/t0013-sha1dc.sh index ce3d81227a0f0c..3ea3169d92ff7c 100755 --- a/t/t0013-sha1dc.sh +++ b/t/t0013-sha1dc.sh @@ -16,7 +16,7 @@ fi test_expect_success 'test-sha1 detects shattered pdf' ' test_must_fail test-tool sha1 <"$TEST_DATA/shattered-1.pdf" 2>err && test_grep collision err && - grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err + test_grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err ' test_done diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index 5144b0effd78aa..2f5c36cddf6c45 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -105,7 +105,7 @@ cannot_alias_regular_builtin () { } test_expect_success 'cannot alias-shadow a sample of regular builtins' ' - for cmd in grep check-ref-format interpret-trailers \ + for cmd in test_grep check-ref-format interpret-trailers \ checkout-index fast-import diagnose rev-list prune do cannot_alias_regular_builtin "$cmd" || return 1 diff --git a/t/t0017-env-helper.sh b/t/t0017-env-helper.sh index 32fe8481792325..da02bce0ef5046 100755 --- a/t/t0017-env-helper.sh +++ b/t/t0017-env-helper.sh @@ -88,7 +88,7 @@ test_expect_success 'test-tool env-helper reads config thanks to trace2' ' test_must_fail \ env HOME="$(pwd)/home" \ git config -l 2>err && - grep "exceeded maximum include depth" err && + test_grep "exceeded maximum include depth" err && # This validates that the assumption that we attempt to # read the configuration and fail very early in the start-up @@ -100,7 +100,7 @@ test_expect_success 'test-tool env-helper reads config thanks to trace2' ' test-tool -C no-such-directory \ env-helper --type=bool --default=0 \ --exit-code GIT_TEST_ENV_HELPER 2>err && - grep "exceeded maximum include depth" err + test_grep "exceeded maximum include depth" err ' test_done diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index f0d50d769e9fc5..a8c79b630c21c3 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -731,7 +731,7 @@ test_expect_success 'process filter should restart after unexpected write failur rm -f debug.log && git checkout --quiet --no-progress . 2>git-stderr.log && - grep "smudge write error" git-stderr.log && + test_grep "smudge write error" git-stderr.log && test_grep "error: external filter" git-stderr.log && cat >expected.log <<-EOF && @@ -853,7 +853,7 @@ test_expect_success 'invalid process filter must fail (and not hang!)' ' cp "$TEST_ROOT/test.o" test.r && test_must_fail git add . 2>git-stderr.log && - grep "expected git-filter-server" git-stderr.log + test_grep "expected git-filter-server" git-stderr.log ) ' @@ -953,7 +953,7 @@ test_expect_success 'missing file in delayed checkout' ' rm -rf repo-cloned && test_must_fail git clone repo repo-cloned 2>git-stderr.log && - grep "error: .missing-delay\.a. was not filtered properly" git-stderr.log + test_grep "error: .missing-delay\.a. was not filtered properly" git-stderr.log ' test_expect_success 'invalid file in delayed checkout' ' @@ -974,7 +974,7 @@ test_expect_success 'invalid file in delayed checkout' ' rm -rf repo-cloned && test_must_fail git clone repo repo-cloned 2>git-stderr.log && - grep "error: external filter .* signaled that .unfiltered. is now available although it has not been delayed earlier" git-stderr.log + test_grep "error: external filter .* signaled that .unfiltered. is now available although it has not been delayed earlier" git-stderr.log ' for mode in 'case' 'utf-8' @@ -1015,7 +1015,7 @@ do git clone $mode-collision $mode-collision-cloned && # Make sure z was really delayed - grep "IN: smudge $dir/z .* \\[DELAYED\\]" $mode-collision-cloned/delayed.log && + test_grep "IN: smudge $dir/z .* \\[DELAYED\\]" $mode-collision-cloned/delayed.log && # Should not create $dir/z at $symlink/z test_path_is_missing $mode-collision/target-dir/z @@ -1053,7 +1053,7 @@ test_expect_success SYMLINKS,CASE_INSENSITIVE_FS \ git commit -m super && git checkout --recurse-submodules . && - grep "IN: smudge A/B/y .* \\[DELAYED\\]" delayed.log && + test_grep "IN: smudge A/B/y .* \\[DELAYED\\]" delayed.log && test_path_is_missing target-dir/y ) ' @@ -1093,12 +1093,12 @@ test_delayed_checkout_progress () { rm -f *.a delay-progress.log && "$@" 2>err && - grep "IN: smudge test-delay10.a .* \\[DELAYED\\]" delay-progress.log && + test_grep "IN: smudge test-delay10.a .* \\[DELAYED\\]" delay-progress.log && if test "$expect_progress" = N then - ! grep "Filtering content" err + test_grep ! "Filtering content" err else - grep "Filtering content" err + test_grep "Filtering content" err fi ) } @@ -1144,9 +1144,9 @@ test_expect_success 'delayed checkout correctly reports the number of updated en rm *.a && git checkout . 2>err && - grep "IN: smudge test-delay10.a .* \\[DELAYED\\]" delayed.log && - grep "IN: smudge test-delay11.a .* \\[DELAYED\\]" delayed.log && - grep "Updated 2 paths from the index" err + test_grep "IN: smudge test-delay10.a .* \\[DELAYED\\]" delayed.log && + test_grep "IN: smudge test-delay11.a .* \\[DELAYED\\]" delayed.log && + test_grep "Updated 2 paths from the index" err ) ' diff --git a/t/t0029-core-unsetenvvars.sh b/t/t0029-core-unsetenvvars.sh index baa1b7e85b10b4..975620b3891b76 100755 --- a/t/t0029-core-unsetenvvars.sh +++ b/t/t0029-core-unsetenvvars.sh @@ -20,10 +20,10 @@ test_expect_success 'core.unsetenvvars works' ' HOBBES=Calvin && export HOBBES && git commit --allow-empty -m with 2>err && - grep Calvin err && + test_grep Calvin err && git -c core.unsetenvvars=FINDUS,HOBBES,CALVIN \ commit --allow-empty -m without 2>err && - ! grep Calvin err + test_grep ! Calvin err ' test_done diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index 43155f6bd86bf4..d6e2f63c595074 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -407,12 +407,12 @@ test_expect_success 'strip comments with changed comment string' ' test_expect_success 'newline as commentchar is forbidden' ' test_must_fail git -c core.commentChar="$LF" stripspace -s 2>err && - grep "core.commentchar cannot contain newline" err + test_grep "core.commentchar cannot contain newline" err ' test_expect_success 'empty commentchar is forbidden' ' test_must_fail git -c core.commentchar= stripspace -s 2>err && - grep "core.commentchar must have at least one character" err + test_grep "core.commentchar must have at least one character" err ' test_expect_success '-c with single line' ' diff --git a/t/t0031-lockfile-pid.sh b/t/t0031-lockfile-pid.sh index 8ef87addf56f1e..e9e2f0404971ce 100755 --- a/t/t0031-lockfile-pid.sh +++ b/t/t0031-lockfile-pid.sh @@ -29,7 +29,7 @@ test_expect_success 'PID info not shown by default' ' test_must_fail git add . 2>err && # Should not crash, just show normal error without PID test_grep "Unable to create" err && - ! test_grep "is held by process" err + test_grep ! "is held by process" err ) ' diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh index e103fe710927ce..66bb97fde379bb 100755 --- a/t/t0033-safe-directory.sh +++ b/t/t0033-safe-directory.sh @@ -9,7 +9,7 @@ export GIT_TEST_ASSUME_DIFFERENT_OWNER expect_rejected_dir () { test_must_fail git status 2>err && - grep "dubious ownership" err + test_grep "dubious ownership" err } test_expect_success 'safe.directory is not set' ' diff --git a/t/t0035-safe-bare-repository.sh b/t/t0035-safe-bare-repository.sh index 1d3d19f5b476a0..93bd350416ab10 100755 --- a/t/t0035-safe-bare-repository.sh +++ b/t/t0035-safe-bare-repository.sh @@ -11,21 +11,21 @@ expect_accepted_implicit () { GIT_TRACE2_PERF="$pwd/trace.perf" git "$@" rev-parse --git-dir && # Note: we're intentionally only checking that the bare repo has a # directory *prefix* of $pwd - grep -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" + test_grep -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" } expect_accepted_explicit () { test_when_finished 'rm "$pwd/trace.perf"' && GIT_DIR="$1" GIT_TRACE2_PERF="$pwd/trace.perf" git rev-parse --git-dir && - ! grep -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" + test_grep ! -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" } expect_rejected () { test_when_finished 'rm "$pwd/trace.perf"' && test_env GIT_TRACE2_PERF="$pwd/trace.perf" \ test_must_fail git "$@" rev-parse --git-dir 2>err && - grep -F "cannot use bare repository" err && - grep -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" + test_grep -F "cannot use bare repository" err && + test_grep -F "implicit-bare-repository:$pwd" "$pwd/trace.perf" } test_expect_success 'setup an embedded bare repo, secondary worktree and submodule' ' diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index ca55ea8228c378..a8348a851c438c 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -324,13 +324,13 @@ test_expect_success 'non ambiguous option (after two options it abbreviates)' ' test_expect_success 'Alias options do not contribute to abbreviation' ' test-tool parse-options --alias-source 123 >output && - grep "^string: 123" output && + test_grep "^string: 123" output && test-tool parse-options --alias-target 123 >output && - grep "^string: 123" output && + test_grep "^string: 123" output && test_must_fail test-tool parse-options --alias && GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ test-tool parse-options --alias 123 >output && - grep "^string: 123" output + test_grep "^string: 123" output ' cat >typo.err <<\EOF @@ -582,16 +582,16 @@ test_expect_success 'KEEP_UNKNOWN_OPT works' ' test_expect_success 'NO_INTERNAL_HELP works for -h' ' test_expect_code 129 test-tool parse-options-flags --no-internal-help cmd -h 2>err && - grep "^error: unknown switch \`h$SQ" err && - grep "^usage: " err + test_grep "^error: unknown switch \`h$SQ" err && + test_grep "^usage: " err ' for help_opt in help help-all do test_expect_success "NO_INTERNAL_HELP works for --$help_opt" " test_expect_code 129 test-tool parse-options-flags --no-internal-help cmd --$help_opt 2>err && - grep '^error: unknown option \`'$help_opt\' err && - grep '^usage: ' err + test_grep '^error: unknown option \`'$help_opt\' err && + test_grep '^usage: ' err " done @@ -608,38 +608,38 @@ test_expect_success 'KEEP_UNKNOWN_OPT | NO_INTERNAL_HELP works' ' test_expect_success 'subcommand - no subcommand shows error and usage' ' test_expect_code 129 test-tool parse-subcommand cmd 2>err && - grep "^error: need a subcommand" err && - grep ^usage: err + test_grep "^error: need a subcommand" err && + test_grep ^usage: err ' test_expect_success 'subcommand - subcommand after -- shows error and usage' ' test_expect_code 129 test-tool parse-subcommand cmd -- subcmd-one 2>err && - grep "^error: need a subcommand" err && - grep ^usage: err + test_grep "^error: need a subcommand" err && + test_grep ^usage: err ' test_expect_success 'subcommand - subcommand after --end-of-options shows error and usage' ' test_expect_code 129 test-tool parse-subcommand cmd --end-of-options subcmd-one 2>err && - grep "^error: need a subcommand" err && - grep ^usage: err + test_grep "^error: need a subcommand" err && + test_grep ^usage: err ' test_expect_success 'subcommand - unknown subcommand shows error and usage' ' test_expect_code 129 test-tool parse-subcommand cmd nope 2>err && - grep "^error: unknown subcommand: \`nope$SQ" err && - grep ^usage: err + test_grep "^error: unknown subcommand: \`nope$SQ" err && + test_grep ^usage: err ' test_expect_success 'subcommand - subcommands cannot be abbreviated' ' test_expect_code 129 test-tool parse-subcommand cmd subcmd-o 2>err && - grep "^error: unknown subcommand: \`subcmd-o$SQ$" err && - grep ^usage: err + test_grep "^error: unknown subcommand: \`subcmd-o$SQ$" err && + test_grep ^usage: err ' test_expect_success 'subcommand - no negated subcommands' ' test_expect_code 129 test-tool parse-subcommand cmd no-subcmd-one 2>err && - grep "^error: unknown subcommand: \`no-subcmd-one$SQ" err && - grep ^usage: err + test_grep "^error: unknown subcommand: \`no-subcmd-one$SQ" err && + test_grep ^usage: err ' test_expect_success 'subcommand - simple' ' @@ -709,8 +709,8 @@ test_expect_success 'subcommand - SUBCOMMAND_OPTIONAL + subcommand not given + u test_expect_success 'subcommand - SUBCOMMAND_OPTIONAL + subcommand not given + unknown option' ' test_expect_code 129 test-tool parse-subcommand --subcommand-optional cmd --subcommand-opt 2>err && - grep "^error: unknown option" err && - grep ^usage: err + test_grep "^error: unknown option" err && + test_grep ^usage: err ' test_expect_success 'subcommand - SUBCOMMAND_OPTIONAL | KEEP_UNKNOWN_OPT + subcommand not given + unknown option' ' @@ -778,28 +778,28 @@ test_expect_success 'subcommand - completion helper' ' test_expect_success 'subcommands are incompatible with STOP_AT_NON_OPTION' ' test_must_fail test-tool parse-subcommand --stop-at-non-option cmd subcmd-one 2>err && - grep ^BUG err + test_grep ^BUG err ' test_expect_success 'subcommands are incompatible with KEEP_UNKNOWN_OPT unless in combination with SUBCOMMAND_OPTIONAL' ' test_must_fail test-tool parse-subcommand --keep-unknown-opt cmd subcmd-two 2>err && - grep ^BUG err + test_grep ^BUG err ' test_expect_success 'subcommands are incompatible with KEEP_DASHDASH unless in combination with SUBCOMMAND_OPTIONAL' ' test_must_fail test-tool parse-subcommand --keep-dashdash cmd subcmd-two 2>err && - grep ^BUG err + test_grep ^BUG err ' test_expect_success 'negative unsigned' ' test_must_fail test-tool parse-options --unsigned -1 >out 2>err && - grep "non-negative integer" err && + test_grep "non-negative integer" err && test_must_be_empty out ' test_expect_success 'unsigned with units but no numbers' ' test_must_fail test-tool parse-options --unsigned m >out 2>err && - grep "non-negative integer" err && + test_grep "non-negative integer" err && test_must_be_empty out ' diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh index a0f6f134c71822..51af7cc0300efb 100755 --- a/t/t0041-usage.sh +++ b/t/t0041-usage.sh @@ -13,7 +13,7 @@ test_expect_success 'setup ' ' test_expect_success 'tag --contains ' ' git tag --contains "v1.0" >actual 2>actual.err && - grep "v1.0" actual && + test_grep "v1.0" actual && test_line_count = 0 actual.err ' diff --git a/t/t0052-simple-ipc.sh b/t/t0052-simple-ipc.sh index ff98be31a51b36..14cea84920271a 100755 --- a/t/t0052-simple-ipc.sh +++ b/t/t0052-simple-ipc.sh @@ -33,19 +33,19 @@ test_expect_success 'servers cannot share the same path' ' test_expect_success 'big response' ' test-tool simple-ipc send --token=big >actual && test_line_count -ge 10000 actual && - grep -q "big: [0]*9999\$" actual + test_grep -q "big: [0]*9999\$" actual ' test_expect_success 'chunk response' ' test-tool simple-ipc send --token=chunk >actual && test_line_count -ge 10000 actual && - grep -q "big: [0]*9999\$" actual + test_grep -q "big: [0]*9999\$" actual ' test_expect_success 'slow response' ' test-tool simple-ipc send --token=slow >actual && test_line_count -ge 100 actual && - grep -q "big: [0]*99\$" actual + test_grep -q "big: [0]*99\$" actual ' # Send an IPC with n=100,000 bytes of ballast. This should be large enough @@ -54,7 +54,7 @@ test_expect_success 'slow response' ' # test_expect_success 'sendbytes' ' test-tool simple-ipc sendbytes --bytecount=100000 --byte=A >actual && - grep "sent:A00100000 rcvd:A00100000" actual + test_grep "sent:A00100000 rcvd:A00100000" actual ' # Start a series of client threads that each make @@ -93,7 +93,7 @@ test_expect_success 'stress test threads' ' --batchsize=13 \ >actual && test_line_count = 92 actual && - grep "good 91" actual && + test_grep "good 91" actual && grep "sent:A" actual_a && cat >expect_a <<-EOF && sent:A00000019 rcvd:A00000019 diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 60cfe65979e215..dc9d77b0e14ab4 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -97,7 +97,7 @@ test_expect_success POSIXPERM 'run_command reports EACCES' ' chmod -x hello.sh && test_must_fail test-tool run-command run-command ./hello.sh 2>err && - grep "fatal: cannot exec.*hello.sh" err + test_grep "fatal: cannot exec.*hello.sh" err ' test_expect_success POSIXPERM,SANITY 'unreadable directory in PATH' ' diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh index df3e9f5fa5d4b5..9fbb41bac5a1b6 100755 --- a/t/t0066-dir-iterator.sh +++ b/t/t0066-dir-iterator.sh @@ -127,7 +127,7 @@ test_expect_success SYMLINKS 'dir-iterator should not follow symlinks by default test_expect_success SYMLINKS 'dir-iterator does not resolve top-level symlinks' ' test_must_fail test-tool dir-iterator ./dir5 >out && - grep "ENOTDIR" out + test_grep "ENOTDIR" out ' test_done diff --git a/t/t0068-for-each-repo.sh b/t/t0068-for-each-repo.sh index 80b163ea99bd75..55b37d895af648 100755 --- a/t/t0068-for-each-repo.sh +++ b/t/t0068-for-each-repo.sh @@ -21,23 +21,23 @@ test_expect_success 'run based on configured value' ' git for-each-repo --config=run.key commit --allow-empty -m "ran" && git -C one log -1 --pretty=format:%s >message && - grep ran message && + test_grep ran message && git -C two log -1 --pretty=format:%s >message && - ! grep ran message && + test_grep ! ran message && git -C three log -1 --pretty=format:%s >message && - grep ran message && + test_grep ran message && git -C ~/four log -1 --pretty=format:%s >message && - grep ran message && + test_grep ran message && git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" && git -C one log -1 --pretty=format:%s >message && - grep again message && + test_grep again message && git -C two log -1 --pretty=format:%s >message && - ! grep again message && + test_grep ! again message && git -C three log -1 --pretty=format:%s >message && - grep again message && + test_grep again message && git -C ~/four log -1 --pretty=format:%s >message && - grep again message && + test_grep again message && git -C three for-each-repo --config=run.key -- \ commit --allow-empty -m "ran from worktree" && diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh index 6b9dcf984bcb54..8f573c2a0e7f11 100755 --- a/t/t0070-fundamental.sh +++ b/t/t0070-fundamental.sh @@ -10,7 +10,7 @@ Verify wrappers and compatibility functions. test_expect_success 'mktemp to nonexistent directory prints filename' ' test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err && - grep "doesnotexist/test" err + test_grep "doesnotexist/test" err ' test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints filename' ' @@ -18,7 +18,7 @@ test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints file test_when_finished "chmod +w cannotwrite" && chmod -w cannotwrite && test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err && - grep "cannotwrite/test" err + test_grep "cannotwrite/test" err ' test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' ' @@ -33,7 +33,7 @@ test_expect_success 'check for a bug in the regex routines' ' test_expect_success 'incomplete sideband messages are reassembled' ' test-tool pkt-line send-split-sideband >split-sideband && test-tool pkt-line receive-sideband err && - grep "Hello, world" err + test_grep "Hello, world" err ' test_expect_success 'eof on sideband message is reported' ' diff --git a/t/t0081-find-pack.sh b/t/t0081-find-pack.sh index 26f017422d7253..ff9d56fbf10572 100755 --- a/t/t0081-find-pack.sh +++ b/t/t0081-find-pack.sh @@ -52,17 +52,17 @@ test_expect_success 'add more packfiles' ' # HEAD^{tree} is in 2 packfiles test-tool find-pack HEAD^{tree} >head_tree_packs && - grep "$head_commit_pack" head_tree_packs && - grep mypackname1 head_tree_packs && - ! grep mypackname2 head_tree_packs && + test_grep "$head_commit_pack" head_tree_packs && + test_grep mypackname1 head_tree_packs && + test_grep ! mypackname2 head_tree_packs && test-tool find-pack --check-count 2 HEAD^{tree} && ! test-tool find-pack --check-count 1 HEAD^{tree} && # HEAD:five.t is also in 2 packfiles test-tool find-pack HEAD:five.t >five_packs && - grep "$head_commit_pack" five_packs && - ! grep mypackname1 five_packs && - grep mypackname2 five_packs && + test_grep "$head_commit_pack" five_packs && + test_grep ! mypackname1 five_packs && + test_grep mypackname2 five_packs && test-tool find-pack -c 2 HEAD:five.t && ! test-tool find-pack --check-count=0 HEAD:five.t ' diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh index e38ca7a9018751..81ed41742c504e 100755 --- a/t/t0091-bugreport.sh +++ b/t/t0091-bugreport.sh @@ -40,15 +40,15 @@ test_expect_success 'sanity check "System Info" section' ' # The beginning should match "git version --build-options" verbatim, # but rather than checking bit-for-bit equality, just test some basics. - grep "git version " system && - grep "shell-path: ." system && + test_grep "git version " system && + test_grep "shell-path: ." system && # After the version, there should be some more info. # This is bound to differ from environment to environment, # so we just do some rather high-level checks. - grep "uname: ." system && - grep "compiler info: ." system && - grep "zlib." system + test_grep "uname: ." system && + test_grep "compiler info: ." system && + test_grep "zlib." system ' test_expect_success 'dies if file with same name as report already exists' ' @@ -112,7 +112,7 @@ test_expect_success UNZIP '--diagnose creates diagnostics zip archive' ' git bugreport --diagnose -o report -s test >out && zip_path=report/git-diagnostics-test.zip && - grep "Available space" out && + test_grep "Available space" out && test_path_is_file "$zip_path" && # Check zipped archive content @@ -120,10 +120,10 @@ test_expect_success UNZIP '--diagnose creates diagnostics zip archive' ' test_file_not_empty out && "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out && - grep ".git/objects" out && + test_grep ".git/objects" out && "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out && - grep "^Total: [0-9][0-9]*" out && + test_grep "^Total: [0-9][0-9]*" out && # Should not include .git directory contents by default ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/" @@ -136,7 +136,7 @@ test_expect_success UNZIP '--diagnose=stats excludes .git dir contents' ' # Includes pack quantity/size info "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out && - grep ".git/objects" out && + test_grep ".git/objects" out && # Does not include .git directory contents ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/" diff --git a/t/t0092-diagnose.sh b/t/t0092-diagnose.sh index 6cabd6e67b9a14..0bc2b1ed5c50bb 100755 --- a/t/t0092-diagnose.sh +++ b/t/t0092-diagnose.sh @@ -8,7 +8,7 @@ test_expect_success UNZIP 'creates diagnostics zip archive' ' test_when_finished rm -rf report && git diagnose -o report -s test >out && - grep "Available space" out && + test_grep "Available space" out && zip_path=report/git-diagnostics-test.zip && test_path_is_file "$zip_path" && @@ -18,10 +18,10 @@ test_expect_success UNZIP 'creates diagnostics zip archive' ' test_file_not_empty out && "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out && - grep ".git/objects" out && + test_grep ".git/objects" out && "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out && - grep "^Total: [0-9][0-9]*" out && + test_grep "^Total: [0-9][0-9]*" out && # Should not include .git directory contents by default ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/" @@ -34,7 +34,7 @@ test_expect_success UNZIP 'counts loose objects' ' git diagnose -o test-count -s 1 >out && zip_path=test-count/git-diagnostics-1.zip && "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out && - grep "^Total: [1-9][0-9]* loose objects" out + test_grep "^Total: [1-9][0-9]* loose objects" out ' test_expect_success UNZIP '--mode=stats excludes .git dir contents' ' @@ -45,7 +45,7 @@ test_expect_success UNZIP '--mode=stats excludes .git dir contents' ' # Includes pack quantity/size info zip_path=report/git-diagnostics-test.zip && "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out && - grep ".git/objects" out && + test_grep ".git/objects" out && # Does not include .git directory contents ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/" @@ -59,7 +59,7 @@ test_expect_success UNZIP '--mode=all includes .git dir contents' ' # Includes pack quantity/size info zip_path=report/git-diagnostics-test.zip && "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out && - grep ".git/objects" out && + test_grep ".git/objects" out && # Includes .git directory contents "$GIT_UNZIP" -l "$zip_path" | grep ".git/" && diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh index dd5d9b4e5ebdf2..87a9995ea4eb6a 100755 --- a/t/t0100-previous.sh +++ b/t/t0100-previous.sh @@ -50,7 +50,7 @@ test_expect_success 'merge @{-1}~1' ' git checkout main && git merge @{-1}~1 && git cat-file commit HEAD >actual && - grep "Merge branch '\''other'\''" actual + test_grep "Merge branch '\''other'\''" actual ' test_expect_success 'merge @{-100} before checking out that many branches yet' ' diff --git a/t/t0200-gettext-basic.sh b/t/t0200-gettext-basic.sh index 8853d8afb923e6..4fc3c18dcbf88f 100755 --- a/t/t0200-gettext-basic.sh +++ b/t/t0200-gettext-basic.sh @@ -16,7 +16,7 @@ test_expect_success 'sanity: $TEXTDOMAIN is git' ' ' test_expect_success 'xgettext sanity: Perl _() strings are not extracted' ' - ! grep "A Perl string xgettext will not get" "$GIT_PO_PATH"/is.po + test_grep ! "A Perl string xgettext will not get" "$GIT_PO_PATH"/is.po ' test_expect_success 'xgettext sanity: Comment extraction with --add-comments' ' @@ -26,8 +26,8 @@ test_expect_success 'xgettext sanity: Comment extraction with --add-comments' ' ' test_expect_success 'xgettext sanity: Comment extraction with --add-comments stops at statements' ' - ! grep "This is a phony" "$GIT_PO_PATH"/is.po && - ! grep "the above comment" "$GIT_PO_PATH"/is.po + test_grep ! "This is a phony" "$GIT_PO_PATH"/is.po && + test_grep ! "the above comment" "$GIT_PO_PATH"/is.po ' test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' ' @@ -44,10 +44,10 @@ test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' ' test_expect_success GETTEXT_LOCALE 'sanity: gettext("") metadata is OK' ' # Return value may be non-zero LANGUAGE=is LC_ALL="$is_IS_locale" gettext "" >zero-expect && - grep "Project-Id-Version: Git" zero-expect && + test_grep "Project-Id-Version: Git" zero-expect && grep "Git Mailing List " zero-expect && - grep "Content-Type: text/plain; charset=UTF-8" zero-expect && - grep "Content-Transfer-Encoding: 8bit" zero-expect + test_grep "Content-Type: text/plain; charset=UTF-8" zero-expect && + test_grep "Content-Transfer-Encoding: 8bit" zero-expect ' test_expect_success GETTEXT_LOCALE 'sanity: gettext(unknown) is passed through' ' diff --git a/t/t0203-gettext-setlocale-sanity.sh b/t/t0203-gettext-setlocale-sanity.sh index 0ce1f22eff6628..670082bf093da3 100755 --- a/t/t0203-gettext-setlocale-sanity.sh +++ b/t/t0203-gettext-setlocale-sanity.sh @@ -12,7 +12,7 @@ test_expect_success 'git show a ISO-8859-1 commit under C locale' ' test_commit "iso-c-commit" iso-under-c && git show >out 2>err && test_must_be_empty err && - grep -q "iso-c-commit" out + test_grep -q "iso-c-commit" out ' test_expect_success GETTEXT_LOCALE 'git show a ISO-8859-1 commit under a UTF-8 locale' ' @@ -20,7 +20,7 @@ test_expect_success GETTEXT_LOCALE 'git show a ISO-8859-1 commit under a UTF-8 l test_commit "iso-utf8-commit" iso-under-utf8 && LANGUAGE=is LC_ALL="$is_IS_locale" git show >out 2>err && test_must_be_empty err && - grep -q "iso-utf8-commit" out + test_grep -q "iso-utf8-commit" out ' test_done diff --git a/t/t0204-gettext-reencode-sanity.sh b/t/t0204-gettext-reencode-sanity.sh index 28d92bb9b7cade..399404a80c16ba 100755 --- a/t/t0204-gettext-reencode-sanity.sh +++ b/t/t0204-gettext-reencode-sanity.sh @@ -66,7 +66,7 @@ test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' ' # eyes. test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' ' LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual && - grep "einfaldar" actual && + test_grep "einfaldar" actual && grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual ' @@ -74,7 +74,7 @@ test_expect_success GETTEXT_LOCALE 'gettext.c: git init UTF-8 -> UTF-8' ' printf "Bjó til tóma Git lind" >expect && LANGUAGE=is LC_ALL="$is_IS_locale" git init repo >actual && test_when_finished "rm -rf repo" && - grep "^$(cat expect) " actual + test_grep "^$(cat expect) " actual ' test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1' ' diff --git a/t/t0210-trace2-normal.sh b/t/t0210-trace2-normal.sh index 7e1e7af862b430..beed2b27a57f0a 100755 --- a/t/t0210-trace2-normal.sh +++ b/t/t0210-trace2-normal.sh @@ -333,12 +333,12 @@ test_expect_success 'unsafe URLs are redacted by default' ' GIT_TRACE2="$(pwd)/trace.normal" \ git clone https://user:pwd@example.com/ clone && - ! grep user:pwd trace.normal && + test_grep ! user:pwd trace.normal && GIT_TRACE2_REDACT=0 GIT_TRACE2="$(pwd)/unredacted.normal" \ git clone https://user:pwd@example.com/ clone2 && - grep "start .* clone https://user:pwd@example.com" unredacted.normal && - grep "remote.origin.url=https://user:pwd@example.com" unredacted.normal + test_grep "start .* clone https://user:pwd@example.com" unredacted.normal && + test_grep "remote.origin.url=https://user:pwd@example.com" unredacted.normal ' test_done diff --git a/t/t0211-trace2-perf.sh b/t/t0211-trace2-perf.sh index 760cf69087f079..92cb085a4d4c99 100755 --- a/t/t0211-trace2-perf.sh +++ b/t/t0211-trace2-perf.sh @@ -192,7 +192,7 @@ have_timer_event () { pattern="d0|${thread}|${event}||||${category}|name:${name} intervals:${intervals}" && - grep "${pattern}" ${file} + test_grep "${pattern}" ${file} } test_expect_success 'stopwatch timer test/test1' ' @@ -238,7 +238,7 @@ have_counter_event () { pattern="d0|${thread}|${event}||||${category}|name:${name} value:${value}" && - grep "${pattern}" ${file} + test_grep "${pattern}" ${file} } test_expect_success 'global counter test/test1' ' @@ -283,13 +283,13 @@ test_expect_success 'unsafe URLs are redacted by default' ' GIT_TRACE2_PERF="$(pwd)/trace.perf" \ git clone https://user:pwd@example.com/ clone && - ! grep user:pwd trace.perf && + test_grep ! user:pwd trace.perf && GIT_TRACE2_REDACT=0 GIT_TRACE2_PERF="$(pwd)/unredacted.perf" \ git clone https://user:pwd@example.com/ clone2 && perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && - grep "d0|main|start|.* clone https://user:pwd@example.com" actual && - grep "d0|main|def_param|.*|remote.origin.url:https://user:pwd@example.com" actual + test_grep "d0|main|start|.* clone https://user:pwd@example.com" actual && + test_grep "d0|main|def_param|.*|remote.origin.url:https://user:pwd@example.com" actual ' # Confirm that the requested command produces a "cmd_name" and a @@ -310,9 +310,9 @@ try_simple () { GIT_TRACE2_PERF="$(pwd)/prop.perf" \ $cmd && perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && - grep "d0|main|cmd_name|.*|$cmd_name" actual && - grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d0|main|cmd_name|.*|$cmd_name" actual && + test_grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual } # Representative mainstream builtin Git command dispatched @@ -358,13 +358,13 @@ test_expect_success LIBCURL \ perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && - grep "d0|main|cmd_name|.*|_run_dashed_" actual && - grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_" actual && + test_grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && - grep "d1|main|cmd_name|.*|remote-curl" actual && - grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d1|main|cmd_name|.*|remote-curl" actual && + test_grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' # Similarly, `git-http-fetch` is not built from git.c so do a @@ -389,13 +389,13 @@ test_expect_success LIBCURL \ perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && - grep "d0|main|cmd_name|.*|_run_dashed_" actual && - grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_" actual && + test_grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && - grep "d1|main|cmd_name|.*|http-fetch" actual && - grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d1|main|cmd_name|.*|http-fetch" actual && + test_grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' # Historically, alias expansion explicitly emitted the def_param @@ -421,22 +421,22 @@ test_expect_success 'expect def_params during git alias expansion' ' perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && # "git xxx" is first mapped to "git-xxx" and the child will fail. - grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && # We unpeel that and substitute "version" into "xxx" (giving # "git version") and update the cmd_name event. - grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_git_alias_)" actual && + test_grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_git_alias_)" actual && # These def_param events could be associated with either of the # above cmd_name events. It does not matter. - grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + test_grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && # The "git version" child sees a different cmd_name hierarchy. # Also test the def_param (only for completeness). - grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_git_alias_/version)" actual && - grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_git_alias_/version)" actual && + test_grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' test_expect_success 'expect def_params during shell alias expansion' ' @@ -456,25 +456,25 @@ test_expect_success 'expect def_params during shell alias expansion' ' perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && # "git xxx" is first mapped to "git-xxx" and the child will fail. - grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && # We unpeel that and substitute "git version" for "git xxx" (as a # shell command. Another cmd_name event is emitted as we unpeel. - grep "d0|main|cmd_name|.*|_run_shell_alias_ (_run_dashed_/_run_shell_alias_)" actual && + test_grep "d0|main|cmd_name|.*|_run_shell_alias_ (_run_dashed_/_run_shell_alias_)" actual && # These def_param events could be associated with either of the # above cmd_name events. It does not matter. - grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + test_grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && # We get the following only because we used a git command for the # shell command. In general, it could have been a shell script and # we would see nothing. # # The child knows the cmd_name hierarchy so it includes it. - grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_shell_alias_/version)" actual && - grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_shell_alias_/version)" actual && + test_grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' test_expect_success 'expect def_params during nested git alias expansion' ' @@ -496,33 +496,33 @@ test_expect_success 'expect def_params during nested git alias expansion' ' # "git xxx" is first mapped to "git-xxx" and try to spawn "git-xxx" # and the child will fail. - grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && - grep "d0|main|child_start|.*|.* class:dashed argv:\[git-xxx\]" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + test_grep "d0|main|child_start|.*|.* class:dashed argv:\[git-xxx\]" actual && # We unpeel that and substitute "yyy" into "xxx" (giving "git yyy") # and spawn "git-yyy" and the child will fail. - grep "d0|main|alias|.*|alias:xxx argv:\[yyy\]" actual && - grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_/_run_dashed_)" actual && - grep "d0|main|child_start|.*|.* class:dashed argv:\[git-yyy\]" actual && + test_grep "d0|main|alias|.*|alias:xxx argv:\[yyy\]" actual && + test_grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_/_run_dashed_)" actual && + test_grep "d0|main|child_start|.*|.* class:dashed argv:\[git-yyy\]" actual && # We unpeel that and substitute "version" into "xxx" (giving # "git version") and update the cmd_name event. - grep "d0|main|alias|.*|alias:yyy argv:\[version\]" actual && - grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_dashed_/_run_git_alias_)" actual && + test_grep "d0|main|alias|.*|alias:yyy argv:\[version\]" actual && + test_grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_dashed_/_run_git_alias_)" actual && # These def_param events could be associated with any of the # above cmd_name events. It does not matter. grep "d0|main|def_param|.*|cfg.prop.foo:red" actual >actual.matches && - grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + test_grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && # However, we do not want them repeated each time we unpeel. test_line_count = 1 actual.matches && # The "git version" child sees a different cmd_name hierarchy. # Also test the def_param (only for completeness). - grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_dashed_/_run_git_alias_/version)" actual && - grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && - grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual + test_grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_dashed_/_run_git_alias_/version)" actual && + test_grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + test_grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' test_done diff --git a/t/t0212-trace2-event.sh b/t/t0212-trace2-event.sh index 1211db9f468717..f5358a1dd44991 100755 --- a/t/t0212-trace2-event.sh +++ b/t/t0212-trace2-event.sh @@ -332,7 +332,7 @@ test_expect_success 'unsafe URLs are redacted by default in cmd_start events' ' GIT_TRACE2_EVENT="$(pwd)/trace.event" \ test-tool trace2 300redact_start git clone https://user:pwd@example.com/ clone2 && - ! grep user:pwd trace.event + test_grep ! user:pwd trace.event ' test_expect_success 'unsafe URLs are redacted by default in child_start events' ' @@ -341,7 +341,7 @@ test_expect_success 'unsafe URLs are redacted by default in child_start events' GIT_TRACE2_EVENT="$(pwd)/trace.event" \ test-tool trace2 301redact_child_start git clone https://user:pwd@example.com/ clone2 && - ! grep user:pwd trace.event + test_grep ! user:pwd trace.event ' test_expect_success 'unsafe URLs are redacted by default in exec events' ' @@ -350,7 +350,7 @@ test_expect_success 'unsafe URLs are redacted by default in exec events' ' GIT_TRACE2_EVENT="$(pwd)/trace.event" \ test-tool trace2 302redact_exec git clone https://user:pwd@example.com/ clone2 && - ! grep user:pwd trace.event + test_grep ! user:pwd trace.event ' test_expect_success 'unsafe URLs are redacted by default in def_param events' ' @@ -359,7 +359,7 @@ test_expect_success 'unsafe URLs are redacted by default in def_param events' ' GIT_TRACE2_EVENT="$(pwd)/trace.event" \ test-tool trace2 303redact_def_param url https://user:pwd@example.com/ && - ! grep user:pwd trace.event + test_grep ! user:pwd trace.event ' test_done diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh index 64ead1571ae1e1..ea11cdb4dcd251 100755 --- a/t/t0300-credentials.sh +++ b/t/t0300-credentials.sh @@ -1014,7 +1014,7 @@ test_expect_success 'credential config with partial URLs' ' do git -c credential.$partial.helper=yep \ credential fill stdout && - grep yep stdout || + test_grep yep stdout || return 1 done && @@ -1030,7 +1030,7 @@ test_expect_success 'credential config with partial URLs' ' do git -c credential.$partial.helper=yep \ credential fill stdout && - ! grep yep stdout || + test_grep ! yep stdout || return 1 done && diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index 52e19728a3fca0..afa890c470b782 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -206,7 +206,7 @@ test_expect_success 'fetching of missing objects' ' git -C repo cat-file -p "$HASH" 2>err && # Ensure that no spurious FETCH_HEAD messages are written - ! grep FETCH_HEAD err && + test_grep ! FETCH_HEAD err && # Ensure that the .promisor file is written, and check that its # associated packfile contains the object @@ -214,7 +214,7 @@ test_expect_success 'fetching of missing objects' ' test_line_count = 1 promisorlist && IDX=$(sed "s/promisor$/idx/" promisorlist) && git verify-pack --verbose "$IDX" >out && - grep "$HASH" out + test_grep "$HASH" out ' test_expect_success 'fetching of a promised object that promisor remote no longer has' ' @@ -228,7 +228,7 @@ test_expect_success 'fetching of a promised object that promisor remote no longe rm -rf unreliable-server/.git/objects/* && test_must_fail git -C unreliable-client checkout HEAD 2>err && - grep "could not fetch.*from promisor remote" err + test_grep "could not fetch.*from promisor remote" err ' test_expect_success 'fetching of missing objects works with ref-in-want enabled' ' @@ -240,7 +240,7 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled' rm -rf repo/.git/objects/* && rm -f trace && GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" && - grep "fetch< fetch=.*ref-in-want" trace + test_grep "fetch< fetch=.*ref-in-want" trace ' test_expect_success 'fetching from another promisor remote' ' @@ -263,7 +263,7 @@ test_expect_success 'fetching from another promisor remote' ' test_line_count = 1 promisorlist && IDX=$(sed "s/promisor$/idx/" promisorlist) && git verify-pack --verbose "$IDX" >out && - grep "$HASH2" out + test_grep "$HASH2" out ' test_expect_success 'fetching with --filter configures a promisor remote' ' @@ -286,7 +286,7 @@ test_expect_success 'fetching with --filter configures a promisor remote' ' test_line_count = 1 promisorlist && IDX=$(sed "s/promisor$/idx/" promisorlist) && git verify-pack --verbose "$IDX" >out && - grep "$HASH3" out + test_grep "$HASH3" out ' test_expect_success 'fetching of missing blobs works' ' @@ -327,8 +327,8 @@ test_expect_success 'fetching of missing trees does not fetch blobs' ' # Ensure that the tree, but not the blob, is fetched git -C repo rev-list --objects --missing=print $(cat treehash) >objects && - grep "^$(cat treehash)" objects && - grep "^[?]$(cat blobhash)" objects + test_grep "^$(cat treehash)" objects && + test_grep "^[?]$(cat blobhash)" objects ' test_expect_success 'rev-list stops traversal at missing and promised commit' ' @@ -343,8 +343,8 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects bar >out && - grep $(git -C repo rev-parse bar) out && - ! grep $FOO out + test_grep $(git -C repo rev-parse bar) out && + test_grep ! $FOO out ' test_expect_success 'missing tree objects with --missing=allow-promisor and --exclude-promisor-objects' ' @@ -413,10 +413,10 @@ test_expect_success 'rev-list stops traversal at missing and promised tree' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects HEAD >out && - grep $(git -C repo rev-parse foo) out && - ! grep $TREE out && - grep $(git -C repo rev-parse HEAD) out && - ! grep $TREE2 out + test_grep $(git -C repo rev-parse foo) out && + test_grep ! $TREE out && + test_grep $(git -C repo rev-parse HEAD) out && + test_grep ! $TREE2 out ' test_expect_success 'rev-list stops traversal at missing and promised blob' ' @@ -432,8 +432,8 @@ test_expect_success 'rev-list stops traversal at missing and promised blob' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects HEAD >out && - grep $(git -C repo rev-parse HEAD) out && - ! grep $BLOB out + test_grep $(git -C repo rev-parse HEAD) out && + test_grep ! $BLOB out ' test_expect_success 'rev-list stops traversal at promisor commit, tree, and blob' ' @@ -451,10 +451,10 @@ test_expect_success 'rev-list stops traversal at promisor commit, tree, and blob git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && git -C repo rev-list --exclude-promisor-objects --objects HEAD >out && - ! grep $COMMIT out && - ! grep $TREE out && - ! grep $BLOB out && - grep $(git -C repo rev-parse bar) out # sanity check that some walking was done + test_grep ! $COMMIT out && + test_grep ! $TREE out && + test_grep ! $BLOB out && + test_grep $(git -C repo rev-parse bar) out # sanity check that some walking was done ' test_expect_success 'rev-list dies for missing objects on cmd line' ' @@ -523,10 +523,10 @@ test_expect_success 'gc repacks promisor objects separately from non-promisor ob test_line_count = 1 promisorlist && PROMISOR_PACKFILE=$(sed "s/.promisor/.pack/" out && - grep "$TREE_ONE" out && - grep "$TREE_TWO" out && - ! grep "$(git -C repo rev-parse one)" out && - ! grep "$(git -C repo rev-parse two)" out && + test_grep "$TREE_ONE" out && + test_grep "$TREE_TWO" out && + test_grep ! "$(git -C repo rev-parse one)" out && + test_grep ! "$(git -C repo rev-parse two)" out && # Remove the promisor packfile and associated files rm $(sed "s/.promisor//" packlist && test_line_count = 1 packlist && git verify-pack repo/.git/objects/pack/pack-*.pack -v >out && - grep "$(git -C repo rev-parse one)" out && - grep "$(git -C repo rev-parse two)" out && - ! grep "$TREE_ONE" out && - ! grep "$TREE_TWO" out + test_grep "$(git -C repo rev-parse one)" out && + test_grep "$(git -C repo rev-parse two)" out && + test_grep ! "$TREE_ONE" out && + test_grep ! "$TREE_TWO" out ' test_expect_success 'gc does not repack promisor objects if there are none' ' @@ -616,8 +616,8 @@ test_expect_success 'gc stops traversal when a missing but promised object is re ls repo/.git/objects/pack/pack-*.pack >packlist && test_line_count = 1 packlist && git verify-pack repo/.git/objects/pack/pack-*.pack -v >out && - grep "$(git -C repo rev-parse HEAD)" out && - ! grep "$TREE_HASH" out + test_grep "$(git -C repo rev-parse HEAD)" out && + test_grep ! "$TREE_HASH" out ' test_expect_success 'do not fetch when checking existence of tree we construct ourselves' ' @@ -647,10 +647,10 @@ test_expect_success 'exact rename does not need to fetch the blob lazily' ' git clone --filter=blob:none --bare "file://$(pwd)/repo" partial.git && git -C partial.git rev-list --objects --missing=print HEAD >out && - grep "[?]$FILE_HASH" out && + test_grep "[?]$FILE_HASH" out && git -C partial.git log --follow -- new-file.txt && git -C partial.git rev-list --objects --missing=print HEAD >out && - grep "[?]$FILE_HASH" out + test_grep "[?]$FILE_HASH" out ' test_expect_success 'lazy-fetch when accessing object not in the_repository' ' @@ -665,7 +665,7 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' ' # Sanity check that the file is missing git -C partial.git rev-list --objects --missing=print HEAD >out && - grep "[?]$FILE_HASH" out && + test_grep "[?]$FILE_HASH" out && # The no-lazy-fetch mechanism prevents Git from fetching test_must_fail env GIT_NO_LAZY_FETCH=1 \ @@ -680,7 +680,7 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' ' # Sanity check that the file is still missing git -C partial.git rev-list --objects --missing=print HEAD >out && - grep "[?]$FILE_HASH" out && + test_grep "[?]$FILE_HASH" out && git -C full cat-file -s "$FILE_HASH" >expect && test-tool partial-clone object-info partial.git "$FILE_HASH" >actual && @@ -688,7 +688,7 @@ test_expect_success 'lazy-fetch when accessing object not in the_repository' ' # Sanity check that the file is now present git -C partial.git rev-list --objects --missing=print HEAD >out && - ! grep "[?]$FILE_HASH" out + test_grep ! "[?]$FILE_HASH" out ' test_expect_success 'push should not fetch new commit objects' ' @@ -705,9 +705,9 @@ test_expect_success 'push should not fetch new commit objects' ' COMMIT=$(git -C server rev-parse server2) && test_must_fail git -C client push 2>err && - grep "fetch first" err && + test_grep "fetch first" err && git -C client rev-list --objects --missing=print "$COMMIT" >objects && - grep "^[?]$COMMIT" objects + test_grep "^[?]$COMMIT" objects ' test_expect_success 'setup for promisor.quiet tests' ' @@ -728,7 +728,7 @@ test_expect_success TTY 'promisor.quiet=false shows progress messages' ' test_terminal git -C repo cat-file -p foo:foo.t 2>err && # Ensure that progress messages are written - grep "Receiving objects" err + test_grep "Receiving objects" err ' test_expect_success TTY 'promisor.quiet=true does not show progress messages' ' @@ -739,7 +739,7 @@ test_expect_success TTY 'promisor.quiet=true does not show progress messages' ' test_terminal git -C repo cat-file -p foo:foo.t 2>err && # Ensure that no progress messages are written - ! grep "Receiving objects" err + test_grep ! "Receiving objects" err ' test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' ' @@ -749,7 +749,7 @@ test_expect_success TTY 'promisor.quiet=unconfigured shows progress messages' ' test_terminal git -C repo cat-file -p foo:foo.t 2>err && # Ensure that progress messages are written - grep "Receiving objects" err + test_grep "Receiving objects" err ' . "$TEST_DIRECTORY"/lib-httpd.sh @@ -776,7 +776,7 @@ test_expect_success 'fetching of missing objects from an HTTP server' ' test_line_count = 1 promisorlist && IDX=$(sed "s/promisor$/idx/" promisorlist) && git verify-pack --verbose "$IDX" >out && - grep "$HASH" out + test_grep "$HASH" out ' # DO NOT add non-httpd-specific tests here, because the last part of this diff --git a/t/t0450-txt-doc-vs-help.sh b/t/t0450-txt-doc-vs-help.sh index 822b0d55a50ae7..401a6f30ba76a8 100755 --- a/t/t0450-txt-doc-vs-help.sh +++ b/t/t0450-txt-doc-vs-help.sh @@ -68,7 +68,7 @@ adoc_to_synopsis () { } check_dashed_labels () { - ! grep -E "<[^>_-]+_" "$1" + test_grep ! -E "<[^>_-]+_" "$1" } HT=" " @@ -87,7 +87,7 @@ do # -h output assertions test_expect_success "$builtin -h output has no \t" ' h2s="$(help_to_synopsis "$builtin")" && - ! grep "$HT" "$h2s" + test_grep ! "$HT" "$h2s" ' test_expect_success "$builtin -h output has dashed labels" ' diff --git a/t/t0500-progress-display.sh b/t/t0500-progress-display.sh index d1a498a216fb52..fe2232cce0e8ef 100755 --- a/t/t0500-progress-display.sh +++ b/t/t0500-progress-display.sh @@ -320,8 +320,8 @@ test_expect_success 'progress generates traces' ' # t0212/parse_events.perl intentionally omits regions and data. test_region progress "Working hard" trace.event && - grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event && - grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event + test_grep "\"key\":\"total_objects\",\"value\":\"40\"" trace.event && + test_grep "\"key\":\"total_bytes\",\"value\":\"409600\"" trace.event ' test_expect_success 'progress generates traces: stop / start' ' @@ -344,8 +344,8 @@ test_expect_success 'progress generates traces: start without stop' ' LSAN_OPTIONS=detect_leaks=0 \ test-tool progress \ stderr && - grep region_enter.*progress trace-start.event && - ! grep region_leave.*progress trace-start.event + test_grep region_enter.*progress trace-start.event && + test_grep ! region_leave.*progress trace-start.event ' test_expect_success 'progress generates traces: stop without start' ' @@ -355,8 +355,8 @@ test_expect_success 'progress generates traces: stop without start' ' GIT_TRACE2_EVENT="$PWD/trace-stop.event" test-tool progress \ stderr && - ! grep region_enter.*progress trace-stop.event && - ! grep region_leave.*progress trace-stop.event + test_grep ! region_enter.*progress trace-stop.event && + test_grep ! region_leave.*progress trace-stop.event ' test_expect_success 'progress generates traces: start with active progress bar (no stops)' ' @@ -369,9 +369,9 @@ test_expect_success 'progress generates traces: start with active progress bar ( LSAN_OPTIONS=detect_leaks=0 \ test-tool progress \ stderr && - grep region_enter.*progress.*One trace-2start.event && - grep region_enter.*progress.*Two trace-2start.event && - ! grep region_leave trace-2start.event + test_grep region_enter.*progress.*One trace-2start.event && + test_grep region_enter.*progress.*Two trace-2start.event && + test_grep ! region_leave trace-2start.event ' test_done diff --git a/t/t0610-reftable-basics.sh b/t/t0610-reftable-basics.sh index e19e0368989d50..2f4c5e2a1b9c39 100755 --- a/t/t0610-reftable-basics.sh +++ b/t/t0610-reftable-basics.sh @@ -776,11 +776,11 @@ test_expect_success 'reflog: can delete separate reflog entries' ' test_commit file3 && test_commit file4 && git reflog >actual && - grep file3 actual && + test_grep file3 actual && git reflog delete HEAD@{1} && git reflog >actual && - ! grep file3 actual + test_grep ! file3 actual ) ' @@ -902,8 +902,8 @@ test_expect_success 'reflog: garbage collection deletes reflog entries' ' done && git reflog refs/heads/main >actual && test_line_count = 10 actual && - grep "commit (initial): number 1" actual && - grep "commit: number 10" actual && + test_grep "commit (initial): number 1" actual && + test_grep "commit: number 10" actual && git gc && git reflog refs/heads/main >actual && diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh index 11bf10424f1620..70ba3eea4d4b63 100755 --- a/t/t1004-read-tree-m-u-wf.sh +++ b/t/t1004-read-tree-m-u-wf.sh @@ -142,8 +142,8 @@ test_expect_success '3-way not overwriting local changes (our side)' ' echo >>file1 "local changes" && read_tree_u_must_succeed -m -u branch-point side-a side-b && - grep "new line to be kept" file1 && - grep "local changes" file1 + test_grep "new line to be kept" file1 && + test_grep "local changes" file1 ' @@ -156,8 +156,8 @@ test_expect_success '3-way not overwriting local changes (their side)' ' echo >>file2 "local changes" && read_tree_u_must_fail -m -u branch-point side-a side-b && - ! grep "new line to be kept" file2 && - grep "local changes" file2 + test_grep ! "new line to be kept" file2 && + test_grep "local changes" file2 ' diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 8e2c52652c5185..e0884c49417090 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -7,7 +7,7 @@ test_description='git cat-file' test_cmdmode_usage () { test_expect_code 129 "$@" 2>err && - grep "^error: .* cannot be used together" err + test_grep "^error: .* cannot be used together" err } for switches in \ @@ -25,7 +25,7 @@ done test_incompatible_usage () { test_expect_code 129 "$@" 2>err && - grep -E "^(fatal|error):.*(requires|incompatible with|needs)" err + test_grep -E "^(fatal|error):.*(requires|incompatible with|needs)" err } for opt in --batch --batch-check @@ -37,7 +37,7 @@ done test_missing_usage () { test_expect_code 129 "$@" 2>err && - grep -E "^fatal:.*required" err + test_grep -E "^fatal:.*required" err } short_modes="-e -p -t -s" @@ -69,7 +69,7 @@ done test_too_many_arguments () { test_expect_code 129 "$@" 2>err && - grep -E "^fatal: too many arguments$" err + test_grep -E "^fatal: too many arguments$" err } for opt in $short_modes $cw_modes @@ -696,7 +696,7 @@ test_expect_success '%(deltabase) reports packed delta bases' ' git repack -ad && git cat-file --batch-check="%(deltabase)" actual && { - grep "$(git rev-parse HEAD:foo)" actual || + test_grep "$(git rev-parse HEAD:foo)" actual || grep "$(git rev-parse HEAD:foo-plus)" actual } ' @@ -826,7 +826,7 @@ test_expect_success 'cat-file -t and -s on corrupt loose object' ' # Swap the two to corrupt the repository mv -f "$other_path" "$empty_path" && test_must_fail git fsck 2>err.fsck && - grep "hash-path mismatch" err.fsck && + test_grep "hash-path mismatch" err.fsck && # confirm that cat-file is reading the new swapped-in # blob... @@ -1318,37 +1318,37 @@ test_expect_success 'cat-file --batch-all-objects --batch-check ignores replace' test_expect_success 'batch-command empty command' ' echo "" >cmd && test_expect_code 128 git cat-file --batch-command err && - grep "^fatal:.*empty command in input.*" err + test_grep "^fatal:.*empty command in input.*" err ' test_expect_success 'batch-command whitespace before command' ' echo " info deadbeef" >cmd && test_expect_code 128 git cat-file --batch-command err && - grep "^fatal:.*whitespace before command.*" err + test_grep "^fatal:.*whitespace before command.*" err ' test_expect_success 'batch-command unknown command' ' echo unknown_command >cmd && test_expect_code 128 git cat-file --batch-command err && - grep "^fatal:.*unknown command.*" err + test_grep "^fatal:.*unknown command.*" err ' test_expect_success 'batch-command missing arguments' ' echo "info" >cmd && test_expect_code 128 git cat-file --batch-command err && - grep "^fatal:.*info requires arguments.*" err + test_grep "^fatal:.*info requires arguments.*" err ' test_expect_success 'batch-command flush with arguments' ' echo "flush arg" >cmd && test_expect_code 128 git cat-file --batch-command --buffer err && - grep "^fatal:.*flush takes no arguments.*" err + test_grep "^fatal:.*flush takes no arguments.*" err ' test_expect_success 'batch-command flush without --buffer' ' echo "flush" >cmd && test_expect_code 128 git cat-file --batch-command err && - grep "^fatal:.*flush is only for --buffer mode.*" err + test_grep "^fatal:.*flush is only for --buffer mode.*" err ' perl_script=' diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index de076293b62a76..4782a6246afc00 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -202,7 +202,7 @@ done test_expect_success 'too-short tree' ' echo abc >malformed-tree && test_must_fail git hash-object -t tree malformed-tree 2>err && - grep "too-short tree object" err + test_grep "too-short tree object" err ' test_expect_success PERL_TEST_HELPERS 'malformed mode in tree' ' @@ -210,7 +210,7 @@ test_expect_success PERL_TEST_HELPERS 'malformed mode in tree' ' bin_oid=$(echo $hex_oid | hex2oct) && printf "9100644 \0$bin_oid" >tree-with-malformed-mode && test_must_fail git hash-object -t tree tree-with-malformed-mode 2>err && - grep "malformed mode in tree entry" err + test_grep "malformed mode in tree entry" err ' test_expect_success PERL_TEST_HELPERS 'empty filename in tree' ' @@ -218,7 +218,7 @@ test_expect_success PERL_TEST_HELPERS 'empty filename in tree' ' bin_oid=$(echo $hex_oid | hex2oct) && printf "100644 \0$bin_oid" >tree-with-empty-filename && test_must_fail git hash-object -t tree tree-with-empty-filename 2>err && - grep "empty filename in tree entry" err + test_grep "empty filename in tree entry" err ' test_expect_success PERL_TEST_HELPERS 'duplicate filename in tree' ' @@ -229,7 +229,7 @@ test_expect_success PERL_TEST_HELPERS 'duplicate filename in tree' ' printf "100644 file\0$bin_oid" } >tree-with-duplicate-filename && test_must_fail git hash-object -t tree tree-with-duplicate-filename 2>err && - grep "duplicateEntries" err + test_grep "duplicateEntries" err ' test_expect_success 'corrupt commit' ' diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index 742f0fa909fd6e..93244ee1344f49 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -196,7 +196,7 @@ test_expect_success 'read-tree will not throw away dirty changes, non-sparse' ' echo dirty >init.t && read_tree_u_must_fail -m -u HEAD^ && test_path_is_file init.t && - grep -q dirty init.t + test_grep -q dirty init.t ' test_expect_success 'read-tree will not throw away dirty changes, sparse' ' @@ -207,7 +207,7 @@ test_expect_success 'read-tree will not throw away dirty changes, sparse' ' echo sub/added >.git/info/sparse-checkout && read_tree_u_must_fail -m -u HEAD^ && test_path_is_file init.t && - grep -q dirty init.t + test_grep -q dirty init.t ' test_expect_success 'read-tree updates worktree, dirty case' ' @@ -215,7 +215,7 @@ test_expect_success 'read-tree updates worktree, dirty case' ' git checkout -f top && echo dirty >init.t && read_tree_u_must_fail -m -u HEAD^ && - grep -q dirty init.t && + test_grep -q dirty init.t && rm init.t ' @@ -224,7 +224,7 @@ test_expect_success 'read-tree removes worktree, dirty case' ' git checkout -f top && echo dirty >added && read_tree_u_must_succeed -m -u HEAD^ && - grep -q dirty added + test_grep -q dirty added ' test_expect_success 'read-tree adds to worktree, absent case' ' @@ -240,7 +240,7 @@ test_expect_success 'read-tree adds to worktree, dirty case' ' mkdir sub && echo dirty >sub/added && read_tree_u_must_succeed -u -m HEAD^ && - grep -q dirty sub/added + test_grep -q dirty sub/added ' test_expect_success 'index removal and worktree narrowing at the same time' ' diff --git a/t/t1050-large.sh b/t/t1050-large.sh index 7d40d0852166b5..d295c265c75c0e 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -8,7 +8,7 @@ test_description='adding and checking out large blobs' test_expect_success 'core.bigFileThreshold must be non-negative' ' : >input && test_must_fail git -c core.bigFileThreshold=-1 hash-object input >out 2>err && - grep "bad numeric config value" err && + test_grep "bad numeric config value" err && test_must_be_empty out ' @@ -148,12 +148,12 @@ test_expect_success 'diff --stat' ' test_expect_success 'diff' ' git diff HEAD^ HEAD >actual && - grep "Binary files.*differ" actual + test_grep "Binary files.*differ" actual ' test_expect_success 'diff --cached' ' git diff --cached HEAD^ >actual && - grep "Binary files.*differ" actual + test_grep "Binary files.*differ" actual ' test_expect_success 'hash-object' ' diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index cd0aed9975fe24..74b1761e0c8507 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -129,7 +129,7 @@ test_expect_success 'switching to cone mode with non-cone mode patterns' ' git sparse-checkout add dir && git config --worktree core.sparseCheckoutCone true && test_must_fail git sparse-checkout add dir 2>err && - grep "existing sparse-checkout patterns do not use cone mode" err + test_grep "existing sparse-checkout patterns do not use cone mode" err ) ' @@ -803,7 +803,7 @@ test_expect_success 'cone mode clears ignored subdirectories' ' # When an untracked file is in the way, all untracked files # (even ignored files) are preserved. git -C repo sparse-checkout set folder1 2>err && - grep "contains untracked files" err && + test_grep "contains untracked files" err && test_path_is_file repo/deep/deeper2/ignored.o && test_path_is_file repo/deep/deeper2/untracked && @@ -882,8 +882,8 @@ test_expect_success 'malformed cone-mode patterns' ' # of using the cone-mode translation to a set of directories. git -C repo sparse-checkout list >actual 2>err && test_cmp repo/.git/info/sparse-checkout actual && - grep "warning: your sparse-checkout file may have issues: pattern .* is repeated" err && - grep "warning: disabling cone pattern matching" err + test_grep "warning: your sparse-checkout file may have issues: pattern .* is repeated" err && + test_grep "warning: disabling cone pattern matching" err ' test_expect_success 'set from subdir pays attention to prefix' ' @@ -917,34 +917,34 @@ test_expect_success 'set from subdir in non-cone mode throws an error' ' git -C repo sparse-checkout disable && test_must_fail git -C repo/deep sparse-checkout set --no-cone deeper2 ../folder1 2>error && - grep "run from the toplevel directory in non-cone mode" error + test_grep "run from the toplevel directory in non-cone mode" error ' test_expect_success 'set from subdir in non-cone mode throws an error' ' git -C repo sparse-checkout set --no-cone deep/deeper2 && test_must_fail git -C repo/deep sparse-checkout add deeper1/deepest ../folder1 2>error && - grep "run from the toplevel directory in non-cone mode" error + test_grep "run from the toplevel directory in non-cone mode" error ' test_expect_success 'by default, cone mode will error out when passed files' ' git -C repo sparse-checkout reapply --cone && test_must_fail git -C repo sparse-checkout add .gitignore 2>error && - grep ".gitignore.*is not a directory" error + test_grep ".gitignore.*is not a directory" error ' test_expect_success 'error on mistyped command line options' ' test_must_fail git -C repo sparse-checkout add --sikp-checks .gitignore 2>error && - grep "unknown option.*sikp-checks" error + test_grep "unknown option.*sikp-checks" error ' test_expect_success 'by default, non-cone mode will warn on individual files' ' git -C repo sparse-checkout reapply --no-cone && git -C repo sparse-checkout add .gitignore 2>warning && - grep "pass a leading slash before paths.*if you want a single file" warning + test_grep "pass a leading slash before paths.*if you want a single file" warning ' test_expect_success 'setup bare repo' ' @@ -1108,11 +1108,11 @@ test_expect_success 'clean' ' touch repo/folder1/extra/inside/file && test_must_fail git -C repo sparse-checkout clean 2>err && - grep "refusing to clean" err && + test_grep "refusing to clean" err && git -C repo config clean.requireForce true && test_must_fail git -C repo sparse-checkout clean 2>err && - grep "refusing to clean" err && + test_grep "refusing to clean" err && cat >expect <<-\EOF && Would remove deep/deeper2/ @@ -1255,7 +1255,7 @@ test_expect_success 'sparse-checkout operations with merge conflicts' ' test_must_fail git merge -m "will-conflict" right && test_must_fail git sparse-checkout clean -f 2>err && - grep "failed to convert index to a sparse index" err && + test_grep "failed to convert index to a sparse index" err && echo merged >folder1/even/more/dirs/file && git add --sparse folder1 && diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index d98cb4ac113c67..b6d67ada5f9fdc 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -173,9 +173,9 @@ init_repos_as_submodules () { git submodule add ./sparse-index && git submodule status >actual && - grep full-checkout actual && - grep sparse-checkout actual && - grep sparse-index actual + test_grep full-checkout actual && + test_grep sparse-checkout actual && + test_grep sparse-index actual } run_on_sparse () { @@ -240,7 +240,7 @@ test_sparse_checkout_set () { for dir in $SPARSE_DIRS do TREE=$(git -C sparse-index rev-parse HEAD:$dir) && - grep "040000 $TREE 0 $dir/" cache \ + test_grep "040000 $TREE 0 $dir/" cache \ || return 1 done && @@ -454,10 +454,10 @@ test_expect_success 'add outside sparse cone' ' run_on_sparse ../edit-contents folder1/a && run_on_sparse ../edit-contents folder1/newfile && test_sparse_match test_must_fail git add folder1/a && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/a && test_sparse_match test_must_fail git add folder1/newfile && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/newfile ' @@ -509,13 +509,13 @@ test_expect_success 'status/add: outside sparse cone' ' # Adding the path outside of the sparse-checkout cone should fail. test_sparse_match test_must_fail git add folder1/a && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/a && test_all_match git add --refresh folder1/a && test_must_be_empty sparse-checkout-err && test_sparse_unstaged folder1/a && test_sparse_match test_must_fail git add folder1/new && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/new && test_sparse_match git add --sparse folder1/a && test_sparse_match git add --sparse folder1/new && @@ -661,8 +661,8 @@ test_expect_success 'checkout and reset (mixed)' ' # in sparse-checkout or sparse-index. git -C full-checkout reset update-folder1 >full-checkout-out && test_sparse_match git reset update-folder1 && - grep "M folder1/a" full-checkout-out && - ! grep "M folder1/a" sparse-checkout-out && + test_grep "M folder1/a" full-checkout-out && + test_grep ! "M folder1/a" sparse-checkout-out && run_on_sparse test_path_is_missing folder1 ' @@ -880,8 +880,8 @@ test_expect_success 'update-index with directories' ' # update-index will exit silently when provided with a directory name # containing a trailing slash test_all_match git update-index deep/ folder1/ && - grep "Ignoring path deep/" sparse-checkout-err && - grep "Ignoring path folder1/" sparse-checkout-err && + test_grep "Ignoring path deep/" sparse-checkout-err && + test_grep "Ignoring path folder1/" sparse-checkout-err && # When update-index is given a directory name WITHOUT a trailing slash, it will # behave in different ways depending on the status of the directory on disk: @@ -1067,7 +1067,7 @@ test_expect_success 'merge with conflict outside cone' ' # 2. Add the file with conflict markers test_sparse_match test_must_fail git add folder1/a && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/a && test_all_match git add --sparse folder1/a && test_all_match git status --porcelain=v2 && @@ -1076,7 +1076,7 @@ test_expect_success 'merge with conflict outside cone' ' # accept conflict markers as resolved content. run_on_all mv folder2/a folder2/z && test_sparse_match test_must_fail git add folder2 && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder2/z && test_all_match git add --sparse folder2 && test_all_match git status --porcelain=v2 && @@ -1107,7 +1107,7 @@ test_expect_success 'cherry-pick/rebase with conflict outside cone' ' # SKIP_WORKTREE bit from the index entry for folder1/a, we should # warn that this is a problematic add. test_sparse_match test_must_fail git add folder1/a && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder1/a && test_all_match git add --sparse folder1/a && test_all_match git status --porcelain=v2 && @@ -1119,7 +1119,7 @@ test_expect_success 'cherry-pick/rebase with conflict outside cone' ' # existing index entry with the SKIP_WORKTREE bit cleared. run_on_all mv folder2/a folder2/z && test_sparse_match test_must_fail git add folder2 && - grep "Disable or modify the sparsity rules" sparse-checkout-err && + test_grep "Disable or modify the sparsity rules" sparse-checkout-err && test_sparse_unstaged folder2/z && test_all_match git add --sparse folder2 && test_all_match git status --porcelain=v2 && @@ -1266,7 +1266,7 @@ test_expect_success 'checkout-index with folders' ' run_on_all test_must_fail git checkout-index -f -- folder1/ && test_cmp full-checkout-err sparse-checkout-err && ! test_cmp full-checkout-err sparse-index-err && - grep "is a sparse directory" sparse-index-err + test_grep "is a sparse directory" sparse-index-err ' test_expect_success 'checkout-index --all' ' @@ -1374,8 +1374,8 @@ test_expect_success 'submodule handling' ' # having a submodule prevents "modules" from collapse test_sparse_match git sparse-checkout set deep/deeper1 && git -C sparse-index ls-files --sparse --stage >cache && - grep "100644 .* modules/a" cache && - grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache + test_grep "100644 .* modules/a" cache && + test_grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache ' test_expect_success 'git apply functionality' ' @@ -1392,7 +1392,7 @@ test_expect_success 'git apply functionality' ' # Apply a patch to a file outside the sparse definition test_sparse_match test_must_fail git apply ../patch-outside && - grep "No such file or directory" sparse-checkout-err && + test_grep "No such file or directory" sparse-checkout-err && # But it works with --index and --cached test_all_match git apply --index --stat ../patch-outside && @@ -2013,9 +2013,9 @@ test_expect_success 'mv directory from out-of-cone to in-cone' ' test_all_match git status --porcelain=v2 && test_sparse_match git ls-files -t && git -C sparse-checkout ls-files -t >actual && - grep -e "H deep/folder1/0/0/0" actual && - grep -e "H deep/folder1/0/1" actual && - grep -e "H deep/folder1/a" actual && + test_grep -e "H deep/folder1/0/0/0" actual && + test_grep -e "H deep/folder1/0/1" actual && + test_grep -e "H deep/folder1/a" actual && test_all_match git reset --hard && @@ -2025,8 +2025,8 @@ test_expect_success 'mv directory from out-of-cone to in-cone' ' test_sparse_match git status --porcelain=v2 && test_sparse_match git ls-files -t && git -C sparse-checkout ls-files -t >actual && - grep -e "H deep/0/0/0" actual && - grep -e "H deep/0/1" actual + test_grep -e "H deep/0/0/0" actual && + test_grep -e "H deep/0/1" actual ' test_expect_success 'rm pathspec inside sparse definition' ' @@ -2129,20 +2129,20 @@ test_expect_success 'grep with and --cached' ' test_expect_success 'grep is not expanded' ' init_repos && - ensure_not_expanded grep a && - ensure_not_expanded grep a -- deep/* && + ensure_not_expanded test_grep a && + ensure_not_expanded test_grep a -- deep/* && # All files within the folder1/* pathspec are sparse, # so this command does not find any matches - ensure_not_expanded ! grep a -- folder1/* && + ensure_not_expanded test_grep ! a -- folder1/* && # test out-of-cone pathspec with or without wildcard - ensure_not_expanded grep --cached a -- "folder1/a" && - ensure_not_expanded grep --cached a -- "folder1/*" && + ensure_not_expanded test_grep --cached a -- "folder1/a" && + ensure_not_expanded test_grep --cached a -- "folder1/*" && # test in-cone pathspec with or without wildcard - ensure_not_expanded grep --cached a -- "deep/a" && - ensure_not_expanded grep --cached a -- "deep/*" + ensure_not_expanded test_grep --cached a -- "deep/a" && + ensure_not_expanded test_grep --cached a -- "deep/*" ' # NEEDSWORK: when running `grep` in the superproject with --recurse-submodules, @@ -2517,7 +2517,7 @@ test_expect_success 'advice.sparseIndexExpanded' ' mkdir -p sparse-index/deep/deeper2/deepest && touch sparse-index/deep/deeper2/deepest/bogus && git -C sparse-index status 2>err && - grep "The sparse index is expanding to a full index" err && + test_grep "The sparse index is expanding to a full index" err && git -C sparse-index sparse-checkout disable 2>err && test_line_count = 0 err diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 11fc976f3ab271..b337e25d92deb5 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -800,7 +800,7 @@ test_expect_success 'renaming a section with an overly-long line' ' printf "[a] g = h\\n" } >y && test_must_fail git config ${mode_prefix}rename-section -f y a xyz 2>err && - grep "refusing to work with overly long line in .y. on line 2" err + test_grep "refusing to work with overly long line in .y. on line 2" err ' cat >> .git/config << EOF @@ -1615,9 +1615,9 @@ test_expect_success 'git --config-env=key=envvar support' ' test_expect_success 'git --config-env with missing value' ' test_must_fail env ENVVAR=value git --config-env 2>error && - grep "no config key given for --config-env" error && + test_grep "no config key given for --config-env" error && test_must_fail env ENVVAR=value git --config-env config core.name 2>error && - grep "invalid config format: config" error + test_grep "invalid config format: config" error ' test_expect_success 'git --config-env fails with invalid parameters' ' @@ -2048,7 +2048,7 @@ test_expect_success '--unset last key removes section (except if commented)' ' key = true EOF git config ${mode_unset} two.key && - ! grep two .git/config && + test_grep ! two .git/config && q_to_tab >.git/config <<-\EOF && [one] @@ -2068,7 +2068,7 @@ test_expect_success '--unset last key removes section (except if commented)' ' Qkey = true EOF git config ${mode_unset} two.key && - grep two .git/config && + test_grep two .git/config && q_to_tab >.git/config <<-\EOF && [one] @@ -2599,7 +2599,7 @@ test_expect_success '--type rejects unknown specifiers' ' test_expect_success '--type=int requires at least one digit' ' test_must_fail git config --type int --default m some.key >out 2>error && - grep "bad numeric config value" error && + test_grep "bad numeric config value" error && test_must_be_empty out ' @@ -2911,12 +2911,12 @@ test_expect_success 'includeIf.hasconfig:remote.*.url forbids remote url in such # test with any Git command test_must_fail git -C hasremoteurlTest status 2>err && - grep "fatal: remote URLs cannot be configured in file directly or indirectly included by includeIf.hasconfig:remote.*.url" err + test_grep "fatal: remote URLs cannot be configured in file directly or indirectly included by includeIf.hasconfig:remote.*.url" err ' test_expect_success 'negated mode causes failure' ' test_must_fail git config --no-get 2>err && - grep "unknown option \`no-get${SQ}" err + test_grep "unknown option \`no-get${SQ}" err ' test_expect_success 'specifying multiple modes causes failure' ' diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh index c69ae41306c90d..bffb043721cf62 100755 --- a/t/t1304-default-acl.sh +++ b/t/t1304-default-acl.sh @@ -32,10 +32,10 @@ fi check_perms_and_acl () { test -r "$1" && getfacl "$1" > actual && - grep -q "user:root:rwx" actual && - grep -q "user:${LOGNAME}:rwx" actual && + test_grep -q "user:root:rwx" actual && + test_grep -q "user:${LOGNAME}:rwx" actual && grep -E "mask::?r--" actual > /dev/null 2>&1 && - grep -q "group::---" actual || false + test_grep -q "group::---" actual || false } dirs_to_set="./ .git/ .git/objects/ .git/objects/pack/" diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index f3892578e4ff86..f6115269f9ede0 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -353,7 +353,7 @@ test_expect_success 'include cycles are detected' ' git -C cycle --git-dir=. config include.path cycle && git config -f cycle/cycle include.path config && test_must_fail git -C cycle --git-dir=. config --get-all test.value 2>stderr && - grep "exceeded maximum include depth" stderr + test_grep "exceeded maximum include depth" stderr ' test_expect_success 'onbranch with unborn branch' ' diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh index e0e49053f07fbc..de95161a83c57a 100755 --- a/t/t1308-config-set.sh +++ b/t/t1308-config-set.sh @@ -180,7 +180,7 @@ test_expect_success 'find integer if value is non parse-able' ' test_expect_success 'non parse-able integer value during iteration' ' check_config expect_code 128 git_config_int lamb.head 2>result && - grep "fatal: bad numeric config value .* in file \.git/config" result + test_grep "fatal: bad numeric config value .* in file \.git/config" result ' test_expect_success 'find bool value for the entered key' ' @@ -302,7 +302,7 @@ test_expect_success 'proper error on directory "files"' ' echo "Error (-1) reading configuration file a-directory." >expect && mkdir a-directory && test_expect_code 2 test-tool config configset_get_value foo.bar a-directory 2>output && - grep "^warning:" output && + test_grep "^warning:" output && grep "^Error" output >actual && test_cmp expect actual ' @@ -312,7 +312,7 @@ test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' ' test_when_finished "chmod +r .git/config" && echo "Error (-1) reading configuration file .git/config." >expect && test_expect_code 2 test-tool config configset_get_value foo.bar .git/config 2>output && - grep "^warning:" output && + test_grep "^warning:" output && grep "^Error" output >actual && test_cmp expect actual ' diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 1015f335e31611..43342797d0a3e4 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -92,7 +92,7 @@ test_expect_success "deleting current branch adds message to HEAD's log" ' git update-ref -m delete-$m -d $m && test_must_fail git show-ref --verify -q $m && test-tool ref-store main for-each-reflog-ent HEAD >actual && - grep "delete-$m$" actual + test_grep "delete-$m$" actual ' test_expect_success "deleting by HEAD adds message to HEAD's log" ' @@ -102,7 +102,7 @@ test_expect_success "deleting by HEAD adds message to HEAD's log" ' git update-ref -m delete-by-head -d HEAD && test_must_fail git show-ref --verify -q $m && test-tool ref-store main for-each-reflog-ent HEAD >actual && - grep "delete-by-head$" actual + test_grep "delete-by-head$" actual ' test_expect_success 'update-ref does not create reflogs by default' ' @@ -192,7 +192,7 @@ test_expect_success "move $m (by HEAD)" ' test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" ' test_when_finished "git update-ref -d $m" && git update-ref -d HEAD $B && - ! grep "$m" .git/packed-refs && + test_grep ! "$m" .git/packed-refs && test_must_fail git show-ref --verify -q $m ' @@ -575,43 +575,43 @@ test_expect_success 'stdin works with no input' ' test_expect_success 'stdin fails on empty line' ' echo "" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: empty command in input" err + test_grep "fatal: empty command in input" err ' test_expect_success 'stdin fails on only whitespace' ' echo " " >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: whitespace before command: " err + test_grep "fatal: whitespace before command: " err ' test_expect_success 'stdin fails on leading whitespace' ' echo " create $a $m" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: whitespace before command: create $a $m" err + test_grep "fatal: whitespace before command: create $a $m" err ' test_expect_success 'stdin fails on unknown command' ' echo "unknown $a" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: unknown command: unknown $a" err + test_grep "fatal: unknown command: unknown $a" err ' test_expect_success 'stdin fails on unbalanced quotes' ' echo "create $a \"main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: badly quoted argument: \\\"main" err + test_grep "fatal: badly quoted argument: \\\"main" err ' test_expect_success 'stdin fails on invalid escape' ' echo "create $a \"ma\zn\"" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err + test_grep "fatal: badly quoted argument: \\\"ma\\\\zn\\\"" err ' test_expect_success 'stdin fails on junk after quoted argument' ' echo "create \"$a\"main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: unexpected character after quoted argument: \\\"$a\\\"main" err + test_grep "fatal: unexpected character after quoted argument: \\\"$a\\\"main" err ' test_expect_success 'stdin fails create with no ref' ' @@ -629,7 +629,7 @@ test_expect_success 'stdin fails create with no new value' ' test_expect_success 'stdin fails create with too many arguments' ' echo "create $a $m $m" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: create $a: extra input: $m" err + test_grep "fatal: create $a: extra input: $m" err ' test_expect_success 'stdin fails update with no ref' ' @@ -647,7 +647,7 @@ test_expect_success 'stdin fails update with no new value' ' test_expect_success 'stdin fails update with too many arguments' ' echo "update $a $m $m $m" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: update $a: extra input: $m" err + test_grep "fatal: update $a: extra input: $m" err ' test_expect_success 'stdin fails delete with no ref' ' @@ -659,19 +659,19 @@ test_expect_success 'stdin fails delete with no ref' ' test_expect_success 'stdin fails delete with too many arguments' ' echo "delete $a $m $m" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: delete $a: extra input: $m" err + test_grep "fatal: delete $a: extra input: $m" err ' test_expect_success 'stdin fails verify with too many arguments' ' echo "verify $a $m $m" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: verify $a: extra input: $m" err + test_grep "fatal: verify $a: extra input: $m" err ' test_expect_success 'stdin fails option with unknown name' ' echo "option unknown" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: option unknown: unknown" err + test_grep "fatal: option unknown: unknown" err ' test_expect_success 'stdin fails with duplicate refs' ' @@ -759,7 +759,7 @@ test_expect_success 'stdin create ref works with path with space to blob' ' test_expect_success 'stdin update ref fails with wrong old value' ' echo "update $c $m $m~1" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: cannot lock ref '"'"'$c'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$c'"'"'" err && test_must_fail git rev-parse --verify -q $c ' @@ -795,7 +795,7 @@ test_expect_success 'stdin update ref works with right old value' ' test_expect_success 'stdin delete ref fails with wrong old value' ' echo "delete $a $m~1" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: cannot lock ref '"'"'$a'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$a'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual @@ -965,7 +965,7 @@ test_expect_success 'stdin update refs fails with wrong old value' ' update $c '' EOF test_must_fail git update-ref --stdin err && - grep "fatal: cannot lock ref '"'"'$c'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual && @@ -998,31 +998,31 @@ test_expect_success 'stdin -z works on empty input' ' test_expect_success 'stdin -z fails on empty line' ' echo "" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: whitespace before command: " err + test_grep "fatal: whitespace before command: " err ' test_expect_success 'stdin -z fails on empty command' ' printf $F "" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: empty command in input" err + test_grep "fatal: empty command in input" err ' test_expect_success 'stdin -z fails on only whitespace' ' printf $F " " >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: whitespace before command: " err + test_grep "fatal: whitespace before command: " err ' test_expect_success 'stdin -z fails on leading whitespace' ' printf $F " create $a" "$m" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: whitespace before command: create $a" err + test_grep "fatal: whitespace before command: create $a" err ' test_expect_success 'stdin -z fails on unknown command' ' printf $F "unknown $a" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: unknown command: unknown $a" err + test_grep "fatal: unknown command: unknown $a" err ' test_expect_success 'stdin -z fails create with no ref' ' @@ -1040,7 +1040,7 @@ test_expect_success 'stdin -z fails create with no new value' ' test_expect_success 'stdin -z fails create with too many arguments' ' printf $F "create $a" "$m" "$m" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: unknown command: $m" err + test_grep "fatal: unknown command: $m" err ' test_expect_success 'stdin -z fails update with no ref' ' @@ -1078,7 +1078,7 @@ test_expect_success 'stdin -z fails update with no old value' ' test_expect_success 'stdin -z fails update with too many arguments' ' printf $F "update $a" "$m" "$m" "$m" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: unknown command: $m" err + test_grep "fatal: unknown command: $m" err ' test_expect_success 'stdin -z fails delete with no ref' ' @@ -1096,13 +1096,13 @@ test_expect_success 'stdin -z fails delete with no old value' ' test_expect_success 'stdin -z fails delete with too many arguments' ' printf $F "delete $a" "$m" "$m" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: unknown command: $m" err + test_grep "fatal: unknown command: $m" err ' test_expect_success 'stdin -z fails verify with too many arguments' ' printf $F "verify $a" "$m" "$m" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: unknown command: $m" err + test_grep "fatal: unknown command: $m" err ' test_expect_success 'stdin -z fails verify with no old value' ' @@ -1114,7 +1114,7 @@ test_expect_success 'stdin -z fails verify with no old value' ' test_expect_success 'stdin -z fails option with unknown name' ' printf $F "option unknown" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: option unknown: unknown" err + test_grep "fatal: option unknown: unknown" err ' test_expect_success 'stdin -z fails with duplicate refs' ' @@ -1160,7 +1160,7 @@ test_expect_success 'stdin -z create ref works with path with space to blob' ' test_expect_success 'stdin -z update ref fails with wrong old value' ' printf $F "update $c" "$m" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: cannot lock ref '"'"'$c'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$c'"'"'" err && test_must_fail git rev-parse --verify -q $c ' @@ -1176,7 +1176,7 @@ test_expect_success 'stdin -z create ref fails when ref exists' ' git rev-parse "$c" >expect && printf $F "create $c" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: cannot lock ref '"'"'$c'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse "$c" >actual && test_cmp expect actual ' @@ -1199,14 +1199,14 @@ test_expect_success 'stdin -z create ref fails with empty new value' ' test_expect_success 'stdin -z create ref fails with non commit object' ' printf $F "create $c" "$(test_oid 001)" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: trying to write ref ${SQ}$c${SQ} with nonexistent object" err && + test_grep "fatal: trying to write ref ${SQ}$c${SQ} with nonexistent object" err && test_must_fail git rev-parse --verify -q $c ' test_expect_success 'stdin -z update ref fails with non commit object' ' printf $F "update $b" "$(test_oid 001)" "" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: trying to write ref ${SQ}$b${SQ} with nonexistent object" err && + test_grep "fatal: trying to write ref ${SQ}$b${SQ} with nonexistent object" err && test_must_fail git rev-parse --verify -q $c ' @@ -1221,7 +1221,7 @@ test_expect_success 'stdin -z update ref works with right old value' ' test_expect_success 'stdin -z delete ref fails with wrong old value' ' printf $F "delete $a" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: cannot lock ref '"'"'$a'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$a'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual @@ -1336,7 +1336,7 @@ test_expect_success 'stdin -z update refs fails with wrong old value' ' git update-ref $c $m && printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: cannot lock ref '"'"'$c'"'"'" err && + test_grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual && @@ -1415,13 +1415,13 @@ test_expect_success 'handle per-worktree refs in refs/bisect' ' cd worktree && git commit --allow-empty -m "test commit" && git for-each-ref >for-each-ref.out && - ! grep refs/bisect for-each-ref.out && + test_grep ! refs/bisect for-each-ref.out && git update-ref refs/bisect/something HEAD && git rev-parse refs/bisect/something >../worktree-head && git for-each-ref | grep refs/bisect/something ) && git show-ref >actual && - ! grep 'refs/bisect' actual && + test_grep ! 'refs/bisect' actual && test_must_fail git rev-parse refs/bisect/something && git update-ref refs/bisect/something HEAD && git rev-parse refs/bisect/something >main-head && @@ -1477,7 +1477,7 @@ test_expect_success 'transaction exits on multiple aborts' ' test_must_fail git update-ref --stdin actual 2>err && printf "%s: ok\n" abort >expect && test_cmp expect actual && - grep "fatal: transaction is closed" err + test_grep "fatal: transaction is closed" err ' test_expect_success 'transaction exits on start after prepare' ' @@ -1488,7 +1488,7 @@ test_expect_success 'transaction exits on start after prepare' ' test_must_fail git update-ref --stdin err >actual && printf "%s: ok\n" prepare >expect && test_cmp expect actual && - grep "fatal: prepared transactions can only be closed" err + test_grep "fatal: prepared transactions can only be closed" err ' test_expect_success 'transaction handles empty abort with missing prepare' ' @@ -1648,7 +1648,7 @@ test_expect_success PIPE 'transaction flushes status updates' ' # This must now fail given that we have locked the ref. test_must_fail git update-ref refs/heads/flush $B 2>stderr && - grep "fatal: update_ref failed for ref ${SQ}refs/heads/flush${SQ}: cannot lock ref" stderr && + test_grep "fatal: update_ref failed for ref ${SQ}refs/heads/flush${SQ}: cannot lock ref" stderr && echo commit >&9 && echo "commit: ok" >expected && @@ -1674,7 +1674,7 @@ do git symbolic-ref refs/heads/symref $a && format_command $type "symref-verify refs/heads/symref" "$a" >stdin && test_must_fail git update-ref --stdin $type err && - grep "fatal: symref-verify: cannot operate with deref mode" err + test_grep "fatal: symref-verify: cannot operate with deref mode" err ' test_expect_success "stdin $type symref-verify fails with too many arguments" ' @@ -1682,9 +1682,9 @@ do test_must_fail git update-ref --stdin $type --no-deref err && if test "$type" = "-z" then - grep "fatal: unknown command: $a" err + test_grep "fatal: unknown command: $a" err else - grep "fatal: symref-verify refs/heads/symref: extra input: $a" err + test_grep "fatal: symref-verify refs/heads/symref: extra input: $a" err fi ' @@ -1717,7 +1717,7 @@ do test-tool ref-store main for-each-reflog-ent refs/heads/symref >before && format_command $type "symref-verify refs/heads/missing" "refs/heads/unknown" >stdin && test_must_fail git update-ref --stdin $type --no-deref err && - grep "fatal: cannot lock ref ${SQ}refs/heads/missing${SQ}: unable to resolve reference ${SQ}refs/heads/missing${SQ}" err && + test_grep "fatal: cannot lock ref ${SQ}refs/heads/missing${SQ}: unable to resolve reference ${SQ}refs/heads/missing${SQ}" err && test_must_fail git rev-parse --verify -q refs/heads/missing && test-tool ref-store main for-each-reflog-ent refs/heads/symref >after && test_cmp before after @@ -1743,7 +1743,7 @@ do git symbolic-ref refs/heads/symref $a && format_command $type "symref-delete refs/heads/symref" "$a" >stdin && test_must_fail git update-ref --stdin $type err && - grep "fatal: symref-delete: cannot operate with deref mode" err + test_grep "fatal: symref-delete: cannot operate with deref mode" err ' test_expect_success "stdin $type symref-delete fails with no ref" ' @@ -1757,7 +1757,7 @@ do git update-ref refs/heads/regularref $a && format_command $type "symref-delete refs/heads/regularref" "$a" >stdin && test_must_fail git update-ref --stdin $type --no-deref err && - grep "fatal: cannot lock ref ${SQ}refs/heads/regularref${SQ}: expected symref with target ${SQ}$a${SQ}: but is a regular ref" err + test_grep "fatal: cannot lock ref ${SQ}refs/heads/regularref${SQ}: expected symref with target ${SQ}$a${SQ}: but is a regular ref" err ' test_expect_success "stdin $type symref-delete fails with too many arguments" ' @@ -1765,16 +1765,16 @@ do test_must_fail git update-ref --stdin $type --no-deref err && if test "$type" = "-z" then - grep "fatal: unknown command: $a" err + test_grep "fatal: unknown command: $a" err else - grep "fatal: symref-delete refs/heads/symref: extra input: $a" err + test_grep "fatal: symref-delete refs/heads/symref: extra input: $a" err fi ' test_expect_success "stdin $type symref-delete fails with wrong old value" ' format_command $type "symref-delete refs/heads/symref" "$m" >stdin && test_must_fail git update-ref --stdin $type --no-deref err && - grep "fatal: verifying symref target: ${SQ}refs/heads/symref${SQ}: is at $a but expected refs/heads/main" err && + test_grep "fatal: verifying symref target: ${SQ}refs/heads/symref${SQ}: is at $a but expected refs/heads/main" err && git symbolic-ref refs/heads/symref >expect && echo $a >actual && test_cmp expect actual @@ -1812,9 +1812,9 @@ do test_must_fail git update-ref --stdin $type --no-deref err && if test "$type" = "-z" then - grep "fatal: unknown command: $a" err + test_grep "fatal: unknown command: $a" err else - grep "fatal: symref-create refs/heads/symref: extra input: $a" err + test_grep "fatal: symref-create refs/heads/symref: extra input: $a" err fi ' @@ -1877,16 +1877,16 @@ do test_must_fail git update-ref --stdin $type --no-deref err && if test "$type" = "-z" then - grep "fatal: unknown command: $a" err + test_grep "fatal: unknown command: $a" err else - grep "fatal: symref-update refs/heads/symref: extra input: $a" err + test_grep "fatal: symref-update refs/heads/symref: extra input: $a" err fi ' test_expect_success "stdin $type symref-update fails with wrong old value argument" ' format_command $type "symref-update refs/heads/symref" "$a" "foo" "$a" "$a" >stdin && test_must_fail git update-ref --stdin $type --no-deref err && - grep "fatal: symref-update refs/heads/symref: invalid arg ${SQ}foo${SQ} for old value" err + test_grep "fatal: symref-update refs/heads/symref: invalid arg ${SQ}foo${SQ} for old value" err ' test_expect_success "stdin $type symref-update creates with zero old value" ' @@ -1922,7 +1922,7 @@ do git symbolic-ref refs/heads/symref $a && format_command $type "symref-update refs/heads/symref" "$m" "ref" "$b" >stdin && test_must_fail git update-ref --stdin $type --no-deref err && - grep "fatal: verifying symref target: ${SQ}refs/heads/symref${SQ}: is at $a but expected $b" err && + test_grep "fatal: verifying symref target: ${SQ}refs/heads/symref${SQ}: is at $a but expected $b" err && test_must_fail git rev-parse --verify -q $c ' @@ -1997,7 +1997,7 @@ do git symbolic-ref --no-recurse refs/heads/symref >actual && test_cmp expect actual && test-tool ref-store main for-each-reflog-ent refs/heads/symref >actual && - grep "$Z $(git rev-parse $a)" actual + test_grep "$Z $(git rev-parse $a)" actual ' test_expect_success "stdin $type symref-update regular ref to symref with correct old-oid" ' @@ -2009,7 +2009,7 @@ do git symbolic-ref --no-recurse refs/heads/regularref >actual && test_cmp expect actual && test-tool ref-store main for-each-reflog-ent refs/heads/regularref >actual && - grep "$(git rev-parse $a) $(git rev-parse $a)" actual + test_grep "$(git rev-parse $a) $(git rev-parse $a)" actual ' test_expect_success "stdin $type symref-update regular ref to symref fails with wrong old-oid" ' @@ -2017,7 +2017,7 @@ do git update-ref --no-deref refs/heads/regularref $a && format_command $type "symref-update refs/heads/regularref" "$a" "oid" "$(git rev-parse refs/heads/target2)" >stdin && test_must_fail git update-ref --stdin $type err && - grep "fatal: cannot lock ref ${SQ}refs/heads/regularref${SQ}: is at $(git rev-parse $a) but expected $(git rev-parse refs/heads/target2)" err && + test_grep "fatal: cannot lock ref ${SQ}refs/heads/regularref${SQ}: is at $(git rev-parse $a) but expected $(git rev-parse refs/heads/target2)" err && echo $(git rev-parse $a) >expect && git rev-parse refs/heads/regularref >actual && test_cmp expect actual @@ -2028,7 +2028,7 @@ do git update-ref --no-deref refs/heads/regularref $a && format_command $type "symref-update refs/heads/regularref" "$a" "oid" "not-a-ref-oid" >stdin && test_must_fail git update-ref --stdin $type err && - grep "fatal: symref-update refs/heads/regularref: invalid oid: not-a-ref-oid" err && + test_grep "fatal: symref-update refs/heads/regularref: invalid oid: not-a-ref-oid" err && echo $(git rev-parse $a) >expect && git rev-parse refs/heads/regularref >actual && test_cmp expect actual @@ -2039,7 +2039,7 @@ do git symbolic-ref refs/heads/symref refs/heads/target2 && format_command $type "symref-update refs/heads/symref" "$a" "oid" "$Z" >stdin && test_must_fail git update-ref --stdin $type err && - grep "fatal: cannot lock ref ${SQ}refs/heads/symref${SQ}: reference already exists" err && + test_grep "fatal: cannot lock ref ${SQ}refs/heads/symref${SQ}: reference already exists" err && echo refs/heads/target2 >expect && git symbolic-ref refs/heads/symref >actual && test_cmp expect actual @@ -2059,7 +2059,7 @@ do git symbolic-ref --no-recurse refs/heads/symref >actual && test_cmp expect actual && test-tool ref-store main for-each-reflog-ent refs/heads/symref >actual && - grep "$(git rev-parse $a) $(git rev-parse $a)" actual + test_grep "$(git rev-parse $a) $(git rev-parse $a)" actual ' test_expect_success "stdin $type symref-update regular ref to symref" ' @@ -2071,7 +2071,7 @@ do git symbolic-ref --no-recurse refs/heads/regularref >actual && test_cmp expect actual && test-tool ref-store main for-each-reflog-ent refs/heads/regularref >actual && - grep "$(git rev-parse $a) $(git rev-parse $a)" actual + test_grep "$(git rev-parse $a) $(git rev-parse $a)" actual ' test_expect_success "stdin $type batch-updates" ' diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh index 36c903ca1901bf..7ce5af4ab8bd06 100755 --- a/t/t1403-show-ref.sh +++ b/t/t1403-show-ref.sh @@ -213,19 +213,19 @@ test_expect_success 'show-ref --verify with dangling ref' ' test_expect_success 'show-ref sub-modes are mutually exclusive' ' test_must_fail git show-ref --verify --exclude-existing 2>err && - grep "verify" err && - grep "exclude-existing" err && - grep "cannot be used together" err && + test_grep "verify" err && + test_grep "exclude-existing" err && + test_grep "cannot be used together" err && test_must_fail git show-ref --verify --exists 2>err && - grep "verify" err && - grep "exists" err && - grep "cannot be used together" err && + test_grep "verify" err && + test_grep "exists" err && + test_grep "cannot be used together" err && test_must_fail git show-ref --exclude-existing --exists 2>err && - grep "exclude-existing" err && - grep "exists" err && - grep "cannot be used together" err + test_grep "exclude-existing" err && + test_grep "exists" err && + test_grep "cannot be used together" err ' test_done diff --git a/t/t1404-update-ref-errors.sh b/t/t1404-update-ref-errors.sh index 28e6c380d76db1..3fb38a765035ad 100755 --- a/t/t1404-update-ref-errors.sh +++ b/t/t1404-update-ref-errors.sh @@ -99,7 +99,7 @@ df_test() { printf "%s\n" "delete $delname" "create $addname $D" fi >commands && test_must_fail git update-ref --stdin output.err && - grep -E "fatal:( cannot lock ref '$addname':)? '$delref' exists; cannot create '$addref'" output.err && + test_grep -E "fatal:( cannot lock ref '$addname':)? '$delref' exists; cannot create '$addref'" output.err && printf "%s\n" "$C $delref" >expected-refs && git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs && test_cmp expected-refs actual-refs diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh index e3c501848a494c..d4e98ee16bca8d 100755 --- a/t/t1409-avoid-packing-refs.sh +++ b/t/t1409-avoid-packing-refs.sh @@ -20,7 +20,7 @@ mark_packed_refs () { # Verify that the packed-refs file is still marked. check_packed_refs_marked () { - grep -q '^#.* t1409 ' .git/packed-refs + test_grep -q '^#.* t1409 ' .git/packed-refs } test_expect_success 'setup' ' diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index ce71f9a30ae1ee..81de1d40eba7fd 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -108,12 +108,12 @@ test_expect_success setup ' test_expect_success 'correct usage on sub-command -h' ' test_expect_code 129 git reflog expire -h >err && - grep "git reflog expire" err + test_grep "git reflog expire" err ' test_expect_success 'correct usage on "git reflog show -h"' ' test_expect_code 129 git reflog show -h >err && - grep -F "git reflog [show]" err + test_grep -F "git reflog [show]" err ' test_expect_success 'pass through -- to sub-command' ' diff --git a/t/t1415-worktree-refs.sh b/t/t1415-worktree-refs.sh index 51d79bae83b429..6b2ad04aef1d0e 100755 --- a/t/t1415-worktree-refs.sh +++ b/t/t1415-worktree-refs.sh @@ -32,7 +32,7 @@ test_expect_success 'ambiguous main-worktree/HEAD' ' test_when_finished git update-ref -d refs/heads/main-worktree/HEAD && git update-ref refs/heads/main-worktree/HEAD $(git rev-parse HEAD) && git rev-parse main-worktree/HEAD 2>warn && - grep "main-worktree/HEAD.*ambiguous" warn + test_grep "main-worktree/HEAD.*ambiguous" warn ' test_expect_success 'resolve worktrees/xx/HEAD' ' @@ -45,7 +45,7 @@ test_expect_success 'ambiguous worktrees/xx/HEAD' ' git update-ref refs/heads/worktrees/wt1/HEAD $(git rev-parse HEAD) && test_when_finished git update-ref -d refs/heads/worktrees/wt1/HEAD && git rev-parse worktrees/wt1/HEAD 2>warn && - grep "worktrees/wt1/HEAD.*ambiguous" warn + test_grep "worktrees/wt1/HEAD.*ambiguous" warn ' test_expect_success 'reflog of main-worktree/HEAD' ' diff --git a/t/t1419-exclude-refs.sh b/t/t1419-exclude-refs.sh index 04797aee59e03c..f1d68d64202fc3 100755 --- a/t/t1419-exclude-refs.sh +++ b/t/t1419-exclude-refs.sh @@ -23,9 +23,9 @@ assert_jumps () { case "$GIT_DEFAULT_REF_FORMAT" in files) - grep -q "name:jumps_made value:$nr$" $trace;; + test_grep -q "name:jumps_made value:$nr$" $trace;; reftable) - grep -q "name:reseeks_made value:$nr$" $trace;; + test_grep -q "name:reseeks_made value:$nr$" $trace;; *) BUG "unhandled ref format $GIT_DEFAULT_REF_FORMAT";; esac diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 3ab65f72cdec88..1ed4c7d2c233a8 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -47,7 +47,7 @@ test_expect_success 'git branch shows badly named ref as warning' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && git branch >output 2>error && test_grep -e "ignoring ref with broken name refs/heads/broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'branch -d can delete badly named ref' ' @@ -55,8 +55,8 @@ test_expect_success 'branch -d can delete badly named ref' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && git branch -d broken...ref && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'branch -D can delete badly named ref' ' @@ -64,8 +64,8 @@ test_expect_success 'branch -D can delete badly named ref' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && git branch -D broken...ref && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'branch -D cannot delete non-ref in .git dir' ' @@ -93,8 +93,8 @@ test_expect_success 'git branch cannot create a badly named ref' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && test_must_fail git branch broken...ref && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'branch -m cannot rename to a bad ref name' ' @@ -104,8 +104,8 @@ test_expect_success 'branch -m cannot rename to a bad ref name' ' test_must_fail git branch -m goodref broken...ref && test_cmp_rev main goodref && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_failure 'branch -m can rename from a bad ref name' ' @@ -115,16 +115,16 @@ test_expect_failure 'branch -m can rename from a bad ref name' ' git branch -m broken...ref renamed && test_cmp_rev main renamed && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'push cannot create a badly named ref' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && test_must_fail git push "file://$(pwd)" HEAD:refs/heads/broken...ref && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_failure 'push --mirror can delete badly named ref' ' @@ -144,8 +144,8 @@ test_expect_failure 'push --mirror can delete badly named ref' ' ) && git -C src push --mirror "file://$top/dest" && git -C dest branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'rev-parse skips symref pointing to broken name' ' @@ -168,9 +168,9 @@ test_expect_success 'for-each-ref emits warnings for broken names' ' test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && git for-each-ref >output 2>error && - ! grep -e "broken\.\.\.ref" output && - ! grep -e "badname" output && - ! grep -e "broken\.\.\.symref" output && + test_grep ! -e "broken\.\.\.ref" output && + test_grep ! -e "badname" output && + test_grep ! -e "broken\.\.\.symref" output && test_grep "ignoring ref with broken name refs/heads/broken\.\.\.ref" error && test_grep ! "ignoring broken ref refs/heads/badname" error && test_grep "ignoring ref with broken name refs/heads/broken\.\.\.symref" error @@ -183,8 +183,8 @@ test_expect_success 'update-ref -d can delete broken name' ' test_must_be_empty output && test_must_be_empty error && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'branch -d can delete broken name' ' @@ -194,8 +194,8 @@ test_expect_success 'branch -d can delete broken name' ' test_grep "Deleted branch broken...ref (was broken)" output && test_must_be_empty error && git branch >output 2>error && - ! grep -e "broken\.\.\.ref" error && - ! grep -e "broken\.\.\.ref" output + test_grep ! -e "broken\.\.\.ref" error && + test_grep ! -e "broken\.\.\.ref" output ' test_expect_success 'update-ref --no-deref -d can delete symref to broken name' ' @@ -313,37 +313,37 @@ test_expect_success 'update-ref -d cannot delete absolute path' ' test_expect_success 'update-ref --stdin fails create with bad ref name' ' echo "create ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: invalid ref format: ~a" err + test_grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin fails update with bad ref name' ' echo "update ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: invalid ref format: ~a" err + test_grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin fails delete with bad ref name' ' echo "delete ~a refs/heads/main" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: invalid ref format: ~a" err + test_grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin -z fails create with bad ref name' ' printf "%s\0" "create ~a " refs/heads/main >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: invalid ref format: ~a " err + test_grep "fatal: invalid ref format: ~a " err ' test_expect_success 'update-ref --stdin -z fails update with bad ref name' ' printf "%s\0" "update ~a" refs/heads/main "" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: invalid ref format: ~a" err + test_grep "fatal: invalid ref format: ~a" err ' test_expect_success 'update-ref --stdin -z fails delete with bad ref name' ' printf "%s\0" "delete ~a" refs/heads/main >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: invalid ref format: ~a" err + test_grep "fatal: invalid ref format: ~a" err ' test_expect_success 'branch rejects HEAD as a branch name' ' diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 54e81c263686de..47d460a69959ea 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -68,7 +68,7 @@ test_expect_success 'object with hash mismatch' ' git update-ref refs/heads/bogus $cmt && test_must_fail git fsck 2>out && - grep "$oldoid: hash-path mismatch, found at: .*$new" out + test_grep "$oldoid: hash-path mismatch, found at: .*$new" out ) ' @@ -172,7 +172,7 @@ test_expect_success 'commit with multiple signatures is okay' ' test_when_finished "git update-ref -d refs/heads/bogus" && git fsck 2>out && cat out && - ! grep "commit $new" out + test_grep ! "commit $new" out ' test_expect_success 'email without @ is okay' ' @@ -183,7 +183,7 @@ test_expect_success 'email without @ is okay' ' git update-ref refs/heads/bogus "$new" && test_when_finished "git update-ref -d refs/heads/bogus" && git fsck 2>out && - ! grep "commit $new" out + test_grep ! "commit $new" out ' test_expect_success 'email with embedded > is not okay' ' @@ -626,7 +626,7 @@ test_expect_success 'fsck notices excessively large tree entry name' ' cd large-name && test_commit a-long-name && git -c fsck.largePathname=warn:10 fsck 2>out && - grep "warning.*large pathname" out + test_grep "warning.*large pathname" out ) ' @@ -849,7 +849,7 @@ test_expect_success 'fsck errors in packed objects' ' test_must_fail git fsck 2>out && test_grep "error in commit $one.* - bad name" out && test_grep "error in commit $two.* - bad name" out && - ! grep corrupt out + test_grep ! corrupt out ' test_expect_success 'fsck handles multiple packfiles with big blobs' ' @@ -1027,7 +1027,7 @@ test_expect_success 'bogus head does not fallback to all heads' ' test_when_finished "git rm --cached foo" && remove_object $blob && test_must_fail git fsck $ZERO_OID >out 2>&1 && - ! grep $blob out + test_grep ! $blob out ' # Corrupt the checksum on the index. diff --git a/t/t1451-fsck-buffer.sh b/t/t1451-fsck-buffer.sh index 3a3d33f4054895..14151eabbd9ffa 100755 --- a/t/t1451-fsck-buffer.sh +++ b/t/t1451-fsck-buffer.sh @@ -46,7 +46,7 @@ check () { echo "$content" } >input && test_must_fail git hash-object -t "$type" input 2>err && - grep "$fsck" err + test_grep "$fsck" err ' } @@ -125,7 +125,7 @@ ident_checks tag tagger test_expect_success 'truncated tree (short hash)' ' printf "100644 foo\0\1\1\1\1" >input && test_must_fail git hash-object -t tree input 2>err && - grep badTree err + test_grep badTree err ' test_expect_success 'truncated tree (missing nul)' ' @@ -135,7 +135,7 @@ test_expect_success 'truncated tree (missing nul)' ' # parser does not walk past the end of the buffer). printf "100644 a long filename, or a hash with missing nul?" >input && test_must_fail git hash-object -t tree input 2>err && - grep badTree err + test_grep badTree err ' test_done diff --git a/t/t1460-refs-migrate.sh b/t/t1460-refs-migrate.sh index 52464680243753..8f426971435309 100755 --- a/t/t1460-refs-migrate.sh +++ b/t/t1460-refs-migrate.sh @@ -212,7 +212,7 @@ do test_commit -C repo initial && git -C repo refs migrate --dry-run \ --ref-format=$to_format >output && - grep "Finished dry-run migration of refs" output && + test_grep "Finished dry-run migration of refs" output && test_path_is_dir repo/.git/ref_migration.* && echo $from_format >expect && git -C repo rev-parse --show-ref-format >actual && diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 38067d95f7f12b..4174ca40c342a9 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -204,7 +204,7 @@ test_expect_success 'rev-parse --show-object-format in repo' ' git rev-parse --show-object-format=output >actual && test_cmp expect actual && test_must_fail git rev-parse --show-object-format=squeamish-ossifrage 2>err && - grep "unknown mode for --show-object-format: squeamish-ossifrage" err + test_grep "unknown mode for --show-object-format: squeamish-ossifrage" err ' @@ -228,7 +228,7 @@ test_expect_success RUST 'rev-parse --show-object-format in repo with compat mod git rev-parse --show-object-format=compat >actual && test_cmp expect actual && test_must_fail git rev-parse --show-object-format=squeamish-ossifrage 2>err && - grep "unknown mode for --show-object-format: squeamish-ossifrage" err + test_grep "unknown mode for --show-object-format: squeamish-ossifrage" err ) && mkdir repo2 && ( @@ -254,7 +254,7 @@ test_expect_success 'rev-parse --show-ref-format with invalid storage' ' cd repo && git config extensions.refstorage broken && test_must_fail git rev-parse --show-ref-format 2>err && - grep "error: invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}broken${SQ}" err + test_grep "error: invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}broken${SQ}" err ) ' diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh index 3962f1d2882a1f..2cab2043760f62 100755 --- a/t/t1502-rev-parse-parseopt.sh +++ b/t/t1502-rev-parse-parseopt.sh @@ -331,7 +331,7 @@ test_expect_success 'ambiguous: --no matches both --noble and --no-noble' ' EOF test_expect_code 129 env GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=false \ git rev-parse --parseopt -- err --no && - grep "error: ambiguous option: no (could be --noble or --no-noble)" err + test_grep "error: ambiguous option: no (could be --noble or --no-noble)" err ' test_done diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh index 75a708f9ba5f22..87638a4a2c71f9 100755 --- a/t/t1503-rev-parse-verify.sh +++ b/t/t1503-rev-parse-verify.sh @@ -62,15 +62,15 @@ test_expect_success 'works with one good rev' ' test_expect_success 'fails with any bad rev or many good revs' ' test_must_fail git rev-parse --verify 2>error && - grep "single revision" error && + test_grep "single revision" error && test_must_fail git rev-parse --verify foo 2>error && - grep "single revision" error && + test_grep "single revision" error && test_must_fail git rev-parse --verify HEAD bar 2>error && - grep "single revision" error && + test_grep "single revision" error && test_must_fail git rev-parse --verify baz HEAD 2>error && - grep "single revision" error && + test_grep "single revision" error && test_must_fail git rev-parse --verify $HASH2 HEAD 2>error && - grep "single revision" error + test_grep "single revision" error ' test_expect_success 'fails silently when using -q' ' diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index bbfe05b8e4a5c4..d330b8df476152 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -604,7 +604,7 @@ test_expect_success '#20b/c: core.worktree and core.bare conflict' ' cd 20b/.git && test_must_fail git status >/dev/null ) 2>message && - grep "core.bare and core.worktree" message + test_grep "core.bare and core.worktree" message ' test_expect_success '#20d: core.worktree and core.bare OK when working tree not needed' ' @@ -721,8 +721,8 @@ test_expect_success '#22.2: core.worktree and core.bare conflict' ' export GIT_DIR && test_must_fail git status 2>result ) && - grep "core.bare and core.worktree" 22/.git/result && - grep "core.bare and core.worktree" 22/result + test_grep "core.bare and core.worktree" 22/.git/result && + test_grep "core.bare and core.worktree" 22/result ' # Case #23: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses bareness. @@ -767,7 +767,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' ' cd 28 && test_must_fail git status ) 2>message && - grep "core.bare and core.worktree" message + test_grep "core.bare and core.worktree" message ' # Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case). @@ -791,7 +791,7 @@ test_expect_success '#30: core.worktree and core.bare conflict (gitfile version) cd 30 && test_must_fail env GIT_DIR=.git git status 2>result ) && - grep "core.bare and core.worktree" 30/result + test_grep "core.bare and core.worktree" 30/result ' # Case #31: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh index 1a380a418425a4..0e6b42ec7825da 100755 --- a/t/t1512-rev-parse-disambiguation.sh +++ b/t/t1512-rev-parse-disambiguation.sh @@ -378,7 +378,7 @@ test_expect_success 'ambiguous 40-hex ref' ' VAL=$(git commit-tree $TREE err) = $REF && - grep "refname.*${REF}.*ambiguous" err + test_grep "refname.*${REF}.*ambiguous" err ' test_expect_success 'ambiguous short sha1 ref' ' @@ -387,7 +387,7 @@ test_expect_success 'ambiguous short sha1 ref' ' VAL=$(git commit-tree $TREE err) = $VAL && - grep "refname.*${REF}.*ambiguous" err + test_grep "refname.*${REF}.*ambiguous" err ' test_expect_success 'ambiguity errors are not repeated (raw)' ' diff --git a/t/t1515-rev-parse-outside-repo.sh b/t/t1515-rev-parse-outside-repo.sh index 75e89c4b6e23c2..2cb3c7cc9c4bb2 100755 --- a/t/t1515-rev-parse-outside-repo.sh +++ b/t/t1515-rev-parse-outside-repo.sh @@ -32,7 +32,7 @@ test_expect_success 'rev-parse --local-env-vars' ' git rev-parse --local-env-vars >actual && # we do not want to depend on the complete list here, # so just look for something plausible - grep ^GIT_DIR actual + test_grep ^GIT_DIR actual ' test_expect_success 'rev-parse --resolve-git-dir' ' diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh index 0132e772e472e2..9aae3ff0745191 100755 --- a/t/t1800-hook.sh +++ b/t/t1800-hook.sh @@ -79,7 +79,7 @@ test_expect_success 'git hook usage' ' test_expect_code 129 git hook run --unknown 2>err && test_expect_code 129 git hook list && test_expect_code 129 git hook list -h && - grep "unknown option" err + test_grep "unknown option" err ' test_expect_success 'git hook list: unknown hook name is rejected' ' @@ -361,9 +361,9 @@ test_expect_success 'hook can be configured for multiple events' ' # 'ghi' should be included in both 'pre-commit' and 'test-hook' git hook list pre-commit >actual && - grep "ghi" actual && + test_grep "ghi" actual && git hook list --allow-unknown-hook-name test-hook >actual && - grep "ghi" actual + test_grep "ghi" actual ' test_expect_success 'git hook list shows hooks from the hookdir' ' @@ -569,7 +569,7 @@ test_expect_success 'git hook run a hook with a bad shebang' ' # TODO: We should emit the same (or at least a more similar) # error on MINGW (essentially Git for Windows) and all other # platforms.. See the OS-specific code in start_command() - grep -E "^(error|fatal): cannot (exec|spawn) .*bad-hooks/test-hook" err + test_grep -E "^(error|fatal): cannot (exec|spawn) .*bad-hooks/test-hook" err ' test_expect_success 'stdin to hooks' ' @@ -826,8 +826,8 @@ test_expect_success 'git hook run -j2 warns for hooks not marked parallel=true' # neither hook has parallel=true git hook run --allow-unknown-hook-name -j2 test-hook >out 2>err && - grep "hook .hook-1. is not marked as parallel=true" err && - grep "hook .hook-2. is not marked as parallel=true" err + test_grep "hook .hook-1. is not marked as parallel=true" err && + test_grep "hook .hook-2. is not marked as parallel=true" err ' test_expect_success 'hook.jobs=1 config runs hooks in series' ' @@ -1068,7 +1068,7 @@ test_expect_success 'hook.jobs=-1 resolves to online_cpus()' ' cpus=$(test-tool online-cpus) && GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ git hook run --allow-unknown-hook-name test-hook >out 2>err && - grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt + test_grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt ' test_expect_success 'hook..jobs=-1 resolves to online_cpus()' ' @@ -1081,7 +1081,7 @@ test_expect_success 'hook..jobs=-1 resolves to online_cpus()' ' cpus=$(test-tool online-cpus) && GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ git hook run --allow-unknown-hook-name test-hook >out 2>err && - grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt + test_grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt ' test_expect_success 'git hook run -j-1 resolves to online_cpus()' ' @@ -1092,7 +1092,7 @@ test_expect_success 'git hook run -j-1 resolves to online_cpus()' ' cpus=$(test-tool online-cpus) && GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ git hook run --allow-unknown-hook-name -j-1 test-hook >out 2>err && - grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt + test_grep "\"region_enter\".*\"hook\".*\"test-hook\".*\"max:$cpus\"" trace.txt ' test_expect_success 'hook.jobs rejects values less than -1' ' diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index 0afe0ff7ca1f31..db06c321ed9cdd 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -132,8 +132,8 @@ test_expect_success 'overriding --stage=all resets implied --temp' ' test_expect_success '--stage=all --no-temp is rejected' ' rm -f path* .merge_* actual && test_must_fail git checkout-index --stage=all --no-temp -- path1 2>err && - grep -v "already exists" err && - grep "options .--stage=all. and .--no-temp. cannot be used together" err + test_grep -v "already exists" err && + test_grep "options .--stage=all. and .--no-temp. cannot be used together" err ' test_expect_success 'checkout some stages/one file to temporary files' ' diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh index 1fcef4be95ce14..0ac35798c26010 100755 --- a/t/t2019-checkout-ambiguous-ref.sh +++ b/t/t2019-checkout-ambiguous-ref.sh @@ -19,7 +19,7 @@ test_expect_success 'checkout ambiguous ref succeeds' ' ' test_expect_success 'checkout produces ambiguity warning' ' - grep "warning.*ambiguous" stderr + test_grep "warning.*ambiguous" stderr ' test_expect_success 'checkout chooses branch over tag' ' @@ -41,7 +41,7 @@ test_expect_success 'checkout vague ref succeeds' ' ' test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' ' - grep "warning.*ambiguous" stderr + test_grep "warning.*ambiguous" stderr ' test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' ' diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh index a3b1449ef11667..752e7f0e6130d7 100755 --- a/t/t2024-checkout-dwim.sh +++ b/t/t2024-checkout-dwim.sh @@ -311,7 +311,7 @@ test_expect_success 'loosely defined local base branch is reported correctly' ' git checkout loose >actual.raw 2>&1 && sed -e "s/loose/BRANCHNAME/g" actual && status_uno_is_clean && - grep BRANCHNAME actual && + test_grep BRANCHNAME actual && test_cmp expect actual ' @@ -324,7 +324,7 @@ test_expect_success 'reject when arg could be part of dwim branch' ' echo bar >dwim-arg && test_must_fail git checkout dwim-arg && test_must_fail git rev-parse refs/heads/dwim-arg -- && - grep bar dwim-arg + test_grep bar dwim-arg ' test_expect_success 'disambiguate dwim branch and checkout path (1)' ' @@ -334,7 +334,7 @@ test_expect_success 'disambiguate dwim branch and checkout path (1)' ' echo bar >dwim-arg1 && git checkout -- dwim-arg1 && test_must_fail git rev-parse refs/heads/dwim-arg1 -- && - grep foo dwim-arg1 + test_grep foo dwim-arg1 ' test_expect_success 'disambiguate dwim branch and checkout path (2)' ' @@ -344,7 +344,7 @@ test_expect_success 'disambiguate dwim branch and checkout path (2)' ' echo bar >dwim-arg2 && git checkout dwim-arg2 -- && git rev-parse refs/heads/dwim-arg2 -- && - grep bar dwim-arg2 + test_grep bar dwim-arg2 ' test_done diff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh index be3fcdde07562c..9af24b12040672 100755 --- a/t/t2030-unresolve-info.sh +++ b/t/t2030-unresolve-info.sh @@ -122,7 +122,7 @@ test_expect_success 'add records checkout -m undoes' ' check_resolve_undo removed && echo the index and the work tree is unmerged again && git diff >actual && - grep "^++<<<<<<<" actual + test_grep "^++<<<<<<<" actual ' test_expect_success 'unmerge with plumbing' ' @@ -173,7 +173,7 @@ test_expect_success 'rerere and rerere forget' ' test -f .git/rr-cache/$rerere_id/postimage && git checkout -m fi/le && echo resurrect the conflict && - grep "^=======" fi/le && + test_grep "^=======" fi/le && echo reresolve the conflict && git rerere && test "z$(cat fi/le)" = zdifferent && @@ -199,7 +199,7 @@ test_expect_success 'rerere and rerere forget (subdirectory)' ' test -f .git/rr-cache/$rerere_id/postimage && (cd fi && git checkout -m le) && echo resurrect the conflict && - grep "^=======" fi/le && + test_grep "^=======" fi/le && echo reresolve the conflict && (cd fi && git rerere) && test "z$(cat fi/le)" = zdifferent && diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh index c91c4db9361133..cec2fe6876c2fe 100755 --- a/t/t2060-switch.sh +++ b/t/t2060-switch.sh @@ -34,13 +34,13 @@ test_expect_success 'switch and detach' ' test_expect_success 'suggestion to detach' ' test_must_fail git switch main^{commit} 2>stderr && - grep "try again with the --detach option" stderr + test_grep "try again with the --detach option" stderr ' test_expect_success 'suggestion to detach is suppressed with advice.suggestDetachingHead=false' ' test_config advice.suggestDetachingHead false && test_must_fail git switch main^{commit} 2>stderr && - ! grep "try again with the --detach option" stderr + test_grep ! "try again with the --detach option" stderr ' test_expect_success 'switch and detach current branch' ' @@ -76,7 +76,7 @@ test_expect_success 'new orphan branch from empty' ' git switch --orphan new-orphan && test_commit orphan && git cat-file commit refs/heads/new-orphan >commit && - ! grep ^parent commit && + test_grep ! ^parent commit && git ls-files >tracked-files && echo orphan.t >expected && test_cmp expected tracked-files diff --git a/t/t2070-restore.sh b/t/t2070-restore.sh index 16d6348b692806..2c222fb9342777 100755 --- a/t/t2070-restore.sh +++ b/t/t2070-restore.sh @@ -216,7 +216,7 @@ test_expect_success 'restore with merge options are incompatible with certain op "--staged --worktree --conflict=zdiff3" do test_must_fail git restore $opts . 2>err && - grep "cannot be used" err || return + test_grep "cannot be used" err || return done ' diff --git a/t/t2080-parallel-checkout-basics.sh b/t/t2080-parallel-checkout-basics.sh index 5ffe1a41e2cd72..88a6ec1826224e 100755 --- a/t/t2080-parallel-checkout-basics.sh +++ b/t/t2080-parallel-checkout-basics.sh @@ -200,13 +200,13 @@ test_expect_success 'parallel checkout respects --[no]-force' ' # We expect 0 workers because there is nothing to be done test_checkout_workers 0 git checkout HEAD && test_path_is_file D && - grep changed D && - grep changed F.t && + test_grep changed D && + test_grep changed F.t && test_checkout_workers 2 git checkout --force HEAD && test_path_is_dir D && - grep D/F D/F.t && - grep F F.t + test_grep D/F D/F.t && + test_grep F F.t ) ' @@ -224,8 +224,8 @@ test_expect_success SYMLINKS 'parallel checkout checks for symlinks in leading d test_checkout_workers 2 git checkout --force HEAD && ! test -h D && - grep D/A D/A.t && - grep D/B D/B.t + test_grep D/A D/A.t && + test_grep D/B D/B.t ) ' @@ -268,7 +268,7 @@ test_expect_success '"git checkout ." report should not include failed entries' # - missing-delay.a: the delay filter will drop this path # - parallel-*.a: the blob will be missing # - grep "Updated 3 paths from the index" err && + test_grep "Updated 3 paths from the index" err && test_stdout_line_count = 3 ls *.b && ! ls *.a ) diff --git a/t/t2081-parallel-checkout-collisions.sh b/t/t2081-parallel-checkout-collisions.sh index f6fcfc0c1e4039..db45f5f30fc172 100755 --- a/t/t2081-parallel-checkout-collisions.sh +++ b/t/t2081-parallel-checkout-collisions.sh @@ -78,8 +78,8 @@ test_expect_success CASE_INSENSITIVE_FS 'worker detects dirname collision' ' # Check that it used the right number of workers and detected the collisions test_workers_in_event_trace 2 trace && - grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/B.}" trace && - grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/C.}" trace + test_grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/B.}" trace && + test_grep "category.:.pcheckout.,.key.:.collision/dirname.,.value.:.A/C.}" trace ' test_expect_success SYMLINKS,CASE_INSENSITIVE_FS 'do not follow symlinks colliding with leading dir' ' @@ -115,11 +115,11 @@ test_expect_success CASE_INSENSITIVE_FS 'collision report on clone (w/ racy file set_checkout_config 2 0 && test_checkout_workers 2 git clone . clone-repo 2>stderr && - grep FILE_X stderr && - grep FILE_x stderr && - grep file_X stderr && - grep file_x stderr && - grep "the following paths have collided" stderr + test_grep FILE_X stderr && + test_grep FILE_x stderr && + test_grep file_X stderr && + test_grep file_x stderr && + test_grep "the following paths have collided" stderr ' # This test ensures that the collision report code is correctly looking for @@ -148,11 +148,11 @@ test_expect_success CASE_INSENSITIVE_FS,!MINGW,!CYGWIN \ test_checkout_workers 2 \ git -c core.ignoreCase=false clone . clone-repo 2>stderr && - grep FILE_X stderr && - grep FILE_x stderr && - grep file_X stderr && - grep file_x stderr && - grep "the following paths have collided" stderr && + test_grep FILE_X stderr && + test_grep FILE_x stderr && + test_grep file_X stderr && + test_grep file_x stderr && + test_grep "the following paths have collided" stderr && # Check that only "file_x" was filtered echo file_x >expected.log && diff --git a/t/t2082-parallel-checkout-attributes.sh b/t/t2082-parallel-checkout-attributes.sh index 79fb11f139a2c1..1f43c2a267b316 100755 --- a/t/t2082-parallel-checkout-attributes.sh +++ b/t/t2082-parallel-checkout-attributes.sh @@ -28,8 +28,8 @@ test_expect_success 'parallel-checkout with ident' ' rm A B && test_checkout_workers 2 git reset --hard && hexsz=$(test_oid hexsz) && - grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A && - grep "\\\$Id\\\$" B + test_grep -E "\\\$Id: [0-9a-f]{$hexsz} \\\$" A && + test_grep "\\\$Id\\\$" B ) ' @@ -175,15 +175,15 @@ test_expect_success 'parallel-checkout and delayed checkout' ' verify_checkout delayed && # Check that the *.d files got to the delay queue and were filtered - grep "smudge W.d .* \[DELAYED\]" delayed.log && - grep "smudge X.d .* \[DELAYED\]" delayed.log && + test_grep "smudge W.d .* \[DELAYED\]" delayed.log && + test_grep "smudge X.d .* \[DELAYED\]" delayed.log && test_cmp delayed/W.d original && test_cmp delayed/X.d original && # Check that the parallel-eligible entries went to the right queue and # were not filtered - ! grep "smudge Y .* \[DELAYED\]" delayed.log && - ! grep "smudge Z .* \[DELAYED\]" delayed.log && + test_grep ! "smudge Y .* \[DELAYED\]" delayed.log && + test_grep ! "smudge Z .* \[DELAYED\]" delayed.log && test_cmp delayed/Y original && test_cmp delayed/Z original ' diff --git a/t/t2103-update-index-ignore-missing.sh b/t/t2103-update-index-ignore-missing.sh index 6938ecca868366..fbfc86b1fa6749 100755 --- a/t/t2103-update-index-ignore-missing.sh +++ b/t/t2103-update-index-ignore-missing.sh @@ -63,9 +63,9 @@ test_expect_success '--unmerged --refresh' ' git update-index --unmerged --refresh && echo 2 >two && test_must_fail git update-index --unmerged --refresh >actual && - grep two actual && - ! grep one actual && - ! grep three actual + test_grep two actual && + test_grep ! one actual && + test_grep ! three actual ' test_expect_success '--ignore-submodules --refresh (1)' ' diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 0a96655cfe7348..bb019d7a7ce439 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -241,7 +241,7 @@ test_expect_success 'add -u avoids rename pairing on unmerged paths' ' test_expect_success '"add -u non-existent" should fail' ' test_must_fail git add -u non-existent && git ls-files >actual && - ! grep "non-existent" actual + test_grep ! "non-existent" actual ' test_expect_success '"commit -a" implies "add -u" if index becomes empty' ' diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index 44c1936e4d698b..69fef7e6463cc3 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -57,7 +57,7 @@ test_expect_success 'intent to add does not clobber existing paths' ' git add -N file elif && empty=$(git hash-object --stdin actual && - ! grep "$empty" actual + test_grep ! "$empty" actual ' test_expect_success 'i-t-a entry is simply ignored' ' @@ -124,7 +124,7 @@ test_expect_success 'cache-tree does not ignore dir that has i-t-a entries' ' git add -N 2/1 && git commit -m committed && git ls-tree -r HEAD >actual && - grep 2/2 actual + test_grep 2/2 actual ) ' @@ -312,7 +312,7 @@ test_expect_success 'apply --intent-to-add' ' echo new >new-ita && git add -N new-ita && git diff >expected && - grep "new file" expected && + test_grep "new file" expected && git reset --hard && git apply --intent-to-add expected && git diff >actual && diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 58b4445cc441a8..87b926728ad8cf 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -122,7 +122,7 @@ test_expect_success 'die the same branch is already checked out' ' ( cd here && test_must_fail git checkout newmain 2>actual && - grep "already used by worktree at" actual + test_grep "already used by worktree at" actual ) ' @@ -139,7 +139,7 @@ test_expect_success 'refuse to reset a branch in use elsewhere' ' git rev-parse --verify refs/heads/newmain >new.branch && git rev-parse --verify HEAD >new.head && - grep "already used by worktree at" error && + test_grep "already used by worktree at" error && test_cmp old.branch new.branch && test_cmp old.head new.head && @@ -328,7 +328,7 @@ test_wt_add_excl () { local opts="$*" && test_expect_success "'worktree add' with '$opts' has mutually exclusive options" ' test_must_fail git worktree add $opts 2>actual && - grep -E "fatal:( options)? .* cannot be used together" actual + test_grep -E "fatal:( options)? .* cannot be used together" actual ' } @@ -436,13 +436,13 @@ test_wt_add_orphan_hint () { (cd repo && test_commit commit) && git -C repo switch --orphan noref && test_must_fail git -C repo worktree add $opts foobar/ 2>actual && - ! grep "error: unknown switch" actual && - grep "hint: If you meant to create a worktree containing a new unborn branch" actual && + test_grep ! "error: unknown switch" actual && + test_grep "hint: If you meant to create a worktree containing a new unborn branch" actual && if [ $use_branch -eq 1 ] then - grep -E "^hint: +git worktree add --orphan -b [^ ]+ [^ ]+$" actual + test_grep -E "^hint: +git worktree add --orphan -b [^ ]+ [^ ]+$" actual else - grep -E "^hint: +git worktree add --orphan [^ ]+$" actual + test_grep -E "^hint: +git worktree add --orphan [^ ]+$" actual fi ' @@ -457,8 +457,8 @@ test_expect_success "'worktree add' doesn't show orphan hint in bad/orphan HEAD git init repo && (cd repo && test_commit commit) && test_must_fail git -C repo worktree add --quiet foobar_branch foobar/ 2>actual && - ! grep "error: unknown switch" actual && - ! grep "hint: If you meant to create a worktree containing a new unborn branch" actual + test_grep ! "error: unknown switch" actual && + test_grep ! "hint: If you meant to create a worktree containing a new unborn branch" actual ' test_expect_success 'local clone from linked checkout' ' @@ -469,7 +469,7 @@ test_expect_success 'local clone from linked checkout' ' test_expect_success 'local clone --shared from linked checkout' ' git -C bare worktree add --detach ../baretree && git clone --local --shared baretree bare-clone && - grep /bare/ bare-clone/.git/objects/info/alternates + test_grep /bare/ bare-clone/.git/objects/info/alternates ' test_expect_success '"add" worktree with --no-checkout' ' @@ -491,7 +491,7 @@ test_expect_success 'put a worktree under rebase' ' set_fake_editor && FAKE_LINES="edit 1" git rebase -i HEAD^ && git worktree list >actual && - grep "under-rebase.*detached HEAD" actual + test_grep "under-rebase.*detached HEAD" actual ) ' @@ -533,7 +533,7 @@ test_expect_success 'checkout a branch under bisect' ' git bisect bad && git bisect good HEAD~2 && git worktree list >actual && - grep "under-bisect.*detached HEAD" actual && + test_grep "under-bisect.*detached HEAD" actual && test_must_fail git worktree add new-bisect under-bisect && test_path_is_missing new-bisect ) diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index e0c6abd2f58e20..eeaf800d74fc5f 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -101,8 +101,8 @@ test_expect_success '"list" all worktrees with locked annotation' ' git worktree lock locked && test_when_finished "git worktree unlock locked" && git worktree list >out && - grep "/locked *[0-9a-f].* locked$" out && - ! grep "/unlocked *[0-9a-f].* locked$" out + test_grep "/locked *[0-9a-f].* locked$" out && + test_grep ! "/unlocked *[0-9a-f].* locked$" out ' test_expect_success '"list" all worktrees --porcelain with locked' ' @@ -143,8 +143,8 @@ test_expect_success '"list" all worktrees with prunable annotation' ' git worktree add --detach unprunable && rm -rf prunable && git worktree list >out && - grep "/prunable *[0-9a-f].* prunable$" out && - ! grep "/unprunable *[0-9a-f].* prunable$" + test_grep "/prunable *[0-9a-f].* prunable$" out && + test_grep ! "/unprunable *[0-9a-f].* prunable$" out ' test_expect_success '"list" all worktrees --porcelain with prunable' ' @@ -162,8 +162,8 @@ test_expect_success '"list" all worktrees with prunable consistent with "prune"' git worktree add --detach unprunable && rm -rf prunable && git worktree list >out && - grep "/prunable *[0-9a-f].* prunable$" out && - ! grep "/unprunable *[0-9a-f].* unprunable$" out && + test_grep "/prunable *[0-9a-f].* prunable$" out && + test_grep ! "/unprunable *[0-9a-f].* unprunable$" out && git worktree prune --verbose 2>out && test_grep "^Removing worktrees/prunable" out && test_grep ! "^Removing worktrees/unprunable" out @@ -184,7 +184,7 @@ test_expect_success '"list" all worktrees --verbose with locked' ' echo "$(git -C locked2 rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >expect && printf "\tlocked: with reason\n" >>expect && git worktree list --verbose >out && - grep "/locked1 *[0-9a-f].* locked$" out && + test_grep "/locked1 *[0-9a-f].* locked$" out && sed -n "s/ */ /g;/\/locked2 *[0-9a-f].*$/,/locked: .*$/p" actual && test_cmp actual expect ' @@ -266,7 +266,7 @@ test_expect_success 'broken main worktree still at the top' ' test_cmp ../expected actual && git worktree list >out && head -n 1 out >actual.2 && - grep -F "(error)" actual.2 + test_grep -F "(error)" actual.2 ) ' diff --git a/t/t2403-worktree-move.sh b/t/t2403-worktree-move.sh index 0bb33e8b1b90fb..69768c120773f4 100755 --- a/t/t2403-worktree-move.sh +++ b/t/t2403-worktree-move.sh @@ -75,8 +75,8 @@ test_expect_success 'move worktree' ' git worktree move source destination && test_path_is_missing source && git worktree list --porcelain >out && - grep "^worktree.*/destination$" out && - ! grep "^worktree.*/source$" out && + test_grep "^worktree.*/destination$" out && + test_grep ! "^worktree.*/source$" out && git -C destination log --format=%s >actual2 && echo init >expected2 && test_cmp expected2 actual2 @@ -92,7 +92,7 @@ test_expect_success 'move worktree to another dir' ' test_when_finished "git worktree move some-dir/destination destination" && test_path_is_missing destination && git worktree list --porcelain >out && - grep "^worktree.*/some-dir/destination$" out && + test_grep "^worktree.*/some-dir/destination$" out && git -C some-dir/destination log --format=%s >actual2 && echo init >expected2 && test_cmp expected2 actual2 diff --git a/t/t2405-worktree-submodule.sh b/t/t2405-worktree-submodule.sh index 11018f37c70c02..f5c94d490be6da 100755 --- a/t/t2405-worktree-submodule.sh +++ b/t/t2405-worktree-submodule.sh @@ -36,7 +36,7 @@ test_expect_success 'add superproject worktree' ' test_expect_failure 'submodule is checked out just after worktree add' ' git -C worktree diff --submodule main"^!" >out && - grep "file1 updated" out + test_grep "file1 updated" out ' test_expect_success 'add superproject worktree and initialize submodules' ' @@ -46,7 +46,7 @@ test_expect_success 'add superproject worktree and initialize submodules' ' test_expect_success 'submodule is checked out just after submodule update in linked worktree' ' git -C worktree-submodule-update diff --submodule main"^!" >out && - grep "file1 updated" out + test_grep "file1 updated" out ' test_expect_success 'add superproject worktree and manually add submodule worktree' ' @@ -56,7 +56,7 @@ test_expect_success 'add superproject worktree and manually add submodule worktr test_expect_success 'submodule is checked out after manually adding submodule worktree' ' git -C linked_submodule diff --submodule main"^!" >out && - grep "file1 updated" out + test_grep "file1 updated" out ' test_expect_success 'checkout --recurse-submodules uses $GIT_DIR for submodules in a linked worktree' ' diff --git a/t/t2407-worktree-heads.sh b/t/t2407-worktree-heads.sh index 57c201869f02e6..a6d7e0f83bb575 100755 --- a/t/t2407-worktree-heads.sh +++ b/t/t2407-worktree-heads.sh @@ -41,10 +41,10 @@ test_expect_success 'refuse to overwrite: checked out in worktree' ' for i in 1 2 3 4 do test_must_fail git branch -f wt-$i HEAD 2>err && - grep "cannot force update the branch" err && + test_grep "cannot force update the branch" err && test_must_fail git branch -D wt-$i 2>err && - grep "cannot delete branch" err || return 1 + test_grep "cannot delete branch" err || return 1 done ' @@ -57,7 +57,7 @@ test_expect_success 'refuse to overwrite: worktree in bisect' ' git -C wt-4 bisect good wt-1 && test_must_fail git branch -f wt-4 HEAD 2>err && - grep "cannot force update the branch '\''wt-4'\'' used by worktree at.*wt-4" err + test_grep "cannot force update the branch '\''wt-4'\'' used by worktree at.*wt-4" err ' test_expect_success 'refuse to overwrite: worktree in rebase (apply)' ' @@ -67,7 +67,7 @@ test_expect_success 'refuse to overwrite: worktree in rebase (apply)' ' test_must_fail git -C wt-2 rebase --apply conflict-2 && test_must_fail git branch -f wt-2 HEAD 2>err && - grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err + test_grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err ' test_expect_success 'refuse to overwrite: worktree in rebase (merge)' ' @@ -77,7 +77,7 @@ test_expect_success 'refuse to overwrite: worktree in rebase (merge)' ' test_must_fail git -C wt-2 rebase conflict-2 && test_must_fail git branch -f wt-2 HEAD 2>err && - grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err + test_grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err ' test_expect_success 'refuse to overwrite: worktree in rebase with --update-refs' ' @@ -89,19 +89,19 @@ test_expect_success 'refuse to overwrite: worktree in rebase with --update-refs' for i in 3 4 do test_must_fail git branch -f can-be-updated HEAD 2>err && - grep "cannot force update the branch '\''can-be-updated'\'' used by worktree at.*wt-3" err || + test_grep "cannot force update the branch '\''can-be-updated'\'' used by worktree at.*wt-3" err || return 1 done ' test_expect_success 'refuse to fetch over ref: checked out' ' test_must_fail git fetch server +refs/heads/wt-3:refs/heads/wt-3 2>err && - grep "refusing to fetch into branch '\''refs/heads/wt-3'\''" err && + test_grep "refusing to fetch into branch '\''refs/heads/wt-3'\''" err && # General fetch into refs/heads/ will fail on first ref, # so use a generic error message check. test_must_fail git fetch server +refs/heads/*:refs/heads/* 2>err && - grep "refusing to fetch into branch" err + test_grep "refusing to fetch into branch" err ' test_expect_success 'refuse to fetch over ref: worktree in bisect' ' @@ -113,7 +113,7 @@ test_expect_success 'refuse to fetch over ref: worktree in bisect' ' git -C wt-4 bisect good wt-1 && test_must_fail git fetch server +refs/heads/wt-4:refs/heads/wt-4 2>err && - grep "refusing to fetch into branch" err + test_grep "refusing to fetch into branch" err ' test_expect_success 'refuse to fetch over ref: worktree in rebase' ' @@ -123,7 +123,7 @@ test_expect_success 'refuse to fetch over ref: worktree in rebase' ' test_must_fail git -C wt-3 rebase conflict-3 && test_must_fail git fetch server +refs/heads/wt-3:refs/heads/wt-3 2>err && - grep "refusing to fetch into branch" err + test_grep "refusing to fetch into branch" err ' test_expect_success 'refuse to overwrite when in error states' ' @@ -149,7 +149,7 @@ test_expect_success 'refuse to overwrite when in error states' ' for i in 1 2 do test_must_fail git branch -f fake-$i HEAD 2>err && - grep "cannot force update the branch '\''fake-$i'\'' used by worktree at" err || + test_grep "cannot force update the branch '\''fake-$i'\'' used by worktree at" err || return 1 done ' @@ -161,13 +161,13 @@ test_expect_success 'refuse to overwrite during rebase with --update-refs' ' ( set_cat_todo_editor && test_must_fail git rebase -i --update-refs HEAD~3 >todo && - ! grep "update-refs" todo + test_grep ! "update-refs" todo ) && git branch -f allow-update HEAD~2 && ( set_cat_todo_editor && test_must_fail git rebase -i --update-refs HEAD~3 >todo && - grep "update-ref refs/heads/allow-update" todo + test_grep "update-ref refs/heads/allow-update" todo ) ' diff --git a/t/t2500-untracked-overwriting.sh b/t/t2500-untracked-overwriting.sh index 5c0bf4d21fcbb2..8e84f29e8d9394 100755 --- a/t/t2500-untracked-overwriting.sh +++ b/t/t2500-untracked-overwriting.sh @@ -51,7 +51,7 @@ test_expect_success 'reset --merge will preserve untracked files/dirs' ' test_must_fail git reset --merge work 2>error && test_cmp expect foo.t/file && - grep "Updating .foo.t. would lose untracked files" error + test_grep "Updating .foo.t. would lose untracked files" error ) ' @@ -66,7 +66,7 @@ test_expect_success 'reset --keep will preserve untracked files/dirs' ' test_must_fail git reset --merge work 2>error && test_cmp expect foo.t/file && - grep "Updating.*foo.t.*would lose untracked files" error + test_grep "Updating.*foo.t.*would lose untracked files" error ) ' @@ -214,7 +214,7 @@ test_expect_success 'git am --abort and untracked dir vs. unmerged file' ' test_must_fail git am --abort 2>errors && test_path_is_dir filler && - grep "Updating .filler. would lose untracked files in it" errors + test_grep "Updating .filler. would lose untracked files in it" errors ) ' @@ -237,7 +237,7 @@ test_expect_success 'git am --skip and untracked dir vs deleted file' ' # Change our mind about resolutions, just skip this patch test_must_fail git am --skip 2>errors && test_path_is_dir newfile && - grep "Updating .newfile. would lose untracked files in it" errors + test_grep "Updating .newfile. would lose untracked files in it" errors ) ' diff --git a/t/t2501-cwd-empty.sh b/t/t2501-cwd-empty.sh index be9140bbaa46e7..98b2d1787870b8 100755 --- a/t/t2501-cwd-empty.sh +++ b/t/t2501-cwd-empty.sh @@ -60,7 +60,7 @@ test_required_dir_removal () { # Ensure command refuses to run test_must_fail "$@" 2>../error && - grep "Refusing to remove.*current working directory" ../error && + test_grep "Refusing to remove.*current working directory" ../error && # ...and that the index and working tree are left clean git diff --exit-code HEAD && @@ -114,7 +114,7 @@ test_expect_success 'merge fails if cwd needs to be removed; recursive friendly' ) && test_path_is_dir dirORfile && - grep "Refusing to remove the current working directory" error + test_grep "Refusing to remove the current working directory" error ' test_expect_success 'merge fails if cwd needs to be removed' ' @@ -179,7 +179,7 @@ test_incidental_untracked_dir_removal () { test_expect_success 'clean does not remove cwd incidentally' ' test_incidental_untracked_dir_removal \ git -C .. clean -fd -e warnings . >warnings && - grep "Refusing to remove current working directory" warnings + test_grep "Refusing to remove current working directory" warnings ' test_expect_success 'stash does not remove cwd incidentally' ' diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 202fb8d9eacc2c..29a0a25b30bdf5 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -161,21 +161,21 @@ test_expect_success 'trailing slash in exclude forces directory match (1)' ' >two && git ls-files --others --exclude=two/ >output && - grep "^two" output + test_grep "^two" output ' test_expect_success 'trailing slash in exclude forces directory match (2)' ' git ls-files --others --exclude=one/a.1/ >output && - grep "^one/a.1" output + test_grep "^one/a.1" output ' test_expect_success 'negated exclude matches can override previous ones' ' git ls-files --others --exclude="a.*" --exclude="!a.1" >output && - grep "^a.1" output + test_grep "^a.1" output ' test_expect_success 'excluded directory overrides content patterns' ' diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh index 61771eec830c06..218964edab00a7 100755 --- a/t/t3007-ls-files-recurse-submodules.sh +++ b/t/t3007-ls-files-recurse-submodules.sh @@ -302,7 +302,7 @@ test_expect_success '--recurse-submodules does not support --error-unmatch' ' test_expect_success '--recurse-submodules parses submodule repo config' ' test_config -C submodule index.sparse "invalid non-boolean value" && test_must_fail git ls-files --recurse-submodules 2>err && - grep "bad boolean config value" err + test_grep "bad boolean config value" err ' test_expect_success '--recurse-submodules parses submodule worktree config' ' @@ -310,7 +310,7 @@ test_expect_success '--recurse-submodules parses submodule worktree config' ' test_config -C submodule --worktree index.sparse "invalid non-boolean value" && test_must_fail git ls-files --recurse-submodules 2>err && - grep "bad boolean config value" err + test_grep "bad boolean config value" err ' test_expect_success '--recurse-submodules submodules ignore super project worktreeConfig extension' ' @@ -329,7 +329,7 @@ test_expect_success '--recurse-submodules submodules ignore super project worktr # With extensions.worktreeConfig disabled in the submodule, the invalid # worktree config is not picked up. git ls-files --recurse-submodules 2>err && - ! grep "bad boolean config value" err + test_grep ! "bad boolean config value" err ' test_incompatible_with_recurse_submodules () { diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index e7829c2c4bfdc3..bd839998b1f092 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -204,7 +204,7 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou test_expect_success 'git branch -M baz bam should add entries to HEAD reflog' ' git reflog show HEAD >actual && - grep "HEAD@{0}: Branch: renamed refs/heads/baz to refs/heads/bam" actual + test_grep "HEAD@{0}: Branch: renamed refs/heads/baz to refs/heads/bam" actual ' test_expect_success 'git branch -M should leave orphaned HEAD alone' ' @@ -339,7 +339,7 @@ test_expect_success 'git branch -d on orphan HEAD (unmerged)' ' test_when_finished "git branch -D to-delete" && git branch to-delete main && test_must_fail git branch -d to-delete 2>err && - grep "not fully merged" err + test_grep "not fully merged" err ' test_expect_success 'git branch -d on orphan HEAD (unmerged, graph)' ' @@ -350,7 +350,7 @@ test_expect_success 'git branch -d on orphan HEAD (unmerged, graph)' ' test_when_finished "rm -rf .git/objects/commit-graph*" && git commit-graph write --reachable && test_must_fail git branch -d to-delete 2>err && - grep "not fully merged" err + test_grep "not fully merged" err ' test_expect_success 'git branch -v -d t should work' ' @@ -712,7 +712,7 @@ test_expect_success 'git branch -C c1 c2 should succeed when c1 is checked out' test_expect_success 'git branch -C c1 c2 should never touch HEAD' ' msg="Branch: copied refs/heads/c1 to refs/heads/c2" && git reflog HEAD >actual && - ! grep "$msg$" actual + test_grep ! "$msg$" actual ' test_expect_success 'git branch -C main should work when main is checked out' ' @@ -930,7 +930,7 @@ test_expect_success 'deleting currently checked out branch fails' ' git worktree add -b my7 my7 && test_must_fail git -C my7 branch -d my7 && test_must_fail git branch -d my7 2>actual && - grep "^error: cannot delete branch .my7. used by worktree at " actual && + test_grep "^error: cannot delete branch .my7. used by worktree at " actual && rm -r my7 && git worktree prune ' @@ -941,7 +941,7 @@ test_expect_success 'deleting in-use branch fails' ' git -C my7 bisect start HEAD HEAD~2 && test_must_fail git -C my7 branch -d my7 && test_must_fail git branch -d my7 2>actual && - grep "^error: cannot delete branch .my7. used by worktree at " actual && + test_grep "^error: cannot delete branch .my7. used by worktree at " actual && rm -r my7 && git worktree prune ' diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index a1139f79e2ccfd..f402334936466d 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -123,13 +123,13 @@ test_expect_success 'show-branch --sparse' ' git commit --allow-empty -m "another" && git show-branch --sparse >out && - grep "merge 1 and 10 to make A" out && + test_grep "merge 1 and 10 to make A" out && git show-branch >out && - ! grep "merge 1 and 10 to make A" out && + test_grep ! "merge 1 and 10 to make A" out && git show-branch --no-sparse >out && - ! grep "merge 1 and 10 to make A" out + test_grep ! "merge 1 and 10 to make A" out ' test_expect_success 'setup show branch --list' ' @@ -189,7 +189,7 @@ while read combo do test_expect_success "show-branch $combo (should fail)" ' test_must_fail git show-branch $combo 2>error && - grep -e "cannot be used together" -e "usage:" error + test_grep -e "cannot be used together" -e "usage:" error ' done <<\EOF --all --reflog @@ -203,7 +203,7 @@ for opt in topo-order date-order reflog do test_expect_success "show-branch --no-$opt (should fail)" ' test_must_fail git show-branch --no-$opt 2>err && - grep "unknown option .no-$opt." err + test_grep "unknown option .no-$opt." err ' done diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index a6bd88a58d0a8c..7c441863418260 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -64,7 +64,7 @@ test_expect_success 'git branch -r shows remote branches' ' test_expect_success 'git branch --no-remotes is rejected' ' test_must_fail git branch --no-remotes 2>err && - grep "unknown option .no-remotes." err + test_grep "unknown option .no-remotes." err ' cat >expect <<'EOF' @@ -85,7 +85,7 @@ test_expect_success 'git branch -a shows local and remote branches' ' test_expect_success 'git branch --no-all is rejected' ' test_must_fail git branch --no-all 2>err && - grep "unknown option .no-all." err + test_grep "unknown option .no-all." err ' cat >expect <<'EOF' diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 1e812df806bbbf..ef92704de39830 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -538,10 +538,10 @@ do main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "= 4: .* s/12/B" 0000-* + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "= 4: .* s/12/B" 0000-* ' done @@ -564,7 +564,7 @@ test_expect_success 'format-patch --range-diff as commentary' ' git format-patch --range-diff=HEAD~1 HEAD~1 >actual && test_line_count = 1 actual && test_grep "^Range-diff:$" 0001-* && - grep "> 1: .* new message" 0001-* + test_grep "> 1: .* new message" 0001-* ' test_expect_success 'format-patch --range-diff reroll-count with a non-integer' ' @@ -572,7 +572,7 @@ test_expect_success 'format-patch --range-diff reroll-count with a non-integer' git format-patch --range-diff=HEAD~1 -v2.9 HEAD~1 >actual && test_line_count = 1 actual && test_grep "^Range-diff:$" v2.9-0001-* && - grep "> 1: .* new message" v2.9-0001-* + test_grep "> 1: .* new message" v2.9-0001-* ' test_expect_success 'format-patch --range-diff reroll-count with a integer' ' @@ -580,7 +580,7 @@ test_expect_success 'format-patch --range-diff reroll-count with a integer' ' git format-patch --range-diff=HEAD~1 -v2 HEAD~1 >actual && test_line_count = 1 actual && test_grep "^Range-diff ..* v1:$" v2-0001-* && - grep "> 1: .* new message" v2-0001-* + test_grep "> 1: .* new message" v2-0001-* ' test_expect_success 'format-patch --range-diff with v0' ' @@ -588,7 +588,7 @@ test_expect_success 'format-patch --range-diff with v0' ' git format-patch --range-diff=HEAD~1 -v0 HEAD~1 >actual && test_line_count = 1 actual && test_grep "^Range-diff:$" v0-0001-* && - grep "> 1: .* new message" v0-0001-* + test_grep "> 1: .* new message" v0-0001-* ' test_expect_success 'range-diff overrides diff.noprefix internally' ' @@ -686,8 +686,8 @@ test_expect_success 'range-diff with --notes=custom does not show default notes' git notes --ref=custom add -m "unmodified note" unmodified && git range-diff --notes=custom main..topic main..unmodified \ >actual && - ! grep "## Notes ##" actual && - grep "## Notes (custom) ##" actual + test_grep ! "## Notes ##" actual && + test_grep "## Notes (custom) ##" actual ' test_expect_success 'format-patch --range-diff does not compare notes by default' ' @@ -699,12 +699,12 @@ test_expect_success 'format-patch --range-diff does not compare notes by default main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "= 4: .* s/12/B" 0000-* && - ! grep "Notes" 0000-* && - ! grep "note" 0000-* + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "= 4: .* s/12/B" 0000-* && + test_grep ! "Notes" 0000-* && + test_grep ! "note" 0000-* ' test_expect_success 'format-patch --notes=custom --range-diff --cover-letter only compares custom notes' ' @@ -717,8 +717,8 @@ test_expect_success 'format-patch --notes=custom --range-diff --cover-letter onl test_when_finished "rm -f 000?-*" && git format-patch --notes=custom --cover-letter --range-diff=$prev \ main..unmodified >actual && - grep "## Notes (custom) ##" 0000-* && - ! grep "## Notes ##" 0000-* + test_grep "## Notes (custom) ##" 0000-* && + test_grep ! "## Notes ##" 0000-* ' # --range-diff on a single commit requires --no-cover-letter @@ -744,12 +744,12 @@ test_expect_success 'format-patch --range-diff with --no-notes' ' main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "= 4: .* s/12/B" 0000-* && - ! grep "Notes" 0000-* && - ! grep "note" 0000-* + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "= 4: .* s/12/B" 0000-* && + test_grep ! "Notes" 0000-* && + test_grep ! "note" 0000-* ' test_expect_success 'format-patch --range-diff with --notes' ' @@ -761,10 +761,10 @@ test_expect_success 'format-patch --range-diff with --notes' ' main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "! 4: .* s/12/B" 0000-* && + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "! 4: .* s/12/B" 0000-* && sed s/Z/\ /g >expect <<-EOF && @@ Commit message Z @@ -790,10 +790,10 @@ test_expect_success 'format-patch --range-diff with format.notes config' ' main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "! 4: .* s/12/B" 0000-* && + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "! 4: .* s/12/B" 0000-* && sed s/Z/\ /g >expect <<-EOF && @@ Commit message Z @@ -821,10 +821,10 @@ test_expect_success 'format-patch --range-diff with multiple notes' ' main..unmodified >actual && test_line_count = 5 actual && test_grep "^Range-diff:$" 0000-* && - grep "= 1: .* s/5/A" 0000-* && - grep "= 2: .* s/4/A" 0000-* && - grep "= 3: .* s/11/B" 0000-* && - grep "! 4: .* s/12/B" 0000-* && + test_grep "= 1: .* s/5/A" 0000-* && + test_grep "= 2: .* s/4/A" 0000-* && + test_grep "= 3: .* s/11/B" 0000-* && + test_grep "! 4: .* s/12/B" 0000-* && sed s/Z/\ /g >expect <<-EOF && @@ Commit message Z @@ -866,9 +866,9 @@ test_expect_success 'ranges with pathspecs' ' topic_oid=$(git rev-parse --short topic) && mode_change_oid=$(git rev-parse --short mode-only-change^) && file_change_oid=$(git rev-parse --short mode-only-change) && - grep "$mode_change_oid" actual && - ! grep "$file_change_oid" actual && - ! grep "$topic_oid" actual + test_grep "$mode_change_oid" actual && + test_grep ! "$file_change_oid" actual && + test_grep ! "$topic_oid" actual ' test_expect_success 'submodule changes are shown irrespective of diff.submodule' ' diff --git a/t/t3207-branch-submodule.sh b/t/t3207-branch-submodule.sh index fe72b247164e56..74c83548ecb96c 100755 --- a/t/t3207-branch-submodule.sh +++ b/t/t3207-branch-submodule.sh @@ -24,7 +24,7 @@ test_no_branch () { DIR=$1 && BRANCH_NAME=$2 && test_must_fail git -C "$DIR" rev-parse "$BRANCH_NAME" 2>err && - grep "ambiguous argument .$BRANCH_NAME." err + test_grep "ambiguous argument .$BRANCH_NAME." err } test_expect_success 'setup superproject and submodule' ' @@ -136,7 +136,7 @@ test_expect_success 'should not create any branches if branch is not valid for a git -C sub branch branch-a && test_must_fail git branch --recurse-submodules branch-a 2>actual && test_no_branch . branch-a && - grep "submodule .sub.: fatal: a branch named .branch-a. already exists" actual + test_grep "submodule .sub.: fatal: a branch named .branch-a. already exists" actual ) ' @@ -251,7 +251,7 @@ test_expect_success 'should get fatal error upon branch creation when submodule git branch --recurse-submodules branch-a origin/branch-a && # This should fail because super-clone does not have sub2 .git/modules test_must_fail git branch --recurse-submodules branch-b origin/branch-b 2>actual && - grep "fatal: submodule .sub2.: unable to find submodule" actual && + test_grep "fatal: submodule .sub2.: unable to find submodule" actual && test_no_branch . branch-b && test_no_branch sub branch-b && # User can fix themselves by initializing the submodule diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index d6c50460d08648..3744e282f8ce38 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -164,7 +164,7 @@ test_expect_success 'show notes' ' ${indent}b1 EOF git cat-file commit HEAD >commits && - ! grep b1 commits && + test_grep ! b1 commits && git log -1 >actual && test_cmp expect actual ' @@ -248,17 +248,17 @@ test_expect_success 'git log --show-notes' ' test_expect_success 'git log --no-notes' ' git log -1 --no-notes >actual && - ! grep xyzzy actual + test_grep ! xyzzy actual ' test_expect_success 'git format-patch does not show notes' ' git format-patch -1 --stdout >actual && - ! grep xyzzy actual + test_grep ! xyzzy actual ' test_expect_success 'git format-patch --show-notes does show notes' ' git format-patch --show-notes -1 --stdout >actual && - grep xyzzy actual + test_grep xyzzy actual ' for pretty in \ @@ -271,7 +271,7 @@ do esac test_expect_success "git show $pretty does$not show notes" ' git show $p >actual && - eval "$negate grep xyzzy actual" + eval "$negate test_grep xyzzy actual" ' done @@ -281,36 +281,36 @@ test_expect_success 'setup alternate notes ref' ' test_expect_success 'git log --notes shows default notes' ' git log -1 --notes >actual && - grep xyzzy actual && - ! grep alternate actual + test_grep xyzzy actual && + test_grep ! alternate actual ' test_expect_success 'git log --notes=X shows only X' ' git log -1 --notes=alternate >actual && - ! grep xyzzy actual && - grep alternate actual + test_grep ! xyzzy actual && + test_grep alternate actual ' test_expect_success 'git log --notes --notes=X shows both' ' git log -1 --notes --notes=alternate >actual && - grep xyzzy actual && - grep alternate actual + test_grep xyzzy actual && + test_grep alternate actual ' test_expect_success 'git log --no-notes resets default state' ' git log -1 --notes --notes=alternate \ --no-notes --notes=alternate \ >actual && - ! grep xyzzy actual && - grep alternate actual + test_grep ! xyzzy actual && + test_grep alternate actual ' test_expect_success 'git log --no-notes resets ref list' ' git log -1 --notes --notes=alternate \ --no-notes --notes \ >actual && - grep xyzzy actual && - ! grep alternate actual + test_grep xyzzy actual && + test_grep ! alternate actual ' test_expect_success 'show -m notes' ' @@ -543,7 +543,7 @@ test_expect_success 'list notes with "git notes"' ' test_expect_success '"git notes" without subcommand does not take arguments' ' test_expect_code 129 git notes HEAD^^ 2>err && - grep "^error: unknown subcommand" err + test_grep "^error: unknown subcommand" err ' test_expect_success 'list specific note with "git notes list "' ' @@ -1464,7 +1464,7 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' GIT_NOTES_REWRITE_REF=refs/notes/commits \ git notes copy --for-rewrite=foo actual && - grep "replacement note 3" actual + test_grep "replacement note 3" actual ' test_expect_success 'git notes copy diagnoses too many or too few arguments' ' diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 0bb366fdb8fce1..1d61c997ff9de9 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -382,12 +382,12 @@ EOF test_cmp pre_merge_z actual && # Merge commit mentions the notes refs merged git log -1 --format=%B refs/notes/m > merge_commit_msg && - grep -q refs/notes/m merge_commit_msg && - grep -q refs/notes/z merge_commit_msg && + test_grep -q refs/notes/m merge_commit_msg && + test_grep -q refs/notes/z merge_commit_msg && # Merge commit mentions conflicting notes - grep -q "Conflicts" merge_commit_msg && + test_grep -q "Conflicts" merge_commit_msg && ( for sha1 in $(cat expect_conflicts); do - grep -q "$sha1" merge_commit_msg || + test_grep -q "$sha1" merge_commit_msg || exit 1 done ) && # Verify contents of merge result @@ -512,12 +512,12 @@ EOF test_cmp pre_merge_z actual && # Merge commit mentions the notes refs merged git log -1 --format=%B refs/notes/m > merge_commit_msg && - grep -q refs/notes/m merge_commit_msg && - grep -q refs/notes/z merge_commit_msg && + test_grep -q refs/notes/m merge_commit_msg && + test_grep -q refs/notes/z merge_commit_msg && # Merge commit mentions conflicting notes - grep -q "Conflicts" merge_commit_msg && + test_grep -q "Conflicts" merge_commit_msg && ( for sha1 in $(cat expect_conflicts); do - grep -q "$sha1" merge_commit_msg || + test_grep -q "$sha1" merge_commit_msg || exit 1 done ) && # Verify contents of merge result diff --git a/t/t3320-notes-merge-worktrees.sh b/t/t3320-notes-merge-worktrees.sh index 96243b72222420..9a2c3ac3f706af 100755 --- a/t/t3320-notes-merge-worktrees.sh +++ b/t/t3320-notes-merge-worktrees.sh @@ -67,7 +67,7 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' ' git config core.notesRef refs/notes/x && test_must_fail git notes merge z >out 2>&1 && test_grep "Automatic notes merge failed" out && - grep -v "A notes merge into refs/notes/x is already in-progress in" out + test_grep -v "A notes merge into refs/notes/x is already in-progress in" out ) && echo "refs/notes/x" >expect && git -C worktree2 symbolic-ref NOTES_MERGE_REF >actual && diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index c0c00fbb7b1e4e..e62e07b894669e 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -287,16 +287,16 @@ test_expect_success 'rebase commit with an ancient timestamp' ' git commit --date="@34567 +0600" -m "Old three" && git cat-file commit HEAD^^ >actual && - grep "author .* 12345 +0400$" actual && + test_grep "author .* 12345 +0400$" actual && git cat-file commit HEAD^ >actual && - grep "author .* 23456 +0500$" actual && + test_grep "author .* 23456 +0500$" actual && git cat-file commit HEAD >actual && - grep "author .* 34567 +0600$" actual && + test_grep "author .* 34567 +0600$" actual && git rebase --onto HEAD^^ HEAD^ && git cat-file commit HEAD >actual && - grep "author .* 34567 +0600$" actual + test_grep "author .* 34567 +0600$" actual ' test_expect_success 'rebase with "From " line in commit message' ' @@ -333,7 +333,7 @@ test_expect_success 'rebase --apply and --show-current-patch' ' git tag two && test_must_fail git rebase --apply -f --onto init HEAD^ && GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr && - grep "show.*$(git rev-parse two)" stderr + test_grep "show.*$(git rev-parse two)" stderr ) ' @@ -364,12 +364,12 @@ test_expect_success 'rebase --apply and .gitattributes' ' git checkout test && git rebase main && - grep "smudged" a.txt && + test_grep "smudged" a.txt && git checkout removal && git reset --hard && git rebase main && - grep "clean" a.txt + test_grep "clean" a.txt ) ' @@ -386,7 +386,7 @@ test_expect_success 'rebase--merge.sh and --show-current-patch' ' test_must_fail git rebase --merge --onto init HEAD^ && git rebase --show-current-patch >actual.patch && GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr && - grep "show.*REBASE_HEAD" stderr && + test_grep "show.*REBASE_HEAD" stderr && test "$(git rev-parse REBASE_HEAD)" = "$(git rev-parse two)" ) ' diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh index 761de63b6b9822..41ebcdec9f7117 100755 --- a/t/t3402-rebase-merge.sh +++ b/t/t3402-rebase-merge.sh @@ -84,8 +84,8 @@ test_expect_success 'rebase -Xtheirs' ' echo "AB $T" >> original && git commit -mconflicting original && git rebase -Xtheirs main && - grep AB original && - ! grep 11 original + test_grep AB original && + test_grep ! 11 original ' test_expect_success 'rebase -Xtheirs from orphan' ' @@ -93,8 +93,8 @@ test_expect_success 'rebase -Xtheirs from orphan' ' echo "AB $T" >> original && git commit -morphan-conflicting original && git rebase -Xtheirs main && - grep AB original && - ! grep 11 original + test_grep AB original && + test_grep ! 11 original ' test_expect_success 'merge and rebase should match' ' @@ -210,15 +210,15 @@ test_expect_success '--reapply-cherry-picks refrains from reading unneeded blobs git -C client rev-list --objects --all --missing=print >missing_list && MERGE_BASE_BLOB=$(git -C server rev-parse main^^:file.txt) && ADD_11_BLOB=$(git -C server rev-parse main^:file.txt) && - grep "[?]$MERGE_BASE_BLOB" missing_list && - grep "[?]$ADD_11_BLOB" missing_list && + test_grep "[?]$MERGE_BASE_BLOB" missing_list && + test_grep "[?]$ADD_11_BLOB" missing_list && git -C client rebase --merge --reapply-cherry-picks origin/main && # The blob from the merge base had to be fetched, but not "add 11" git -C client rev-list --objects --all --missing=print >missing_list && - ! grep "[?]$MERGE_BASE_BLOB" missing_list && - grep "[?]$ADD_11_BLOB" missing_list + test_grep ! "[?]$MERGE_BASE_BLOB" missing_list && + test_grep "[?]$ADD_11_BLOB" missing_list ' test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 58b3bb0c271aae..e90f02e06f3a09 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -144,7 +144,7 @@ test_expect_success 'rebase -i sets work tree properly' ' mkdir subdir && git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \ >actual && - ! grep "/subdir$" actual + test_grep ! "/subdir$" actual ' test_expect_success 'rebase -i with the exec command checks tree cleanness' ' @@ -196,7 +196,7 @@ test_expect_success 'rebase -i with exec of inexistent command' ' test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \ git rebase -i HEAD^ >actual 2>&1 ) && - ! grep "Maybe git-rebase is broken" actual + test_grep ! "Maybe git-rebase is broken" actual ' test_expect_success 'implicit interactive rebase does not invoke sequence editor' ' @@ -293,7 +293,7 @@ test_expect_success 'stop on conflicting pick' ' test_expect_success 'show conflicted patch' ' GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr && - grep "show.*REBASE_HEAD" stderr && + test_grep "show.*REBASE_HEAD" stderr && # the original stopped-sha1 is abbreviated stopped_sha1="$(git rev-parse $(cat ".git/rebase-merge/stopped-sha"))" && test "$(git rev-parse REBASE_HEAD)" = "$stopped_sha1" @@ -326,7 +326,7 @@ test_expect_success 'retain authorship' ' git tag twerp && git rebase -i --onto primary HEAD^ && git show HEAD >actual && - grep "^Author: Twerp Snog" actual + test_grep "^Author: Twerp Snog" actual ' test_expect_success 'retain authorship w/ conflicts' ' @@ -348,7 +348,7 @@ test_expect_success 'retain authorship w/ conflicts' ' git rebase --continue && test_cmp_rev conflict-a^0 HEAD^ && git show >out && - grep AttributeMe out + test_grep AttributeMe out ' test_expect_success 'squash' ' @@ -368,7 +368,7 @@ test_expect_success 'squash' ' test_expect_success 'retain authorship when squashing' ' git show HEAD >actual && - grep "^Author: Twerp Snog" actual + test_grep "^Author: Twerp Snog" actual ' test_expect_success '--continue tries to commit' ' @@ -383,7 +383,7 @@ test_expect_success '--continue tries to commit' ' ) && test_cmp_rev HEAD^ new-branch1 && git show HEAD >actual && - grep chouette actual + test_grep chouette actual ' test_expect_success 'verbose flag is heeded, even after --continue' ' @@ -422,7 +422,7 @@ test_expect_success 'multi-fixup does not fire up editor' ' ) && test $base = $(git rev-parse HEAD^) && git show >output && - ! grep NEVER output && + test_grep ! NEVER output && git checkout @{-1} && git branch -D multi-fixup ' @@ -487,9 +487,9 @@ test_expect_success 'squash and fixup generate correct log messages' ' git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup && test_cmp expect-squash-fixup actual-squash-fixup && git cat-file commit HEAD@{2} >actual && - grep "^# This is a combination of 3 commits\." actual && + test_grep "^# This is a combination of 3 commits\." actual && git cat-file commit HEAD@{3} >actual && - grep "^# This is a combination of 2 commits\." actual && + test_grep "^# This is a combination of 2 commits\." actual && git checkout @{-1} && git branch -D squash-fixup ' @@ -593,7 +593,7 @@ test_expect_success '--continue tries to commit, even for "edit"' ' ) && test edited = $(git show HEAD:file7) && git show HEAD >actual && - grep chouette actual && + test_grep chouette actual && test $parent = $(git rev-parse HEAD^) ' @@ -779,22 +779,22 @@ test_expect_success 'reword' ' FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \ git rebase -i A && git show HEAD >actual && - grep "E changed" actual && + test_grep "E changed" actual && test $(git rev-parse primary) != $(git rev-parse HEAD) && test_cmp_rev primary^ HEAD^ && FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \ git rebase -i A && git show HEAD^ >actual && - grep "D changed" actual && + test_grep "D changed" actual && FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" \ git rebase -i A && git show HEAD~3 >actual && - grep "B changed" actual && + test_grep "B changed" actual && FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" \ git rebase -i A ) && git show HEAD~2 >actual && - grep "C changed" actual + test_grep "C changed" actual ' test_expect_success 'reword fast-forwarded empty commit' ' @@ -1043,9 +1043,9 @@ test_expect_success 'rebase -i --root retain root commit author and message' ' FAKE_LINES="2" git rebase -i --root ) && git cat-file commit HEAD >output && - grep -q "^author Twerp Snog" output && + test_grep -q "^author Twerp Snog" output && git cat-file commit HEAD >actual && - grep -q "^different author$" actual + test_grep -q "^different author$" actual ' test_expect_success 'rebase -i --root temporary sentinel commit' ' @@ -1055,7 +1055,7 @@ test_expect_success 'rebase -i --root temporary sentinel commit' ' test_must_fail env FAKE_LINES="2" git rebase -i --root ) && git cat-file commit HEAD >actual && - grep "^tree $EMPTY_TREE" actual && + test_grep "^tree $EMPTY_TREE" actual && git rebase --abort ' @@ -1079,7 +1079,7 @@ test_expect_success 'rebase -i --root reword original root commit' ' git rebase -i --root ) && git show HEAD^ >actual && - grep "A changed" actual && + test_grep "A changed" actual && test -z "$(git show -s --format=%p HEAD^)" ' @@ -1092,7 +1092,7 @@ test_expect_success 'rebase -i --root reword new root commit' ' git rebase -i --root ) && git show HEAD^ >actual && - grep "C changed" actual && + test_grep "C changed" actual && test -z "$(git show -s --format=%p HEAD^)" ' @@ -1315,11 +1315,11 @@ test_expect_success 'short commit ID collide' ' FAKE_COMMIT_MESSAGE="collide2 $(test_oid t3404_collider)" \ FAKE_LINES="reword 1 break 2" git rebase -i HEAD~2 && test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" && - grep "^pick $colliding_id " \ + test_grep "^pick $colliding_id " \ .git/rebase-merge/git-rebase-todo.tmp && - grep -E "^pick [0-9a-f]{$hexsz}" \ + test_grep -E "^pick [0-9a-f]{$hexsz}" \ .git/rebase-merge/git-rebase-todo && - grep -E "^pick [0-9a-f]{$hexsz}" \ + test_grep -E "^pick [0-9a-f]{$hexsz}" \ .git/rebase-merge/git-rebase-todo.backup && git rebase --continue ) && @@ -1371,7 +1371,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (pick)' ' echo changed >file1 && git add file1 && test_must_fail git rebase --continue 2>err && - grep "error: you have staged changes in your working tree" err && + test_grep "error: you have staged changes in your working tree" err && git reset --hard HEAD && git rebase --continue && test_cmp_rev HEAD D && @@ -1398,7 +1398,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (squash)' echo changed >file1 && git add file1 && test_must_fail git rebase --continue 2>err && - grep "error: you have staged changes in your working tree" err && + test_grep "error: you have staged changes in your working tree" err && git reset --hard HEAD && git rebase --continue && test $(git cat-file commit HEAD | sed -ne \$p) = I && @@ -1423,7 +1423,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' ' echo changed >file1 && git add file1 && test_must_fail git rebase --continue 2>err && - grep "error: you have staged changes in your working tree" err && + test_grep "error: you have staged changes in your working tree" err && git reset --hard HEAD && git rebase --continue && test $(git cat-file commit HEAD | sed -ne \$p) = I @@ -1709,15 +1709,15 @@ test_expect_success 'the first command cannot be a fixup' ' set_replace_editor orig && test_must_fail git rebase -i A 2>actual ) && - grep "cannot .fixup. without a previous commit" actual && - grep "You can fix this with .git rebase --edit-todo.." actual && + test_grep "cannot .fixup. without a previous commit" actual && + test_grep "You can fix this with .git rebase --edit-todo.." actual && # verify that the todo list has not been truncated grep -v "^#" .git/rebase-merge/git-rebase-todo >actual && test_cmp orig actual && test_must_fail git rebase --edit-todo 2>actual && - grep "cannot .fixup. without a previous commit" actual && - grep "You can fix this with .git rebase --edit-todo.." actual && + test_grep "cannot .fixup. without a previous commit" actual && + test_grep "You can fix this with .git rebase --edit-todo.." actual && # verify that the todo list has not been truncated grep -v "^#" .git/rebase-merge/git-rebase-todo >actual && test_cmp orig actual @@ -2252,7 +2252,7 @@ test_expect_success '--update-refs: check failed ref update' ' git update-ref refs/heads/second third && test_must_fail git rebase --continue 2>err && - grep "update_ref failed for ref '\''refs/heads/second'\''" err && + test_grep "update_ref failed for ref '\''refs/heads/second'\''" err && q_to_tab >expect <<-\EOF && Updated the following refs with --update-refs: @@ -2283,10 +2283,10 @@ test_expect_success 'bad labels and refs rejected when parsing todo list' ' set_replace_editor todo && test_must_fail git rebase -i HEAD 2>err ) && - grep "'\''#'\'' is not a valid label" err && - grep "'\'':invalid'\'' is not a valid label" err && - grep "'\'':bad'\'' is not a valid refname" err && - grep "update-ref requires a fully qualified refname e.g. refs/heads/topic" \ + test_grep "'\''#'\'' is not a valid label" err && + test_grep "'\'':invalid'\'' is not a valid label" err && + test_grep "'\'':bad'\'' is not a valid refname" err && + test_grep "update-ref requires a fully qualified refname e.g. refs/heads/topic" \ err && test_path_is_missing execed ' diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 5033411a431833..07a5a11678cda1 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -223,7 +223,7 @@ test_expect_success 'auto squash that matches a sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - ! grep "squash" commit && + test_grep ! "squash" commit && grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -245,7 +245,7 @@ test_expect_success 'auto squash that matches longer sha1' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - ! grep "squash" commit && + test_grep ! "squash" commit && grep "^extra para" commit >actual && test_line_count = 1 actual ' @@ -377,7 +377,7 @@ test_expect_success 'autosquash with custom inst format' ' git cat-file blob HEAD^:file1 >actual && test_cmp expect actual && git cat-file commit HEAD^ >commit && - ! grep "squash" commit && + test_grep ! "squash" commit && grep first commit >actual && test_line_count = 3 actual ' @@ -424,7 +424,7 @@ test_expect_success 'autosquash with multiple empty patches' ' set_backup_editor && GIT_USE_REBASE_HELPER=false \ git rebase -i --force-rebase --autosquash HEAD~4 && - grep empty2 .git/backup-git-rebase-todo + test_grep empty2 .git/backup-git-rebase-todo ) ' @@ -467,7 +467,7 @@ test_expect_success 'abort last squash' ' git commit --allow-empty --amend -m edited-first && git rebase --skip && git show >actual && - ! grep first actual + test_grep ! first actual ' test_expect_success 'fixup a fixup' ' diff --git a/t/t3416-rebase-onto-threedots.sh b/t/t3416-rebase-onto-threedots.sh index ea501f2b42b8cc..e7f725b8d0c709 100755 --- a/t/t3416-rebase-onto-threedots.sh +++ b/t/t3416-rebase-onto-threedots.sh @@ -107,7 +107,7 @@ test_expect_success 'rebase --onto main...side requires a single merge-base' ' git reset --hard K && test_must_fail git rebase -i --onto main...side J 2>err && - grep "need exactly one merge base" err + test_grep "need exactly one merge base" err ' test_expect_success 'rebase --keep-base --onto incompatible' ' @@ -196,7 +196,7 @@ test_expect_success 'rebase --keep-base requires a single merge base' ' git reset --hard K && test_must_fail git rebase -i --keep-base main 2>err && - grep "need exactly one merge base with branch" err + test_grep "need exactly one merge base with branch" err ' test_expect_success 'rebase --keep-base keeps cherry picks' ' diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index f9b8999db50f1b..03e0714864c5fd 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -289,18 +289,18 @@ test_expect_success 'patch file is removed before break command' ' test_expect_success '--reschedule-failed-exec' ' test_when_finished "git rebase --abort" && test_must_fail git rebase -x false --reschedule-failed-exec HEAD^ && - grep "^exec false" .git/rebase-merge/git-rebase-todo && + test_grep "^exec false" .git/rebase-merge/git-rebase-todo && git rebase --abort && test_must_fail git -c rebase.rescheduleFailedExec=true \ rebase -x false HEAD^ 2>err && - grep "^exec false" .git/rebase-merge/git-rebase-todo && + test_grep "^exec false" .git/rebase-merge/git-rebase-todo && test_grep "has been rescheduled" err ' test_expect_success 'rebase.rescheduleFailedExec only affects `rebase -i`' ' test_config rebase.rescheduleFailedExec true && test_must_fail git rebase -x false HEAD^ && - grep "^exec false" .git/rebase-merge/git-rebase-todo && + test_grep "^exec false" .git/rebase-merge/git-rebase-todo && git rebase --abort && git rebase HEAD^ ' @@ -310,7 +310,7 @@ test_expect_success 'rebase.rescheduleFailedExec=true & --no-reschedule-failed-e test_config rebase.rescheduleFailedExec true && test_must_fail git rebase -x false --no-reschedule-failed-exec HEAD~2 && test_must_fail git rebase --continue 2>err && - ! grep "has been rescheduled" err + test_grep ! "has been rescheduled" err ' test_expect_success 'new rebase.rescheduleFailedExec=true setting in an ongoing rebase is ignored' ' @@ -318,7 +318,7 @@ test_expect_success 'new rebase.rescheduleFailedExec=true setting in an ongoing test_must_fail git rebase -x false HEAD~2 && test_config rebase.rescheduleFailedExec true && test_must_fail git rebase --continue 2>err && - ! grep "has been rescheduled" err + test_grep ! "has been rescheduled" err ' test_expect_success 'there is no --no-reschedule-failed-exec in an ongoing rebase' ' diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index f0bbc476ff8f4d..4042d67722182d 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -141,8 +141,8 @@ testrebase () { git checkout -b rebased-feature-branch feature-branch && echo dirty >>file3 && git rebase$type unrelated-onto-branch >actual 2>&1 && - grep unrelated file4 && - grep dirty file3 && + test_grep unrelated file4 && + test_grep dirty file3 && git checkout feature-branch ' @@ -165,8 +165,8 @@ testrebase () { echo dirty >>file3 && git add file3 && git rebase$type unrelated-onto-branch && - grep unrelated file4 && - grep dirty file3 && + test_grep unrelated file4 && + test_grep dirty file3 && git checkout feature-branch ' @@ -197,7 +197,7 @@ testrebase () { git add file2 && git rebase --continue && test_path_is_missing $dotest/autostash && - grep dirty file3 && + test_grep dirty file3 && git checkout feature-branch ' @@ -212,7 +212,7 @@ testrebase () { test_path_is_missing file3 && git rebase --skip && test_path_is_missing $dotest/autostash && - grep dirty file3 && + test_grep dirty file3 && git checkout feature-branch ' @@ -227,7 +227,7 @@ testrebase () { test_path_is_missing file3 && git rebase --abort && test_path_is_missing $dotest/autostash && - grep dirty file3 && + test_grep dirty file3 && git checkout feature-branch ' @@ -244,7 +244,7 @@ testrebase () { git rebase --quit && test_when_finished git stash drop && test_path_is_missing $dotest/autostash && - ! grep dirty file3 && + test_grep ! dirty file3 && git stash show -p >actual && test_cmp expect actual && git reset --hard && @@ -260,11 +260,11 @@ testrebase () { git rebase$type unrelated-onto-branch >actual 2>&1 && test_path_is_missing $dotest && git reset --hard && - grep unrelated file4 && - ! grep dirty file4 && + test_grep unrelated file4 && + test_grep ! dirty file4 && git checkout feature-branch && git stash pop && - grep dirty file4 + test_grep dirty file4 ' test_expect_success "rebase$type: check output with conflicting stash" ' @@ -286,7 +286,7 @@ test_expect_success "rebase: fast-forward rebase" ' test_when_finished git branch -D behind-feature-branch && echo dirty >>file1 && git rebase feature-branch && - grep dirty file1 && + test_grep dirty file1 && git checkout feature-branch ' @@ -297,7 +297,7 @@ test_expect_success "rebase: noop rebase" ' test_when_finished git branch -D same-feature-branch && echo dirty >>file1 && git rebase feature-branch && - grep dirty file1 && + test_grep dirty file1 && git checkout feature-branch ' diff --git a/t/t3422-rebase-incompatible-options.sh b/t/t3422-rebase-incompatible-options.sh index b9408f9ba1285f..d6830b82e000d9 100755 --- a/t/t3422-rebase-incompatible-options.sh +++ b/t/t3422-rebase-incompatible-options.sh @@ -102,13 +102,13 @@ test_rebase_am_only () { test_expect_success "$opt incompatible with rebase.rebaseMerges" " git checkout B^0 && test_must_fail git -c rebase.rebaseMerges=true rebase $opt A 2>err && - grep -e --no-rebase-merges err + test_grep -e --no-rebase-merges err " test_expect_success "$opt incompatible with rebase.updateRefs" " git checkout B^0 && test_must_fail git -c rebase.updateRefs=true rebase $opt A 2>err && - grep -e --no-update-refs err + test_grep -e --no-update-refs err " test_expect_success "$opt okay with overridden rebase.rebaseMerges" " diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index abd66f360213e1..28e4bdd0d93a1a 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -19,7 +19,7 @@ test_expect_success 'rebase exec modifies rebase-todo' ' test_expect_success 'rebase exec with an empty list does not exec anything' ' git rebase HEAD -x "true" 2>output && - ! grep "Executing: true" output + test_grep ! "Executing: true" output ' test_expect_success 'loose object cache vs re-reading todo list' ' diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index 84b2d0e664e58f..9bd61c58b38d4c 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -161,7 +161,7 @@ test_expect_success '`reset` rejects trees' ' test_when_finished "test_might_fail git rebase --abort" && test_must_fail env GIT_SEQUENCE_EDITOR="echo reset A^{tree} >" \ git rebase -i B C >out 2>err && - grep "object .* is a tree" err && + test_grep "object .* is a tree" err && test_must_be_empty out ' @@ -170,7 +170,7 @@ test_expect_success '`reset` only looks for labels under refs/rewritten/' ' git branch refs/rewritten/my-label A && test_must_fail env GIT_SEQUENCE_EDITOR="echo reset my-label >" \ git rebase -i B C >out 2>err && - grep "could not resolve ${SQ}my-label${SQ}" err && + test_grep "could not resolve ${SQ}my-label${SQ}" err && test_must_be_empty out ' @@ -185,18 +185,18 @@ test_expect_success 'failed `merge -C` writes patch (may be rescheduled, too)' ' test_tick && test_must_fail git rebase -ir HEAD && test_cmp_rev REBASE_HEAD H^0 && - grep "^merge -C .* G$" .git/rebase-merge/done && - grep "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && + test_grep "^merge -C .* G$" .git/rebase-merge/done && + test_grep "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && test_path_is_missing .git/rebase-merge/patch && echo changed >file1 && git add file1 && test_must_fail git rebase --continue 2>err && - grep "error: you have staged changes in your working tree" err && + test_grep "error: you have staged changes in your working tree" err && : fail because of merge conflict && git reset --hard conflicting-G && test_must_fail git rebase --continue && - ! grep "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && + test_grep ! "^merge -C .* G$" .git/rebase-merge/git-rebase-todo && test_path_is_file .git/rebase-merge/patch ' @@ -208,8 +208,8 @@ test_expect_success 'failed `merge ` does not crash' ' test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && test_must_fail git rebase -ir HEAD && - ! grep "^merge G$" .git/rebase-merge/git-rebase-todo && - grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message + test_grep ! "^merge G$" .git/rebase-merge/git-rebase-todo && + test_grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message ' test_expect_success 'merge -c commits before rewording and reloads todo-list' ' @@ -481,8 +481,8 @@ test_expect_success 'labels that are object IDs are rewritten' ' test_config sequence.editor \""$PWD"/replace-editor.sh\" && test_tick && git rebase -i -r A && - grep "^label $third-" .git/ORIGINAL-TODO && - ! grep "^label $third$" .git/ORIGINAL-TODO + test_grep "^label $third-" .git/ORIGINAL-TODO && + test_grep ! "^label $third$" .git/ORIGINAL-TODO ' test_expect_success 'octopus merges' ' @@ -533,9 +533,9 @@ test_expect_success 'with --autosquash and --exec' ' EOF test_tick && git rebase -ir --autosquash --exec ./show.sh A >actual && - grep "B: +Booh" actual && - grep "E: +Booh" actual && - grep "G: +G" actual + test_grep "B: +Booh" actual && + test_grep "E: +Booh" actual && + test_grep "G: +G" actual ' test_expect_success '--continue after resolving conflicts after a merge' ' @@ -546,7 +546,7 @@ test_expect_success '--continue after resolving conflicts after a merge' ' git checkout -b conflicts-in-merge H && test_commit H2 H2.t conflicts H2-conflict && test_must_fail git rebase -r already-has-g && - grep conflicts H2.t && + test_grep conflicts H2.t && echo resolved >H2.t && git add -u && git rebase --continue && @@ -616,9 +616,9 @@ test_expect_success 'truncate label names' ' done="$(git rev-parse --git-path rebase-merge/done)" && git -c rebase.maxLabelLength=14 rebase --rebase-merges -x "cp \"$done\" out" --root && - grep "label 0123456789-我$" out && + test_grep "label 0123456789-我$" out && git -c rebase.maxLabelLength=13 rebase --rebase-merges -x "cp \"$done\" out" --root && - grep "label 0123456789-$" out + test_grep "label 0123456789-$" out ' test_expect_success 'reword fast-forwarded empty merge commit' ' diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh index 94671d3c465046..f78c655a5887fb 100755 --- a/t/t3436-rebase-more-options.sh +++ b/t/t3436-rebase-more-options.sh @@ -128,7 +128,7 @@ test_expect_success '--committer-date-is-author-date works when committing confl # author dates in the file. test_atime_is_ignored () { git log $1 --format=%ai >authortime && - ! grep -v +0000 authortime + test_grep ! -v +0000 authortime } test_expect_success '--reset-author-date works with apply backend' ' diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index 3e66827d7641d8..03655c8a481aa1 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -100,8 +100,8 @@ test_expect_success 'cherry in partial clone does bulk prefetch' ' GIT_TRACE2_EVENT="$(pwd)/trace2.output" git cherry upstream-with-space feature-without-space >actual && test_cmp ../expect actual && - ! grep "child_start.*fetch.negotiationAlgorithm" trace2.output && - ! grep "\"key\":\"fetch_count\"" trace2.output + test_grep ! "child_start.*fetch.negotiationAlgorithm" trace2.output && + test_grep ! "\"key\":\"fetch_count\"" trace2.output ) ' diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 8025a28cfddb08..939e7a16a636d4 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -67,7 +67,7 @@ test_expect_success 'cherry-pick after renaming branch' ' git checkout rename2 && git cherry-pick added && test_cmp_rev rename2 HEAD^ && - grep "Add extra line at the end" opos && + test_grep "Add extra line at the end" opos && git reflog -1 | grep cherry-pick ' @@ -162,7 +162,7 @@ test_expect_success 'cherry-pick works with dirty renamed file' ' echo modified >renamed && git cherry-pick refs/heads/unrelated && test $(git rev-parse :0:renamed) = $(git rev-parse HEAD~2:to-rename.t) && - grep -q "^modified$" renamed + test_grep -q "^modified$" renamed ' test_expect_success 'advice from failed revert' ' @@ -253,7 +253,7 @@ test_expect_success 'identification of reverted commit (revert.reference)' ' test_expect_success 'cherry-pick is unaware of --reference (for now)' ' test_when_finished "git reset --hard" && test_must_fail git cherry-pick --reference HEAD 2>actual && - grep "^usage: git cherry-pick" actual + test_grep "^usage: git cherry-pick" actual ' test_done diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh index 18aeba161c0ae4..462973fa9191ce 100755 --- a/t/t3504-cherry-pick-rerere.sh +++ b/t/t3504-cherry-pick-rerere.sh @@ -98,9 +98,9 @@ test_expect_success 'cherry-pick --rerere-autoupdate more than once' ' test_expect_success 'cherry-pick conflict without rerere' ' test_config rerere.enabled false && test_must_fail git cherry-pick foo-main && - grep ===== foo && - grep foo-dev foo && - grep foo-main foo + test_grep ===== foo && + test_grep foo-dev foo && + test_grep foo-main foo ' test_done diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 66ff9db2702a35..5777dff4964381 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -580,10 +580,10 @@ test_expect_success '--continue respects opts' ' git cat-file commit HEAD~1 >picked_msg && git cat-file commit HEAD~2 >unrelatedpick_msg && git cat-file commit HEAD~3 >initial_msg && - ! grep "cherry picked from" initial_msg && - grep "cherry picked from" unrelatedpick_msg && - grep "cherry picked from" picked_msg && - grep "cherry picked from" anotherpick_msg + test_grep ! "cherry picked from" initial_msg && + test_grep "cherry picked from" unrelatedpick_msg && + test_grep "cherry picked from" picked_msg && + test_grep "cherry picked from" anotherpick_msg ' test_expect_success '--continue of single-pick respects -x' ' @@ -594,7 +594,7 @@ test_expect_success '--continue of single-pick respects -x' ' git cherry-pick --continue && test_path_is_missing .git/sequencer && git cat-file commit HEAD >msg && - grep "cherry picked from" msg + test_grep "cherry picked from" msg ' test_expect_success '--continue respects -x in first commit in multi-pick' ' @@ -606,7 +606,7 @@ test_expect_success '--continue respects -x in first commit in multi-pick' ' test_path_is_missing .git/sequencer && git cat-file commit HEAD^ >msg && picked=$(git rev-parse --verify picked) && - grep "cherry picked from.*$picked" msg + test_grep "cherry picked from.*$picked" msg ' test_expect_failure '--signoff is automatically propagated to resolved conflict' ' @@ -621,10 +621,10 @@ test_expect_failure '--signoff is automatically propagated to resolved conflict' git cat-file commit HEAD~1 >picked_msg && git cat-file commit HEAD~2 >unrelatedpick_msg && git cat-file commit HEAD~3 >initial_msg && - ! grep "Signed-off-by:" initial_msg && - grep "Signed-off-by:" unrelatedpick_msg && - ! grep "Signed-off-by:" picked_msg && - grep "Signed-off-by:" anotherpick_msg + test_grep ! "Signed-off-by:" initial_msg && + test_grep "Signed-off-by:" unrelatedpick_msg && + test_grep ! "Signed-off-by:" picked_msg && + test_grep "Signed-off-by:" anotherpick_msg ' test_expect_failure '--signoff dropped for implicit commit of resolution, multi-pick case' ' @@ -637,7 +637,7 @@ test_expect_failure '--signoff dropped for implicit commit of resolution, multi- git diff --exit-code HEAD && test_cmp_rev initial HEAD^^ && git cat-file commit HEAD^ >msg && - ! grep Signed-off-by: msg + test_grep ! Signed-off-by: msg ' test_expect_failure 'sign-off needs to be reaffirmed after conflict resolution, single-pick case' ' @@ -650,7 +650,7 @@ test_expect_failure 'sign-off needs to be reaffirmed after conflict resolution, git diff --exit-code HEAD && test_cmp_rev initial HEAD^ && git cat-file commit HEAD >msg && - ! grep Signed-off-by: msg + test_grep ! Signed-off-by: msg ' test_expect_success 'malformed instruction sheet 1' ' diff --git a/t/t3602-rm-sparse-checkout.sh b/t/t3602-rm-sparse-checkout.sh index 02c7acd61784ad..252df28bbf4329 100755 --- a/t/t3602-rm-sparse-checkout.sh +++ b/t/t3602-rm-sparse-checkout.sh @@ -79,8 +79,8 @@ test_expect_success 'do not advice about sparse entries when they do not match t git reset --hard && git sparse-checkout set a && test_must_fail git rm nonexistent 2>stderr && - grep "fatal: pathspec .nonexistent. did not match any files" stderr && - ! grep -F -f sparse_error_header stderr + test_grep "fatal: pathspec .nonexistent. did not match any files" stderr && + test_grep ! -F -f sparse_error_header stderr ' test_expect_success 'do not warn about sparse entries when pathspec matches dense entries' ' diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh index 53a4782267b705..64ad7a2949bf0c 100755 --- a/t/t3705-add-sparse-checkout.sh +++ b/t/t3705-add-sparse-checkout.sh @@ -149,8 +149,8 @@ test_expect_success 'git add --dry-run --ignore-missing warn on sparse path' ' test_expect_success 'do not advice about sparse entries when they do not match the pathspec' ' setup_sparse_entry && test_must_fail git add nonexistent 2>stderr && - grep "fatal: pathspec .nonexistent. did not match any files" stderr && - ! grep -F -f sparse_error_header stderr + test_grep "fatal: pathspec .nonexistent. did not match any files" stderr && + test_grep ! -F -f sparse_error_header stderr ' test_expect_success 'do not warn when pathspec matches dense entries' ' @@ -184,19 +184,19 @@ test_expect_success 'git add fails outside of sparse-checkout definition' ' git -c core.autocrlf=input add --sparse sparse_entry 2>stderr && test_must_be_empty stderr && git ls-files --stage >actual && - grep "^100644 .*sparse_entry\$" actual && + test_grep "^100644 .*sparse_entry\$" actual && git add --sparse --chmod=+x sparse_entry 2>stderr && test_must_be_empty stderr && git ls-files --stage >actual && - grep "^100755 .*sparse_entry\$" actual && + test_grep "^100755 .*sparse_entry\$" actual && git reset && # This will print a message over stderr on Windows. git add --sparse --renormalize sparse_entry && git status --porcelain >actual && - grep "^M sparse_entry\$" actual + test_grep "^M sparse_entry\$" actual ' test_expect_success 'add obeys advice.updateSparsePath' ' diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index e3cf0ffbe59c44..d3ddf076c48458 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -535,9 +535,9 @@ test_expect_success 'invalid header entry config & fsck' ' git fsck && git -c fsck.extraHeaderEntry=warn fsck 2>err && - grep "warning .*extraHeaderEntry:" err && + test_grep "warning .*extraHeaderEntry:" err && test_must_fail git -c fsck.extraHeaderEntry=error 2>err fsck && - grep "error .* extraHeaderEntry:" err + test_grep "error .* extraHeaderEntry:" err ' cat >tag.sig <out-l1 && git format-patch --stdout HEAD^ >out-l2 && - grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 && - grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 && - grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 && - grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2 + test_grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 && + test_grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 && + test_grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 && + test_grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2 ' test_expect_success 'format-patch output (UTF-8)' ' @@ -92,10 +92,10 @@ test_expect_success 'format-patch output (UTF-8)' ' git format-patch --stdout main..HEAD^ >out-u1 && git format-patch --stdout HEAD^ >out-u2 && - grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && - grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && - grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2 + test_grep "^Content-Type: text/plain; charset=UTF-8" out-u1 && + test_grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u1 && + test_grep "^Content-Type: text/plain; charset=UTF-8" out-u2 && + test_grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD=20=C3=B3=C3=BA?=" out-u2 ' test_expect_success 'rebase (U/U)' ' diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index ecc35aae82a5fe..53328b84755511 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -20,21 +20,21 @@ test_expect_success 'setup' ' test_expect_success 'usage on cmd and subcommand invalid option' ' test_expect_code 129 git stash --invalid-option 2>usage && - grep "or: git stash" usage && + test_grep "or: git stash" usage && test_expect_code 129 git stash push --invalid-option 2>usage && - ! grep "or: git stash" usage + test_grep ! "or: git stash" usage ' test_expect_success 'usage on main command -h emits a summary of subcommands' ' test_expect_code 129 git stash -h >usage && - grep -F "usage: git stash list" usage && - grep -F "or: git stash show" usage + test_grep -F "usage: git stash list" usage && + test_grep -F "or: git stash show" usage ' test_expect_success 'usage for subcommands should emit subcommand usage' ' test_expect_code 129 git stash push -h >usage && - grep -F "usage: git stash [push" usage + test_grep -F "usage: git stash [push" usage ' diff_cmp () { @@ -965,7 +965,7 @@ test_expect_success 'store updates stash ref and reflog' ' test $(git rev-parse stash) = $STASH_ID && git reflog --format=%H stash| grep $STASH_ID && git stash pop && - grep quux bazzy + test_grep quux bazzy ' test_expect_success 'handle stash specification with spaces' ' @@ -977,7 +977,7 @@ test_expect_success 'handle stash specification with spaces' ' echo cow >file && git stash && git stash apply "stash@{$stamp}" && - grep pig file + test_grep pig file ' test_expect_success 'setup stash with index and worktree changes' ' @@ -1500,9 +1500,9 @@ test_expect_success 'stash export can accept specified stashes' ' test_expect_success 'stash export rejects invalid arguments' ' test_must_fail git stash export --print --to-ref refs/heads/invalid 2>err && - grep "exactly one of --print and --to-ref is required" err && + test_grep "exactly one of --print and --to-ref is required" err && test_must_fail git stash export 2>err2 && - grep "exactly one of --print and --to-ref is required" err2 + test_grep "exactly one of --print and --to-ref is required" err2 ' test_expect_success 'stash can import and export zero stashes' ' @@ -1519,7 +1519,7 @@ test_expect_success 'stash rejects invalid attempts to import commits' ' git stash import foo && test_must_fail git stash import HEAD 2>output && oid=$(git rev-parse HEAD) && - grep "$oid is not a valid exported stash commit" output && + test_grep "$oid is not a valid exported stash commit" output && test_cmp_rev stash@{0} t-stash0 && git checkout --orphan orphan && @@ -1527,7 +1527,7 @@ test_expect_success 'stash rejects invalid attempts to import commits' ' git update-ref refs/heads/orphan "$(cat fake-commit)" && oid=$(git rev-parse HEAD) && test_must_fail git stash import orphan 2>output && - grep "found stash commit $oid without expected prefix" output && + test_grep "found stash commit $oid without expected prefix" output && test_cmp_rev stash@{0} t-stash0 && git checkout --orphan orphan2 && @@ -1535,7 +1535,7 @@ test_expect_success 'stash rejects invalid attempts to import commits' ' git update-ref refs/heads/orphan2 "$(cat fake-commit)" && oid=$(git rev-parse HEAD) && test_must_fail git stash import orphan2 2>output && - grep "found root commit $oid with invalid data" output && + test_grep "found root commit $oid with invalid data" output && test_cmp_rev stash@{0} t-stash0 ' @@ -1741,7 +1741,7 @@ test_expect_success 'submodules does not affect the branch recorded in stash mes git stash push -m "custom stash for work_branch" && git stash list >../actual_stash_list.txt && - grep "On work_branch: custom stash for work_branch" ../actual_stash_list.txt + test_grep "On work_branch: custom stash for work_branch" ../actual_stash_list.txt ) ' @@ -1751,7 +1751,7 @@ test_expect_success SANITIZE_LEAK 'stash show handles -- without leaking' ' test_expect_success 'controlled error return on unrecognized option' ' test_expect_code 129 git stash show -p --invalid 2>usage && - grep -e "^usage: git stash show" usage + test_grep -e "^usage: git stash show" usage ' test_expect_success 'stash.index=true implies --index' ' diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh index 90a4ff2c102cef..adc45c7073c777 100755 --- a/t/t3904-stash-patch.sh +++ b/t/t3904-stash-patch.sh @@ -103,8 +103,8 @@ test_expect_success 'stash -p with split hunk' ' printf "%s\n" s n y q | git stash -p 2>error && test_must_be_empty error && - grep "added line 1" test && - ! grep "added line 2" test + test_grep "added line 1" test && + test_grep ! "added line 2" test ' test_expect_success 'stash -p not confused by GIT_PAGER_IN_USE' ' diff --git a/t/t3908-stash-in-worktree.sh b/t/t3908-stash-in-worktree.sh index 2b2b366ef94b7c..e7ae838bb21eee 100755 --- a/t/t3908-stash-in-worktree.sh +++ b/t/t3908-stash-in-worktree.sh @@ -21,7 +21,7 @@ test_expect_success 'apply in subdirectory' ' git stash && git stash apply >out ) && - grep "\.\.\/initial\.t" wt/subdir/out + test_grep "\.\.\/initial\.t" wt/subdir/out ' test_done diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index 32b14e3a714b0b..74dec7d34acede 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -84,7 +84,7 @@ test_expect_success 'git diff-files --no-patch --patch shows the patch' ' test_expect_success 'git diff-files --no-patch --patch-with-raw shows the patch and raw data' ' git diff-files --no-patch --patch-with-raw >actual && - grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual && + test_grep -q "^:100644 100755 .* $ZERO_OID M path0\$" actual && tail -n +4 actual >actual-patch && compare_diff_patch expected actual-patch ' diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh index 4f520d600de495..ad474100affa0b 100755 --- a/t/t4001-diff-rename.sh +++ b/t/t4001-diff-rename.sh @@ -189,7 +189,7 @@ test_expect_success 'setup for many rename source candidates' ' M path1 EOF test_cmp expect actual.munged && - grep warning actual.err + test_grep warning actual.err ' test_expect_success 'rename pretty print with nothing in common' ' @@ -258,7 +258,7 @@ test_expect_success 'diff-tree -l0 defaults to a big rename limit, not zero' ' git diff-tree -M -l0 HEAD HEAD^ >actual && # Verify that a rename from myotherfile to myfile was detected - grep "myotherfile.*myfile" actual + test_grep "myotherfile.*myfile" actual ' test_expect_success 'basename similarity vs best similarity' ' diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index ac837b6c9ecd7b..4103bd69890692 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -140,7 +140,7 @@ test_expect_success SYMLINKS 'diff symlinks with non-existing targets' ' ln -s narf pinky && ln -s take\ over brain && test_must_fail git diff --no-index pinky brain >output 2>output.err && - grep narf output && + test_grep narf output && test_must_be_empty output.err ' diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index d35695f5b0bcf2..b7a382c88130ec 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -778,7 +778,7 @@ test_expect_success 'diff.{src,dst}Prefix ignored with --default-prefix' ' test_expect_success 'diff --no-renames cannot be abbreviated' ' test_expect_code 129 git diff --no-rename >actual 2>error && test_must_be_empty actual && - grep "invalid option: --no-rename" error + test_grep "invalid option: --no-rename" error ' test_done diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 0b89d127b5a95d..4d4c8b2712b51d 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -119,17 +119,17 @@ test_expect_success 'format-patch --ignore-if-in-upstream result applies' ' test_expect_success 'commit did not screw up the log message' ' git cat-file commit side >actual && - grep "^Side .* with .* backslash-n" actual + test_grep "^Side .* with .* backslash-n" actual ' test_expect_success 'format-patch did not screw up the log message' ' - grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 && - grep "^Subject: .*Side changes #3 with .* backslash-n" patch1 + test_grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 && + test_grep "^Subject: .*Side changes #3 with .* backslash-n" patch1 ' test_expect_success 'replay did not screw up the log message' ' git cat-file commit rebuild-1 >actual && - grep "^Side .* with .* backslash-n" actual + test_grep "^Side .* with .* backslash-n" actual ' test_expect_success 'format-patch empty commit' ' @@ -241,9 +241,9 @@ test_expect_failure 'configuration To: header (rfc2047)' ' # check_patch : Verify that looks like a half-sane # patch email to avoid a false positive with !grep check_patch () { - grep -e "^From:" "$1" && - grep -e "^Date:" "$1" && - grep -e "^Subject:" "$1" + test_grep -e "^From:" "$1" && + test_grep -e "^Date:" "$1" && + test_grep -e "^Subject:" "$1" } test_expect_success 'format.from=false' ' @@ -508,41 +508,41 @@ test_expect_success 'cover letter config commitlistformat not set' ' test_expect_success 'reroll count' ' rm -fr patches && git format-patch -o patches --cover-letter --reroll-count 4 main..side >list && - ! grep -v "^patches/v4-000[0-3]-" list && + test_grep ! -v "^patches/v4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && - ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects + test_grep ! -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects ' test_expect_success 'reroll count (-v)' ' rm -fr patches && git format-patch -o patches --cover-letter -v4 main..side >list && - ! grep -v "^patches/v4-000[0-3]-" list && + test_grep ! -v "^patches/v4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && - ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects + test_grep ! -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects ' test_expect_success 'reroll count (-v) with a fractional number' ' rm -fr patches && git format-patch -o patches --cover-letter -v4.4 main..side >list && - ! grep -v "^patches/v4.4-000[0-3]-" list && + test_grep ! -v "^patches/v4.4-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && - ! grep -v "^Subject: \[PATCH v4.4 [0-3]/3\] " subjects + test_grep ! -v "^Subject: \[PATCH v4.4 [0-3]/3\] " subjects ' test_expect_success 'reroll (-v) count with a non number' ' rm -fr patches && git format-patch -o patches --cover-letter -v4rev2 main..side >list && - ! grep -v "^patches/v4rev2-000[0-3]-" list && + test_grep ! -v "^patches/v4rev2-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && - ! grep -v "^Subject: \[PATCH v4rev2 [0-3]/3\] " subjects + test_grep ! -v "^Subject: \[PATCH v4rev2 [0-3]/3\] " subjects ' test_expect_success 'reroll (-v) count with a non-pathname character' ' rm -fr patches && git format-patch -o patches --cover-letter -v4---..././../--1/.2// main..side >list && - ! grep -v "patches/v4-\.-\.-\.-1-\.2-000[0-3]-" list && + test_grep ! -v "patches/v4-\.-\.-\.-1-\.2-000[0-3]-" list && sed -n -e "/^Subject: /p" $(cat list) >subjects && - ! grep -v "^Subject: \[PATCH v4---\.\.\./\./\.\./--1/\.2// [0-3]/3\] " subjects + test_grep ! -v "^Subject: \[PATCH v4---\.\.\./\./\.\./--1/\.2// [0-3]/3\] " subjects ' check_threading () { @@ -813,9 +813,9 @@ test_expect_success 'cover-letter inherits diff options' ' git commit -m foo && git format-patch --no-renames --cover-letter -1 && check_patch 0000-cover-letter.patch && - ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch && + test_grep ! "file => foo .* 0 *\$" 0000-cover-letter.patch && git format-patch --cover-letter -1 -M && - grep "file => foo .* 0 *\$" 0000-cover-letter.patch + test_grep "file => foo .* 0 *\$" 0000-cover-letter.patch ' cat >expect <out && - ! grep "notes config message" out && + test_grep ! "notes config message" out && git format-patch -1 --stdout --notes >out && - grep "notes config message" out && + test_grep "notes config message" out && git format-patch -1 --stdout --no-notes >out && - ! grep "notes config message" out && + test_grep ! "notes config message" out && git format-patch -1 --stdout --notes --no-notes >out && - ! grep "notes config message" out && + test_grep ! "notes config message" out && git format-patch -1 --stdout --no-notes --notes >out && - grep "notes config message" out && + test_grep "notes config message" out && test_config format.notes true && git format-patch -1 --stdout >out && - grep "notes config message" out && + test_grep "notes config message" out && git format-patch -1 --stdout --notes >out && - grep "notes config message" out && + test_grep "notes config message" out && git format-patch -1 --stdout --no-notes >out && - ! grep "notes config message" out && + test_grep ! "notes config message" out && git format-patch -1 --stdout --notes --no-notes >out && - ! grep "notes config message" out && + test_grep ! "notes config message" out && git format-patch -1 --stdout --no-notes --notes >out && - grep "notes config message" out + test_grep "notes config message" out ' test_expect_success 'format-patch with multiple notes refs' ' @@ -979,39 +979,39 @@ test_expect_success 'format-patch with multiple notes refs' ' git notes --ref note2 add -m "this is note 2" HEAD && git format-patch -1 --stdout >out && - ! grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep ! "this is note 2" out && git format-patch -1 --stdout --notes=note1 >out && - grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep ! "this is note 2" out && git format-patch -1 --stdout --notes=note2 >out && - ! grep "this is note 1" out && - grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep "this is note 2" out && git format-patch -1 --stdout --notes=note1 --notes=note2 >out && - grep "this is note 1" out && - grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep "this is note 2" out && test_config format.notes note1 && git format-patch -1 --stdout >out && - grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep ! "this is note 2" out && git format-patch -1 --stdout --no-notes >out && - ! grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep ! "this is note 2" out && git format-patch -1 --stdout --notes=note2 >out && - grep "this is note 1" out && - grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep "this is note 2" out && git format-patch -1 --stdout --no-notes --notes=note2 >out && - ! grep "this is note 1" out && - grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep "this is note 2" out && git config --add format.notes note2 && git format-patch -1 --stdout >out && - grep "this is note 1" out && - grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep "this is note 2" out && git format-patch -1 --stdout --no-notes >out && - ! grep "this is note 1" out && - ! grep "this is note 2" out + test_grep ! "this is note 1" out && + test_grep ! "this is note 2" out ' test_expect_success 'format-patch with multiple notes refs in config' ' @@ -1024,26 +1024,26 @@ test_expect_success 'format-patch with multiple notes refs in config' ' git config format.notes note1 && git format-patch -1 --stdout >out && - grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep ! "this is note 2" out && git config format.notes note2 && git format-patch -1 --stdout >out && - ! grep "this is note 1" out && - grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep "this is note 2" out && git config --add format.notes note1 && git format-patch -1 --stdout >out && - grep "this is note 1" out && - grep "this is note 2" out && + test_grep "this is note 1" out && + test_grep "this is note 2" out && git config --replace-all format.notes note1 && git config --add format.notes false && git format-patch -1 --stdout >out && - ! grep "this is note 1" out && - ! grep "this is note 2" out && + test_grep ! "this is note 1" out && + test_grep ! "this is note 2" out && git config --add format.notes note2 && git format-patch -1 --stdout >out && - ! grep "this is note 1" out && - grep "this is note 2" out + test_grep ! "this is note 1" out && + test_grep "this is note 2" out ' echo "fatal: --name-only does not make sense" >expect.name-only @@ -1095,7 +1095,7 @@ test_expect_success 'format-patch -- ' ' git format-patch main..pathspec -- file_a >output && test_cmp expect output && - ! grep file_b *.patch + test_grep ! file_b *.patch ' test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' @@ -1129,14 +1129,14 @@ test_expect_success 'format-patch --signature' ' test_expect_success 'format-patch with format.signature config' ' git config format.signature "config sig" && git format-patch --stdout -1 >output && - grep "config sig" output + test_grep "config sig" output ' test_expect_success 'format-patch --signature overrides format.signature' ' git config format.signature "config sig" && git format-patch --stdout --signature="overrides" -1 >output && - ! grep "config sig" output && - grep "overrides" output + test_grep ! "config sig" output && + test_grep "overrides" output ' test_expect_success 'format-patch --no-signature ignores format.signature' ' @@ -1144,9 +1144,9 @@ test_expect_success 'format-patch --no-signature ignores format.signature' ' git format-patch --stdout --signature="my sig" --no-signature \ -1 >output && check_patch output && - ! grep "config sig" output && - ! grep "my sig" output && - ! grep "^-- \$" output + test_grep ! "config sig" output && + test_grep ! "my sig" output && + test_grep ! "^-- \$" output ' test_expect_success 'format-patch --signature --cover-letter' ' @@ -1161,20 +1161,20 @@ test_expect_success 'format.signature="" suppresses signatures' ' git config format.signature "" && git format-patch --stdout -1 >output && check_patch output && - ! grep "^-- \$" output + test_grep ! "^-- \$" output ' test_expect_success 'format-patch --no-signature suppresses signatures' ' git config --unset-all format.signature && git format-patch --stdout --no-signature -1 >output && check_patch output && - ! grep "^-- \$" output + test_grep ! "^-- \$" output ' test_expect_success 'format-patch --signature="" suppresses signatures' ' git format-patch --stdout --signature="" -1 >output && check_patch output && - ! grep "^-- \$" output + test_grep ! "^-- \$" output ' test_expect_success 'prepare mail-signature input' ' @@ -1213,7 +1213,7 @@ test_expect_success '--no-signature suppresses format.signaturefile ' ' test_config format.signaturefile mail-signature && git format-patch --stdout --no-signature -1 >output && check_patch output && - ! grep "^-- \$" output + test_grep ! "^-- \$" output ' test_expect_success '--signature-file overrides format.signaturefile' ' @@ -1235,7 +1235,7 @@ test_expect_success '--signature overrides format.signaturefile' ' test_config format.signaturefile mail-signature && git format-patch --stdout --signature="my sig" -1 >output && check_patch output && - grep "my sig" output + test_grep "my sig" output ' test_expect_success TTY 'format-patch --stdout paginates' ' @@ -2001,10 +2001,10 @@ body" && test_config format.coverFromDescription default && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description default' ' @@ -2013,10 +2013,10 @@ test_expect_success 'cover letter with --cover-from-description default' ' body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description default main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with format.coverFromDescription = none' ' @@ -2026,10 +2026,10 @@ body" && test_config format.coverFromDescription none && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - ! grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep ! "^body$" actual ' test_expect_success 'cover letter with --cover-from-description none' ' @@ -2038,10 +2038,10 @@ test_expect_success 'cover letter with --cover-from-description none' ' body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description none main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - ! grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep ! "^body$" actual ' test_expect_success 'cover letter with format.coverFromDescription = message' ' @@ -2051,10 +2051,10 @@ body" && test_config format.coverFromDescription message && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description message' ' @@ -2063,10 +2063,10 @@ test_expect_success 'cover letter with --cover-from-description message' ' body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description message main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with format.coverFromDescription = subject' ' @@ -2076,10 +2076,10 @@ body" && test_config format.coverFromDescription subject && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] config subject$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] config subject$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description subject' ' @@ -2088,10 +2088,10 @@ test_expect_success 'cover letter with --cover-from-description subject' ' body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description subject main >actual && - grep "^Subject: \[PATCH 0/2\] config subject$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] config subject$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description subject (UTF-8 subject line)' ' @@ -2100,8 +2100,8 @@ test_expect_success 'cover letter with --cover-from-description subject (UTF-8 s body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description subject --encode-email-headers main >actual && - grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual && - ! grep "Café" actual + test_grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual && + test_grep ! "Café" actual ' test_expect_success 'cover letter with format.coverFromDescription = auto (short subject line)' ' @@ -2111,10 +2111,10 @@ body" && test_config format.coverFromDescription auto && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] config subject$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] config subject$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description auto (short subject line)' ' @@ -2123,10 +2123,10 @@ test_expect_success 'cover letter with --cover-from-description auto (short subj body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description auto main >actual && - grep "^Subject: \[PATCH 0/2\] config subject$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] config subject$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with format.coverFromDescription = auto (long subject line)' ' @@ -2136,10 +2136,10 @@ body" && test_config format.coverFromDescription auto && git checkout rebuild-1 && git format-patch --stdout --cover-letter main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with --cover-from-description auto (long subject line)' ' @@ -2148,10 +2148,10 @@ test_expect_success 'cover letter with --cover-from-description auto (long subje body" && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description auto main >actual && - grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter with command-line --cover-from-description overrides config' ' @@ -2161,52 +2161,52 @@ body" && test_config format.coverFromDescription none && git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description subject main >actual && - grep "^Subject: \[PATCH 0/2\] config subject$" actual && - ! grep "^\*\*\* BLURB HERE \*\*\*$" actual && - ! grep "^config subject$" actual && - grep "^body$" actual + test_grep "^Subject: \[PATCH 0/2\] config subject$" actual && + test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual && + test_grep ! "^config subject$" actual && + test_grep "^body$" actual ' test_expect_success 'cover letter using branch description (1)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter main >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter using branch description (2)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter using branch description (3)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter ^main rebuild-1 >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter using branch description (4)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter main.. >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter using branch description (5)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 HEAD >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter using branch description (6)' ' git checkout rebuild-1 && test_config branch.rebuild-1.description hello && git format-patch --stdout --cover-letter -2 >actual && - grep hello actual + test_grep hello actual ' test_expect_success 'cover letter with --description-file' ' @@ -2219,8 +2219,8 @@ test_expect_success 'cover letter with --description-file' ' git checkout rebuild-1 && git format-patch --stdout --cover-letter --cover-from-description auto \ --description-file description.txt main >actual && - grep "^Subject: \[PATCH 0/2\] subject from file$" actual && - grep "^body from file$" actual + test_grep "^Subject: \[PATCH 0/2\] subject from file$" actual && + test_grep "^body from file$" actual ' test_expect_success 'cover letter with nothing' ' @@ -2467,7 +2467,7 @@ test_expect_success 'format-patch errors out when history involves criss-cross' test_expect_success 'format-patch format.useAutoBase whenAble history involves criss-cross' ' test_config format.useAutoBase whenAble && git format-patch -1 >patch && - ! grep "^base-commit:" patch + test_grep ! "^base-commit:" patch ' test_expect_success 'format-patch format.useAutoBase option' ' @@ -2502,13 +2502,13 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' ' test_expect_success 'format-patch --no-base overrides format.useAutoBase' ' test_config format.useAutoBase true && git format-patch --stdout --no-base -1 >patch && - ! grep "^base-commit:" patch + test_grep ! "^base-commit:" patch ' test_expect_success 'format-patch --no-base overrides format.useAutoBase whenAble' ' test_config format.useAutoBase whenAble && git format-patch --stdout --no-base -1 >patch && - ! grep "^base-commit:" patch + test_grep ! "^base-commit:" patch ' test_expect_success 'format-patch --base with --attach' ' @@ -2521,7 +2521,7 @@ test_expect_success 'format-patch --base with --attach' ' test_expect_success 'format-patch --attach cover-letter only is non-multipart' ' test_when_finished "rm -fr patches" && git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 && - ! grep -E "^--+mimemime" patches/0000*.patch && + test_grep ! -E "^--+mimemime" patches/0000*.patch && grep -E "^--+mimemime$" patches/0001*.patch >output && test_line_count = 2 output && grep -E "^--+mimemime--$" patches/0001*.patch >output && @@ -2533,7 +2533,7 @@ test_expect_success 'format-patch with format.attach' ' separator=attachment-separator && test_config format.attach "$separator" && filename=$(git format-patch -o patches -1) && - grep "^Content-Type: multipart/.*$separator" "$filename" + test_grep "^Content-Type: multipart/.*$separator" "$filename" ' test_expect_success 'format-patch with format.attach=disabled' ' @@ -2543,7 +2543,7 @@ test_expect_success 'format-patch with format.attach=disabled' ' test_config format.attach "" && filename=$(git format-patch -o patches -1) && # The output should not even declare content type for text/plain. - ! grep "^Content-Type: multipart/" "$filename" + test_grep ! "^Content-Type: multipart/" "$filename" ' test_expect_success '-c format.mboxrd format-patch' ' @@ -2674,23 +2674,23 @@ test_expect_success 'interdiff: explicit --no-cover-letter defeats implied --cov test_expect_success 'format-patch does not respect diff.noprefix' ' git -c diff.noprefix format-patch -1 --stdout >actual && - grep "^--- a/blorp" actual + test_grep "^--- a/blorp" actual ' test_expect_success 'format-patch respects format.noprefix' ' git -c format.noprefix format-patch -1 --stdout >actual && - grep "^--- blorp" actual + test_grep "^--- blorp" actual ' test_expect_success 'format.noprefix=false' ' git -c format.noprefix=false format-patch -1 --stdout >actual && - grep "^--- a/blorp" actual + test_grep "^--- a/blorp" actual ' test_expect_success 'format-patch --default-prefix overrides format.noprefix' ' git -c format.noprefix \ format-patch -1 --default-prefix --stdout >actual && - grep "^--- a/blorp" actual + test_grep "^--- a/blorp" actual ' test_expect_success 'errors on format.noprefix which is not boolean' ' diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index b691d2947943c8..6e7ba8abf682b3 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -638,14 +638,14 @@ test_expect_success 'check mixed spaces and tabs in indent' ' # This is indented with SP HT SP. echo " foo();" >x && test_must_fail git diff --check >check && - grep "space before tab in indent" check + test_grep "space before tab in indent" check ' test_expect_success 'check mixed tabs and spaces in indent' ' # This is indented with HT SP HT. echo " foo();" >x && test_must_fail git diff --check >check && - grep "space before tab in indent" check + test_grep "space before tab in indent" check ' test_expect_success 'check with no whitespace errors' ' @@ -891,14 +891,14 @@ test_expect_success 'line numbers in --check output are correct' ' echo "" >x && echo "foo(); " >>x && test_must_fail git diff --check >check && - grep "x:2:" check + test_grep "x:2:" check ' test_expect_success 'checkdiff detects new trailing blank lines (1)' ' echo "foo();" >x && echo "" >>x && test_must_fail git diff --check >check && - grep "new blank line" check + test_grep "new blank line" check ' test_expect_success 'checkdiff detects new trailing blank lines (2)' ' @@ -906,7 +906,7 @@ test_expect_success 'checkdiff detects new trailing blank lines (2)' ' git add x && test_write_lines a "" "" "" "" >x && test_must_fail git diff --check >check && - grep "new blank line" check + test_grep "new blank line" check ' test_expect_success 'checkdiff allows new blank lines' ' @@ -1018,7 +1018,7 @@ test_expect_success 'combined diff with autocrlf conversion' ' git diff >actual.raw && sed -e "1,/^@@@/d" actual.raw >actual && - ! grep "^-" actual + test_grep ! "^-" actual ' @@ -2166,8 +2166,8 @@ test_expect_success 'move detection with submodules' ' # no move detection as the moved line is across repository boundaries. test_decode_color decoded_actual && - ! grep BGREEN decoded_actual && - ! grep BRED decoded_actual && + test_grep ! BGREEN decoded_actual && + test_grep ! BRED decoded_actual && # nor did we mess with it another way git diff --submodule=diff --color >expect.raw && diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh index c2863c99b71fac..5ec6f5c612e004 100755 --- a/t/t4017-diff-retval.sh +++ b/t/t4017-diff-retval.sh @@ -139,7 +139,7 @@ test_expect_success 'check honors conflict marker length' ' test_expect_success 'option errors are not confused by --exit-code' ' test_must_fail git diff --exit-code --nonsense 2>err && - grep '^usage:' err + test_grep '^usage:' err ' for option in --exit-code --quiet diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index e026fac1f40903..b538b715f5a54f 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -115,7 +115,7 @@ for i in $(git ls-files) do test_expect_success "hunk header: $i" " git diff -U1 $i >actual && - grep '@@ .* @@.*RIGHT' actual + test_grep '@@ .* @@.*RIGHT' actual " done diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh index 4001dacee39193..939ec8a0b4a198 100755 --- a/t/t4019-diff-wserror.sh +++ b/t/t4019-diff-wserror.sh @@ -251,8 +251,8 @@ test_expect_success 'trailing empty lines (1)' ' rm -f .gitattributes && test_must_fail git diff --check >output && - grep "new blank line at" output && - grep "trailing whitespace" output + test_grep "new blank line at" output && + test_grep "trailing whitespace" output ' @@ -280,8 +280,8 @@ test_expect_success 'do not color trailing cr in context' ' git add G && echo BBBQ | tr Q "\015" >>G && git diff --color G | tr "\015" Q >output && - grep "BBB.*${blue_grep}Q" output && - grep "AAA.*\[mQ" output + test_grep "BBB.*${blue_grep}Q" output && + test_grep "AAA.*\[mQ" output ' diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh index 7ec5854f74d651..93d37230c61e19 100755 --- a/t/t4020-diff-external.sh +++ b/t/t4020-diff-external.sh @@ -34,13 +34,13 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment' ' test_expect_success 'GIT_EXTERNAL_DIFF environment should apply only to diff' ' GIT_EXTERNAL_DIFF=echo git log -p -1 HEAD >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' ' GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' @@ -86,13 +86,13 @@ test_expect_success 'diff.external' ' test_expect_success 'diff.external should apply only to diff' ' test_config diff.external echo && git log -p -1 HEAD >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' test_expect_success 'diff.external and --no-ext-diff' ' test_config diff.external echo && git diff --no-ext-diff >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' test_expect_success 'diff attribute' ' @@ -113,13 +113,13 @@ test_expect_success 'diff attribute' ' test_expect_success 'diff attribute should apply only to diff' ' git log -p -1 HEAD >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' test_expect_success 'diff attribute and --no-ext-diff' ' git diff --no-ext-diff >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' @@ -140,13 +140,13 @@ test_expect_success 'diff attribute' ' test_expect_success 'diff attribute should apply only to diff' ' git log -p -1 HEAD >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' test_expect_success 'diff attribute and --no-ext-diff' ' git diff --no-ext-diff >out && - grep "^diff --git a/file b/file" out + test_grep "^diff --git a/file b/file" out ' @@ -178,7 +178,7 @@ test_expect_success 'attributes trump GIT_EXTERNAL_DIFF and diff.external' ' test_expect_success 'no diff with -diff' ' echo >.gitattributes "file -diff" && git diff >out && - grep Binary out + test_grep Binary out ' check_external_diff () { diff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh index 9be65fd4440a68..35793f30080f89 100755 --- a/t/t4021-format-patch-numbered.sh +++ b/t/t4021-format-patch-numbered.sh @@ -37,17 +37,17 @@ test_no_numbered() { } test_single_cover_letter_numbered() { - grep "^Subject: \[PATCH 0/1\]" $1 && - grep "^Subject: \[PATCH 1/1\]" $1 + test_grep "^Subject: \[PATCH 0/1\]" $1 && + test_grep "^Subject: \[PATCH 1/1\]" $1 } test_single_numbered() { - grep "^Subject: \[PATCH 1/1\]" $1 + test_grep "^Subject: \[PATCH 1/1\]" $1 } test_numbered() { - grep "^Subject: \[PATCH 1/2\]" $1 && - grep "^Subject: \[PATCH 2/2\]" $1 + test_grep "^Subject: \[PATCH 1/2\]" $1 && + test_grep "^Subject: \[PATCH 2/2\]" $1 } test_expect_success 'single patch defaults to no numbers' ' @@ -94,7 +94,7 @@ test_expect_success 'format.numbered && --no-numbered' ' test_expect_success 'format.numbered && --keep-subject' ' git format-patch --keep-subject --stdout HEAD^ >patch4a && - grep "^Subject: Third" patch4a + test_grep "^Subject: Third" patch4a ' @@ -123,7 +123,7 @@ test_expect_success 'format.numbered = auto && --no-numbered' ' test_expect_success '--start-number && --numbered' ' git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 && - grep "^Subject: \[PATCH 3/3\]" patch8 + test_grep "^Subject: \[PATCH 3/3\]" patch8 ' test_expect_success 'single patch with cover-letter defaults to numbers' ' diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh index 6fed993ea0b34d..b5c1b6868f93ee 100755 --- a/t/t4022-diff-rewrite.sh +++ b/t/t4022-diff-rewrite.sh @@ -58,13 +58,13 @@ test_expect_success 'suppress deletion diff with -D' ' test_expect_success 'show deletion diff with -B' ' git diff -B -- test >actual && - grep "Linus Torvalds" actual + test_grep "Linus Torvalds" actual ' test_expect_success 'suppress deletion diff with -B -D' ' git diff -B -D -- test >actual && - grep -v "Linus Torvalds" actual + test_grep -v "Linus Torvalds" actual ' test_expect_success 'prepare a file that ends with an incomplete line' ' @@ -82,19 +82,19 @@ test_expect_success 'rewrite the middle 90% of sequence file and terminate with test_expect_success 'confirm that sequence file is considered a rewrite' ' git diff -B seq >res && - grep "dissimilarity index" res + test_grep "dissimilarity index" res ' test_expect_success 'no newline at eof is on its own line without -B' ' git diff seq >res && - grep "^\\\\ " res && - ! grep "^..*\\\\ " res + test_grep "^\\\\ " res && + test_grep ! "^..*\\\\ " res ' test_expect_success 'no newline at eof is on its own line with -B' ' git diff -B seq >res && - grep "^\\\\ " res && - ! grep "^..*\\\\ " res + test_grep "^\\\\ " res && + test_grep ! "^..*\\\\ " res ' test_done diff --git a/t/t4028-format-patch-mime-headers.sh b/t/t4028-format-patch-mime-headers.sh index a06a7479260fa9..39344cf761c646 100755 --- a/t/t4028-format-patch-mime-headers.sh +++ b/t/t4028-format-patch-mime-headers.sh @@ -17,15 +17,15 @@ test_expect_success 'create commit with utf-8 body' ' test_expect_success 'patch has mime headers' ' rm -f 0001-two.patch && git format-patch HEAD^ && - grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch + test_grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch ' test_expect_success 'patch has mime and extra headers' ' rm -f 0001-two.patch && git config format.headers "x-foo: bar" && git format-patch HEAD^ && - grep -i "x-foo: bar" 0001-two.patch && - grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch + test_grep -i "x-foo: bar" 0001-two.patch && + test_grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch ' test_done diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh index 15e012ccc7c02e..5b31ca02fe7431 100755 --- a/t/t4031-diff-rewrite-binary.sh +++ b/t/t4031-diff-rewrite-binary.sh @@ -29,32 +29,32 @@ test_expect_success 'create binary file with changes' ' test_expect_success 'vanilla diff is binary' ' git diff >diff && - grep "Binary files a/file and b/file differ" diff + test_grep "Binary files a/file and b/file differ" diff ' test_expect_success 'rewrite diff is binary' ' git diff -B >diff && - grep "dissimilarity index" diff && - grep "Binary files a/file and b/file differ" diff + test_grep "dissimilarity index" diff && + test_grep "Binary files a/file and b/file differ" diff ' test_expect_success 'rewrite diff can show binary patch' ' git diff -B --binary >diff && - grep "dissimilarity index" diff && - grep "GIT binary patch" diff + test_grep "dissimilarity index" diff && + test_grep "GIT binary patch" diff ' test_expect_success 'rewrite diff --numstat shows binary changes' ' git diff -B --numstat --summary >diff && - grep -e "- - " diff && - grep " rewrite file" diff + test_grep -e "- - " diff && + test_grep " rewrite file" diff ' test_expect_success 'diff --stat counts binary rewrite as 0 lines' ' git diff -B --stat --summary >diff && - grep "Bin" diff && + test_grep "Bin" diff && test_grep "0 insertions.*0 deletions" diff && - grep " rewrite file" diff + test_grep " rewrite file" diff ' test_expect_success 'setup textconv' ' diff --git a/t/t4033-diff-patience.sh b/t/t4033-diff-patience.sh index 113304dc596034..8002c0f434cf2c 100755 --- a/t/t4033-diff-patience.sh +++ b/t/t4033-diff-patience.sh @@ -10,7 +10,7 @@ test_expect_success '--ignore-space-at-eol with a single appended character' ' printf "a\nbX\nc\n" >post && test_must_fail git diff --no-index \ --patience --ignore-space-at-eol pre post >diff && - grep "^+.*X" diff + test_grep "^+.*X" diff ' test_diff_frobnitz "patience" diff --git a/t/t4036-format-patch-signer-mime.sh b/t/t4036-format-patch-signer-mime.sh index 98d9713d8b2454..f57d3dc9fbdc9f 100755 --- a/t/t4036-format-patch-signer-mime.sh +++ b/t/t4036-format-patch-signer-mime.sh @@ -19,14 +19,14 @@ test_expect_success setup ' test_expect_success 'format normally' ' git format-patch --stdout -1 >output && - ! grep Content-Type output + test_grep ! Content-Type output ' test_expect_success 'format with signoff without funny signer name' ' git format-patch -s --stdout -1 >output && - ! grep Content-Type output + test_grep ! Content-Type output ' @@ -34,7 +34,7 @@ test_expect_success 'format with non ASCII signer name' ' GIT_COMMITTER_NAME="はまの ふにおう" \ git format-patch -s --stdout -1 >output && - grep Content-Type output + test_grep Content-Type output ' diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 2ce26e585c98c1..e11b7113886821 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -100,7 +100,7 @@ test_expect_success 'diagnose truncated file' ' git add file && git commit --amend -C HEAD && git show >out && - grep "diff --cc file" out + test_grep "diff --cc file" out ' test_expect_success 'setup for --cc --raw' ' @@ -118,13 +118,13 @@ test_expect_success 'check --cc --raw with four trees' ' four_trees=$(echo "$trees" | sed -e 4q) && git diff --cc --raw $four_trees $base_tree >out && # Check for four leading colons in the output: - grep "^::::[^:]" out + test_grep "^::::[^:]" out ' test_expect_success 'check --cc --raw with forty trees' ' git diff --cc --raw $trees $base_tree >out && # Check for forty leading colons in the output: - grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out + test_grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out ' test_expect_success 'setup combined ignore spaces' ' diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh index 4838a1df8b4369..117eaede8ab299 100755 --- a/t/t4051-diff-function-context.sh +++ b/t/t4051-diff-function-context.sh @@ -86,15 +86,15 @@ test_expect_success 'setup' ' check_diff changed_hello 'changed function' test_expect_success ' context includes comment' ' - grep "^ .*Hello comment" changed_hello.diff + test_grep "^ .*Hello comment" changed_hello.diff ' test_expect_success ' context includes begin' ' - grep "^ .*Begin of hello" changed_hello.diff + test_grep "^ .*Begin of hello" changed_hello.diff ' test_expect_success ' context includes end' ' - grep "^ .*End of hello" changed_hello.diff + test_grep "^ .*End of hello" changed_hello.diff ' test_expect_success ' context does not include other functions' ' @@ -112,11 +112,11 @@ test_expect_success ' context does not include trailing empty lines' ' check_diff changed_includes 'changed includes' test_expect_success ' context includes begin' ' - grep "^ .*Begin.h" changed_includes.diff + test_grep "^ .*Begin.h" changed_includes.diff ' test_expect_success ' context includes end' ' - grep "^ .*End.h" changed_includes.diff + test_grep "^ .*End.h" changed_includes.diff ' test_expect_success ' context does not include other functions' ' @@ -130,11 +130,11 @@ test_expect_success ' context does not include trailing empty lines' ' check_diff appended 'appended function' test_expect_success ' context includes begin' ' - grep "^[+].*Begin of first part" appended.diff + test_grep "^[+].*Begin of first part" appended.diff ' test_expect_success ' context includes end' ' - grep "^[+].*End of first part" appended.diff + test_grep "^[+].*End of first part" appended.diff ' test_expect_success ' context does not include other functions' ' @@ -144,11 +144,11 @@ test_expect_success ' context does not include other functions' ' check_diff extended 'appended function part' test_expect_success ' context includes begin' ' - grep "^ .*Begin of first part" extended.diff + test_grep "^ .*Begin of first part" extended.diff ' test_expect_success ' context includes end' ' - grep "^[+].*End of second part" extended.diff + test_grep "^[+].*End of second part" extended.diff ' test_expect_success ' context does not include other functions' ' @@ -162,11 +162,11 @@ test_expect_success ' context does not include preceding empty lines' ' check_diff long_common_tail 'change with long common tail and no context' -U0 test_expect_success ' context includes begin' ' - grep "^ .*Begin of first part" long_common_tail.diff + test_grep "^ .*Begin of first part" long_common_tail.diff ' test_expect_success ' context includes end' ' - grep "^ .*End of second part" long_common_tail.diff + test_grep "^ .*End of second part" long_common_tail.diff ' test_expect_success ' context does not include other functions' ' @@ -180,13 +180,13 @@ test_expect_success ' context does not include preceding empty lines' ' check_diff changed_hello_appended 'changed function plus appended function' test_expect_success ' context includes begin' ' - grep "^ .*Begin of hello" changed_hello_appended.diff && - grep "^[+].*Begin of first part" changed_hello_appended.diff + test_grep "^ .*Begin of hello" changed_hello_appended.diff && + test_grep "^[+].*Begin of first part" changed_hello_appended.diff ' test_expect_success ' context includes end' ' - grep "^ .*End of hello" changed_hello_appended.diff && - grep "^[+].*End of first part" changed_hello_appended.diff + test_grep "^ .*End of hello" changed_hello_appended.diff && + test_grep "^[+].*End of first part" changed_hello_appended.diff ' test_expect_success ' context does not include other functions' ' @@ -196,13 +196,13 @@ test_expect_success ' context does not include other functions' ' check_diff changed_hello_dummy 'changed two consecutive functions' test_expect_success ' context includes begin' ' - grep "^ .*Begin of hello" changed_hello_dummy.diff && - grep "^ .*Begin of dummy" changed_hello_dummy.diff + test_grep "^ .*Begin of hello" changed_hello_dummy.diff && + test_grep "^ .*Begin of dummy" changed_hello_dummy.diff ' test_expect_success ' context includes end' ' - grep "^ .*End of hello" changed_hello_dummy.diff && - grep "^ .*End of dummy" changed_hello_dummy.diff + test_grep "^ .*End of hello" changed_hello_dummy.diff && + test_grep "^ .*End of dummy" changed_hello_dummy.diff ' test_expect_success ' overlapping hunks are merged' ' diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh index 15076dfe0dcb07..8e0394cf5afd95 100755 --- a/t/t4053-diff-no-index.sh +++ b/t/t4053-diff-no-index.sh @@ -283,14 +283,14 @@ test_expect_success "diff --no-index -R treats '-' as stdin" ' test_expect_success 'diff --no-index refuses to diff stdin and a directory' ' test_must_fail git diff --no-index -- - a err && - grep "fatal: cannot compare stdin to a directory" err + test_grep "fatal: cannot compare stdin to a directory" err ' test_expect_success PIPE 'diff --no-index refuses to diff a named pipe and a directory' ' test_when_finished "rm -f pipe" && mkfifo pipe && test_must_fail git diff --no-index -- pipe a 2>err && - grep "fatal: cannot compare a named pipe to a directory" err + test_grep "fatal: cannot compare a named pipe to a directory" err ' test_expect_success PIPE,SYMLINKS 'diff --no-index reads from pipes' ' diff --git a/t/t4063-diff-blobs.sh b/t/t4063-diff-blobs.sh index 50fdb5ea529234..08bfce377f7949 100755 --- a/t/t4063-diff-blobs.sh +++ b/t/t4063-diff-blobs.sh @@ -10,16 +10,16 @@ run_diff () { } check_index () { - grep "^index $1\\.\\.$2" diff + test_grep "^index $1\\.\\.$2" diff } check_mode () { - grep "^old mode $1" diff && - grep "^new mode $2" diff + test_grep "^old mode $1" diff && + test_grep "^new mode $2" diff } check_paths () { - grep "^diff --git a/$1 b/$2" diff + test_grep "^diff --git a/$1 b/$2" diff } test_expect_success 'create some blobs' ' @@ -47,7 +47,7 @@ test_expect_success 'sha1 diff uses arguments as paths' ' check_paths $sha1_one $sha1_two ' test_expect_success 'sha1 diff has no mode change' ' - ! grep mode diff + test_grep ! mode diff ' test_expect_success 'diff by tree:path (run)' ' diff --git a/t/t4065-diff-anchored.sh b/t/t4065-diff-anchored.sh index b3f510f040ec3b..9f06ac65be3a36 100755 --- a/t/t4065-diff-anchored.sh +++ b/t/t4065-diff-anchored.sh @@ -10,11 +10,11 @@ test_expect_success '--anchored' ' # normally, c is moved to produce the smallest diff test_expect_code 1 git diff --no-index pre post >diff && - grep "^+c" diff && + test_grep "^+c" diff && # with anchor, a is moved test_expect_code 1 git diff --no-index --anchored=c pre post >diff && - grep "^+a" diff + test_grep "^+a" diff ' test_expect_success '--anchored multiple' ' @@ -23,13 +23,13 @@ test_expect_success '--anchored multiple' ' # with 1 anchor, c is not moved, but f is moved test_expect_code 1 git diff --no-index --anchored=c pre post >diff && - grep "^+a" diff && # a is moved instead of c - grep "^+f" diff && + test_grep "^+a" diff && # a is moved instead of c + test_grep "^+f" diff && # with 2 anchors, c and f are not moved test_expect_code 1 git diff --no-index --anchored=c --anchored=f pre post >diff && - grep "^+a" diff && - grep "^+d" diff # d is moved instead of f + test_grep "^+a" diff && + test_grep "^+d" diff # d is moved instead of f ' test_expect_success '--anchored with nonexistent line has no effect' ' @@ -37,7 +37,7 @@ test_expect_success '--anchored with nonexistent line has no effect' ' printf "c\na\nb\n" >post && test_expect_code 1 git diff --no-index --anchored=x pre post >diff && - grep "^+c" diff + test_grep "^+c" diff ' test_expect_success '--anchored with non-unique line has no effect' ' @@ -45,7 +45,7 @@ test_expect_success '--anchored with non-unique line has no effect' ' printf "c\na\nb\nc\nd\ne\n" >post && test_expect_code 1 git diff --no-index --anchored=c pre post >diff && - grep "^+c" diff + test_grep "^+c" diff ' test_expect_success 'diff still produced with impossible multiple --anchored' ' @@ -66,16 +66,16 @@ test_expect_success 'later algorithm arguments override earlier ones' ' printf "c\na\nb\n" >post && test_expect_code 1 git diff --no-index --patience --anchored=c pre post >diff && - grep "^+a" diff && + test_grep "^+a" diff && test_expect_code 1 git diff --no-index --anchored=c --patience pre post >diff && - grep "^+c" diff && + test_grep "^+c" diff && test_expect_code 1 git diff --no-index --histogram --anchored=c pre post >diff && - grep "^+a" diff && + test_grep "^+a" diff && test_expect_code 1 git diff --no-index --anchored=c --histogram pre post >diff && - grep "^+c" diff + test_grep "^+c" diff ' test_expect_success '--anchored works with other commands like "git show"' ' @@ -88,7 +88,7 @@ test_expect_success '--anchored works with other commands like "git show"' ' # with anchor, a is moved git show --patience --anchored=c >diff && - grep "^+a" diff + test_grep "^+a" diff ' test_done diff --git a/t/t4067-diff-partial-clone.sh b/t/t4067-diff-partial-clone.sh index 30813109ac044e..142abdf74ac16d 100755 --- a/t/t4067-diff-partial-clone.sh +++ b/t/t4067-diff-partial-clone.sh @@ -70,9 +70,9 @@ test_expect_success 'diff skips same-OID blobs' ' # Ensure that only a and another-a are fetched. GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD && - grep "want $(cat hash-old-a)" trace && - grep "want $(cat hash-new-a)" trace && - ! grep "want $(cat hash-b)" trace + test_grep "want $(cat hash-old-a)" trace && + test_grep "want $(cat hash-new-a)" trace && + test_grep ! "want $(cat hash-b)" trace ' test_expect_success 'when fetching missing objects, diff skips GITLINKs' ' @@ -103,8 +103,8 @@ test_expect_success 'when fetching missing objects, diff skips GITLINKs' ' # Ensure that a and another-a are fetched, and check (by successful # execution of the diff) that no invalid OIDs are sent. GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD && - grep "want $(cat hash-old-a)" trace && - grep "want $(cat hash-new-a)" trace + test_grep "want $(cat hash-old-a)" trace && + test_grep "want $(cat hash-new-a)" trace ' test_expect_success 'diff with rename detection batches blobs' ' @@ -127,7 +127,7 @@ test_expect_success 'diff with rename detection batches blobs' ' # Ensure that there is exactly 1 negotiation by checking that there is # only 1 "done" line sent. ("done" marks the end of negotiation.) GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --raw -M HEAD^ HEAD >out && - grep ":100644 100644.*R[0-9][0-9][0-9].*b.*c" out && + test_grep ":100644 100644.*R[0-9][0-9][0-9].*b.*c" out && grep "fetch> done" trace >done_lines && test_line_count = 1 done_lines ' diff --git a/t/t4073-diff-stat-name-width.sh b/t/t4073-diff-stat-name-width.sh index ec5d3c3c1ffc9d..241242064538df 100755 --- a/t/t4073-diff-stat-name-width.sh +++ b/t/t4073-diff-stat-name-width.sh @@ -21,41 +21,41 @@ test_expect_success 'setup' ' test_expect_success 'test name-width long enough for filepath' ' git diff HEAD~1 HEAD --stat --stat-name-width=12 >out && - grep "d你好/f再见 |" out && + test_grep "d你好/f再见 |" out && git diff HEAD~1 HEAD --stat --stat-name-width=11 >out && - grep "d你好/f再见 |" out + test_grep "d你好/f再见 |" out ' test_expect_success 'test name-width not long enough for dir name' ' git diff HEAD~1 HEAD --stat --stat-name-width=10 >out && - grep ".../f再见 |" out && + test_grep ".../f再见 |" out && git diff HEAD~1 HEAD --stat --stat-name-width=9 >out && - grep ".../f再见 |" out + test_grep ".../f再见 |" out ' test_expect_success 'test name-width not long enough for slash' ' git diff HEAD~1 HEAD --stat --stat-name-width=8 >out && - grep "...f再见 |" out + test_grep "...f再见 |" out ' test_expect_success 'test name-width not long enough for file name' ' git diff HEAD~1 HEAD --stat --stat-name-width=7 >out && - grep "...再见 |" out && + test_grep "...再见 |" out && git diff HEAD~1 HEAD --stat --stat-name-width=6 >out && - grep "...见 |" out && + test_grep "...见 |" out && git diff HEAD~1 HEAD --stat --stat-name-width=5 >out && - grep "...见 |" out && + test_grep "...见 |" out && git diff HEAD~1 HEAD --stat --stat-name-width=4 >out && - grep "... |" out + test_grep "... |" out ' test_expect_success 'test name-width minimum length' ' git diff HEAD~1 HEAD --stat --stat-name-width=3 >out && - grep "... |" out && + test_grep "... |" out && git diff HEAD~1 HEAD --stat --stat-name-width=2 >out && - grep "... |" out && + test_grep "... |" out && git diff HEAD~1 HEAD --stat --stat-name-width=1 >out && - grep "... |" out + test_grep "... |" out ' test_done diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh index f2d41e06bcdd63..bdd4ccf9e31cbd 100755 --- a/t/t4103-apply-binary.sh +++ b/t/t4103-apply-binary.sh @@ -181,7 +181,7 @@ test_expect_success PERL_TEST_HELPERS 'reject truncated binary diff' ' do_reset && test_must_fail git apply patch.trunc 2>err && line=$(awk "END { print NR + 1 }" patch.trunc) && - grep "error: corrupt binary patch at patch.trunc:$line: " err + test_grep "error: corrupt binary patch at patch.trunc:$line: " err ' test_expect_success 'reject unrecognized binary diff' ' diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh index c960fdf622512f..c7801aec2c3e67 100755 --- a/t/t4120-apply-popt.sh +++ b/t/t4120-apply-popt.sh @@ -18,7 +18,7 @@ test_expect_success setup ' git mv sub süb && echo B >süb/file1 && git diff >patch.escaped && - grep "[\]" patch.escaped && + test_grep "[\]" patch.escaped && rm süb/file1 && rmdir süb ' diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 205d86d05edfec..4c487fb5763123 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -222,8 +222,8 @@ test_expect_success 'trailing whitespace & no newline at the end of file' ' >target && create_patch >patch-file && git apply --whitespace=fix patch-file && - grep "newline$" target && - grep "^$" target + test_grep "newline$" target && + test_grep "^$" target ' test_expect_success 'blank at EOF with --whitespace=fix (1)' ' @@ -287,7 +287,7 @@ test_expect_success 'blank at EOF with --whitespace=warn' ' git checkout one && git apply --whitespace=warn patch 2>error && test_cmp expect one && - grep "new blank line at EOF" error + test_grep "new blank line at EOF" error ' test_expect_success 'blank at EOF with --whitespace=error' ' @@ -300,7 +300,7 @@ test_expect_success 'blank at EOF with --whitespace=error' ' git checkout one && test_must_fail git apply --whitespace=error patch 2>error && test_cmp expect one && - grep "new blank line at EOF" error + test_grep "new blank line at EOF" error ' test_expect_success 'blank but not empty at EOF' ' @@ -313,7 +313,7 @@ test_expect_success 'blank but not empty at EOF' ' git checkout one && git apply --whitespace=warn patch 2>error && test_cmp expect one && - grep "new blank line at EOF" error + test_grep "new blank line at EOF" error ' test_expect_success 'applying beyond EOF requires one non-blank context line' ' diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh index 5eba15fa66b956..c772faea62ea3f 100755 --- a/t/t4128-apply-root.sh +++ b/t/t4128-apply-root.sh @@ -138,7 +138,7 @@ test_expect_success 'apply --directory (delete file)' ' git add some/sub/dir/delfile && git apply --directory=some/sub/dir/ --index patch && git ls-files >out && - ! grep delfile out + test_grep ! delfile out ' cat > patch << 'EOF' diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh index 0b11a8aef4fa12..49ebb51564b667 100755 --- a/t/t4140-apply-ita.sh +++ b/t/t4140-apply-ita.sh @@ -14,11 +14,11 @@ test_expect_success setup ' cat blueprint >test-file && git add -N test-file && git diff >creation-patch && - grep "new file mode 100644" creation-patch && + test_grep "new file mode 100644" creation-patch && rm -f test-file && git diff >deletion-patch && - grep "deleted file mode 100644" deletion-patch && + test_grep "deleted file mode 100644" deletion-patch && git rm -f test-file && test_write_lines 6 >>committed-file && diff --git a/t/t4141-apply-too-large.sh b/t/t4141-apply-too-large.sh index eac6f7e151b562..b114a7adf76995 100755 --- a/t/t4141-apply-too-large.sh +++ b/t/t4141-apply-too-large.sh @@ -16,7 +16,7 @@ test_expect_success EXPENSIVE 'git apply rejects patches that are too large' ' EOF test-tool genzeros } | test_copy_bytes $sz | test_must_fail git apply 2>err && - grep "patch too large" err + test_grep "patch too large" err ' test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 699a81ab5cc6d2..61c3ce90182295 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -580,7 +580,7 @@ test_expect_success 'am --keep really keeps the subject' ' git am --keep patch4 && test_path_is_missing .git/rebase-apply && git cat-file commit HEAD >actual && - grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual + test_grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual ' test_expect_success 'am --keep-non-patch really keeps the non-patch part' ' @@ -590,7 +590,7 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' ' git am --keep-non-patch patch4 && test_path_is_missing .git/rebase-apply && git cat-file commit HEAD >actual && - grep "^\[foo\] third" actual + test_grep "^\[foo\] third" actual ' test_expect_success 'setup am -3' ' @@ -642,7 +642,7 @@ test_expect_success 'am with config am.threeWay overridden by --no-3way' ' ' test_expect_success 'am can rename a file' ' - grep "^rename from" rename.patch && + test_grep "^rename from" rename.patch && rm -fr .git/rebase-apply && git reset --hard && git checkout lorem^0 && @@ -653,7 +653,7 @@ test_expect_success 'am can rename a file' ' ' test_expect_success 'am -3 can rename a file' ' - grep "^rename from" rename.patch && + test_grep "^rename from" rename.patch && rm -fr .git/rebase-apply && git reset --hard && git checkout lorem^0 && @@ -664,7 +664,7 @@ test_expect_success 'am -3 can rename a file' ' ' test_expect_success 'am -3 can rename a file after falling back to 3-way merge' ' - grep "^rename from" rename-add.patch && + test_grep "^rename from" rename-add.patch && rm -fr .git/rebase-apply && git reset --hard && git checkout lorem^0 && @@ -884,7 +884,7 @@ test_expect_success 'am --ignore-date' ' git am --ignore-date patch1 && git cat-file commit HEAD | sed -e "/^\$/q" >head1 && sed -ne "/^author /s/.*> //p" head1 >at && - grep "+0000" at + test_grep "+0000" at ' test_expect_success 'am into an unborn branch' ' @@ -1066,7 +1066,7 @@ test_expect_success 'am --patch-format=mboxrd handles mboxrd' ' INPUT_END git commit -F msg && git -c format.mboxrd format-patch --stdout -1 >mboxrd1 && - grep "^>From could trip up a loose mbox parser" mboxrd1 && + test_grep "^>From could trip up a loose mbox parser" mboxrd1 && git checkout -f first && git am --patch-format=mboxrd mboxrd1 && git cat-file commit HEAD | tail -n4 >out && @@ -1144,21 +1144,21 @@ test_expect_success 'am and .gitattibutes' ' git format-patch --stdout main..HEAD >patches && git reset --hard main && git am patches && - grep "smudged" a.txt && + test_grep "smudged" a.txt && git checkout removal && git reset --hard && git format-patch --stdout main..HEAD >patches && git reset --hard main && git am patches && - grep "clean" a.txt && + test_grep "clean" a.txt && git checkout conflict && git reset --hard && git format-patch --stdout main..HEAD >patches && git reset --hard fourth && test_must_fail git am -3 patches && - grep "<<<<<<<<<<" a.txt + test_grep "<<<<<<<<<<" a.txt ) ' @@ -1196,13 +1196,13 @@ test_expect_success 'invalid when passing the --empty option alone' ' test_expect_success 'a message without a patch is an error (default)' ' test_when_finished "git am --abort || :" && test_must_fail git am empty-commit.patch >err && - grep "Patch is empty" err + test_grep "Patch is empty" err ' test_expect_success 'a message without a patch is an error where an explicit "--empty=stop" is given' ' test_when_finished "git am --abort || :" && test_must_fail git am --empty=stop empty-commit.patch >err && - grep "Patch is empty." err + test_grep "Patch is empty." err ' test_expect_success 'a message without a patch will be skipped when "--empty=drop" is given' ' @@ -1210,7 +1210,7 @@ test_expect_success 'a message without a patch will be skipped when "--empty=dro git rev-parse empty-commit^ >expected && git rev-parse HEAD >actual && test_cmp expected actual && - grep "Skipping: empty commit" output + test_grep "Skipping: empty commit" output ' test_expect_success 'record as an empty commit when meeting e-mail message that lacks a patch' ' @@ -1218,15 +1218,15 @@ test_expect_success 'record as an empty commit when meeting e-mail message that test_path_is_missing .git/rebase-apply && git show empty-commit --format="%B" >expected && git show HEAD --format="%B" >actual && - grep -f actual expected && - grep "Creating an empty commit: empty commit" output + test_grep -f actual expected && + test_grep "Creating an empty commit: empty commit" output ' test_expect_success 'skip an empty patch in the middle of an am session' ' git checkout empty-commit^ && test_must_fail git am empty-commit.patch >out 2>err && - grep "Patch is empty." out && - grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && + test_grep "Patch is empty." out && + test_grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && git am --skip && test_path_is_missing .git/rebase-apply && git rev-parse empty-commit^ >expected && @@ -1237,14 +1237,14 @@ test_expect_success 'skip an empty patch in the middle of an am session' ' test_expect_success 'record an empty patch as an empty commit in the middle of an am session' ' git checkout empty-commit^ && test_must_fail git am empty-commit.patch >out 2>err && - grep "Patch is empty." out && - grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && + test_grep "Patch is empty." out && + test_grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && git am --allow-empty >output && - grep "No changes - recorded it as an empty commit." output && + test_grep "No changes - recorded it as an empty commit." output && test_path_is_missing .git/rebase-apply && git show empty-commit --format="%B" >expected && git show HEAD --format="%B" >actual && - grep -f actual expected + test_grep -f actual expected ' test_expect_success 'create an non-empty commit when the index IS changed though "--allow-empty" is given' ' @@ -1255,7 +1255,7 @@ test_expect_success 'create an non-empty commit when the index IS changed though git am --allow-empty && git show empty-commit --format="%B" >expected && git show HEAD --format="%B" >actual && - grep -f actual expected && + test_grep -f actual expected && git diff HEAD^..HEAD --name-only ' @@ -1264,7 +1264,7 @@ test_expect_success 'cannot create empty commits when there is a clean index due git rev-parse HEAD >expected && test_must_fail git am seq.patch && test_must_fail git am --allow-empty >err && - ! grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && + test_grep ! "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && git rev-parse HEAD >actual && test_cmp actual expected ' @@ -1274,7 +1274,7 @@ test_expect_success 'cannot create empty commits when there is unmerged index du git rev-parse HEAD >expected && test_must_fail git am -3 seq.patch && test_must_fail git am --allow-empty >err && - ! grep "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && + test_grep ! "To record the empty patch as an empty commit, run \"git am --allow-empty\"." err && git rev-parse HEAD >actual && test_cmp actual expected ' diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh index 1717f407c80d86..5466fb78bc9a8b 100755 --- a/t/t4200-rerere.sh +++ b/t/t4200-rerere.sh @@ -83,7 +83,7 @@ test_expect_success 'activate rerere, old style (conflicting merge)' ' sha1=$(sed "s/ .*//" .git/MERGE_RR) && rr=.git/rr-cache/$sha1 && - grep "^=======\$" $rr/preimage && + test_grep "^=======\$" $rr/preimage && test_path_is_missing $rr/postimage && test_path_is_missing $rr/thisimage ' @@ -96,7 +96,7 @@ test_expect_success 'rerere.enabled works, too' ' sha1=$(sed "s/ .*//" .git/MERGE_RR) && rr=.git/rr-cache/$sha1 && - grep ^=======$ $rr/preimage + test_grep ^=======$ $rr/preimage ' test_expect_success 'set up rr-cache' ' @@ -177,7 +177,7 @@ test_expect_success 'first postimage wins' ' test_must_fail git merge first && # rerere kicked in - ! grep "^=======\$" a1 && + test_grep ! "^=======\$" a1 && test_cmp expect a1 ' diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 9f41d56d9a556c..023fbff546b87f 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -267,7 +267,7 @@ test_expect_success 'shortlog --group= DWIM' ' test_expect_success 'shortlog bogus --group' ' test_must_fail git shortlog --group=bogus HEAD 2>err && - grep "unknown group type" err + test_grep "unknown group type" err ' test_expect_success 'trailer idents are split' ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 05cee9e41bb48d..ca502cefce71b4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -668,12 +668,12 @@ test_expect_success 'log --graph with merge with log.graphColors' ' test_expect_success 'log --raw --graph -m with merge' ' git log --raw --graph --oneline -m main | head -n 500 >actual && - grep "initial" actual + test_grep "initial" actual ' test_expect_success 'diff-tree --graph' ' git diff-tree --graph main^ | head -n 500 >actual && - grep "one" actual + test_grep "one" actual ' cat > expect <<\EOF @@ -1082,13 +1082,13 @@ test_expect_success 'decorate-refs and simplify-by-decoration without output' ' test_expect_success 'decorate-refs-exclude HEAD' ' git log --decorate=full --oneline \ --decorate-refs-exclude="HEAD" >actual && - ! grep HEAD actual + test_grep ! HEAD actual ' test_expect_success 'decorate-refs focus from default' ' git log --decorate=full --oneline \ --decorate-refs="refs/heads" >actual && - ! grep HEAD actual + test_grep ! HEAD actual ' test_expect_success '--clear-decorations overrides defaults' ' @@ -2055,45 +2055,45 @@ test_expect_success GPGSSH 'log ssh key fingerprint' ' test_expect_success GPG 'log --graph --show-signature' ' git log --graph --show-signature -n1 signed >actual && - grep "^| gpg: Signature made" actual && - grep "^| gpg: Good signature" actual + test_grep "^| gpg: Signature made" actual && + test_grep "^| gpg: Good signature" actual ' test_expect_success GPGSM 'log --graph --show-signature x509' ' git log --graph --show-signature -n1 signed-x509 >actual && - grep "^| gpgsm: Signature made" actual && - grep "^| gpgsm: Good signature" actual + test_grep "^| gpgsm: Signature made" actual && + test_grep "^| gpgsm: Good signature" actual ' test_expect_success GPGSSH 'log --graph --show-signature ssh' ' test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && git log --graph --show-signature -n1 signed-ssh >actual && - grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual + test_grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual ' test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' ' test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && git log --graph --show-signature -n1 expired-signed >actual && - ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual + test_grep ! "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual ' test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' ' test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && git log --graph --show-signature -n1 notyetvalid-signed >actual && - ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual + test_grep ! "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual ' test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' ' test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && git log --graph --show-signature -n1 timeboxedvalid-signed >actual && - grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual && - ! grep "${GPGSSH_BAD_SIGNATURE}" actual + test_grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual && + test_grep ! "${GPGSSH_BAD_SIGNATURE}" actual ' test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' ' test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" && git log --graph --show-signature -n1 timeboxedinvalid-signed >actual && - ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual + test_grep ! "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual ' test_expect_success GPG 'log --graph --show-signature for merged tag' ' @@ -2110,7 +2110,7 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' ' git checkout plain && git merge --no-ff -m msg signed_tag && git log --graph --show-signature -n1 plain >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep "^| | gpg: Signature made" actual && grep "^| | gpg: Good signature" actual ' @@ -2132,7 +2132,7 @@ test_expect_success GPG 'log --graph --show-signature for merged tag in shallow git clone --depth 1 --no-local . shallow && test_when_finished "rm -rf shallow" && git -C shallow log --graph --show-signature -n1 plain-shallow >actual && - grep "tag signed_tag_shallow names a non-parent $hash" actual + test_grep "tag signed_tag_shallow names a non-parent $hash" actual ' test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' ' @@ -2149,7 +2149,7 @@ test_expect_success GPG 'log --graph --show-signature for merged tag with missin git checkout plain-nokey && git merge --no-ff -m msg signed_tag_nokey && GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep "^| | gpg: Signature made" actual && grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual ' @@ -2171,7 +2171,7 @@ test_expect_success GPG 'log --graph --show-signature for merged tag with bad si git checkout plain-bad && git merge --no-ff -m msg "$(cat forged.tag)" && git log --graph --show-signature -n1 plain-bad >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep "^| | gpg: Signature made" actual && grep "^| | gpg: BAD signature from" actual ' @@ -2192,9 +2192,9 @@ test_expect_success GPG 'log --show-signature for merged tag with GPG failure' ' if ! test_have_prereq VALGRIND then TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual && - grep "^merged tag" actual && - grep "^No signature" actual && - ! grep "^gpg: Signature made" actual + test_grep "^merged tag" actual && + test_grep "^No signature" actual && + test_grep ! "^gpg: Signature made" actual fi ' @@ -2214,7 +2214,7 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' git checkout plain-x509 && git merge --no-ff -m msg signed_tag_x509 && git log --graph --show-signature -n1 plain-x509 >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep "^| | gpgsm: Signature made" actual && grep "^| | gpgsm: Good signature" actual ' @@ -2235,7 +2235,7 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 miss git checkout plain-x509-nokey && git merge --no-ff -m msg signed_tag_x509_nokey && GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep -e "^| | gpgsm: certificate not found" \ -e "^| | gpgsm: failed to find the certificate: Not found" actual ' @@ -2259,7 +2259,7 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad git checkout plain-x509-bad && git merge --no-ff -m msg "$(cat forged.tag)" && git log --graph --show-signature -n1 plain-x509-bad >actual && - grep "^|\\\ merged tag" actual && + test_grep "^|\\\ merged tag" actual && grep "^| | gpgsm: Signature made" actual && grep "^| | gpgsm: invalid signature" actual ' @@ -2267,27 +2267,27 @@ test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad test_expect_success GPG '--no-show-signature overrides --show-signature' ' git log -1 --show-signature --no-show-signature signed >actual && - ! grep "^gpg:" actual + test_grep ! "^gpg:" actual ' test_expect_success GPG 'log.showsignature=true behaves like --show-signature' ' test_config log.showsignature true && git log -1 signed >actual && - grep "gpg: Signature made" actual && - grep "gpg: Good signature" actual + test_grep "gpg: Signature made" actual && + test_grep "gpg: Good signature" actual ' test_expect_success GPG '--no-show-signature overrides log.showsignature=true' ' test_config log.showsignature true && git log -1 --no-show-signature signed >actual && - ! grep "^gpg:" actual + test_grep ! "^gpg:" actual ' test_expect_success GPG '--show-signature overrides log.showsignature=false' ' test_config log.showsignature false && git log -1 --show-signature signed >actual && - grep "gpg: Signature made" actual && - grep "gpg: Good signature" actual + test_grep "gpg: Signature made" actual && + test_grep "gpg: Good signature" actual ' test_expect_success 'log --graph --no-walk is forbidden' ' @@ -2383,7 +2383,7 @@ test_expect_success 'log --decorate does not include things outside filter' ' git log --decorate=full --oneline >actual && # None of the refs are visible: - ! grep /fake actual + test_grep ! /fake actual ' test_expect_success 'log --end-of-options' ' diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh index 605faea0c7baae..90e661fe98437a 100755 --- a/t/t4204-patch-id.sh +++ b/t/t4204-patch-id.sh @@ -44,7 +44,7 @@ test_expect_success 'setup' ' test_expect_success 'patch-id output is well-formed' ' git log -p -1 >log.output && git patch-id output && - grep "^$OID_REGEX $(git rev-parse HEAD)$" output + test_grep "^$OID_REGEX $(git rev-parse HEAD)$" output ' #calculate patch id. Make sure output is not empty. diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 3865f6abc70caa..4be5c51489ab79 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -535,7 +535,7 @@ test_expect_success 'strbuf_utf8_replace() not producing NUL' ' git log --color --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d" | test_decode_color | nul_to_q >actual && - ! grep Q actual + test_grep ! Q actual ' # --date=[XXX] and corresponding %a[X] %c[X] format equivalency diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh index 0e2f80a268ed0d..802597efc793f9 100755 --- a/t/t4209-log-pickaxe.sh +++ b/t/t4209-log-pickaxe.sh @@ -64,21 +64,21 @@ test_expect_success 'usage' ' test_grep "switch.*requires a value" err && test_expect_code 128 git log -Gregex -Sstring 2>err && - grep "cannot be used together" err && + test_grep "cannot be used together" err && test_expect_code 128 git log -Gregex --find-object=HEAD 2>err && - grep "cannot be used together" err && + test_grep "cannot be used together" err && test_expect_code 128 git log -Sstring --find-object=HEAD 2>err && - grep "cannot be used together" err && + test_grep "cannot be used together" err && test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err && - grep "cannot be used together" err + test_grep "cannot be used together" err ' test_expect_success 'usage: --pickaxe-regex' ' test_expect_code 128 git log -Gregex --pickaxe-regex 2>err && - grep "cannot be used together" err + test_grep "cannot be used together" err ' test_expect_success 'usage: --no-pickaxe-regex' ' diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index aaf197d2edc4d8..6cd80a92bb9514 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -356,14 +356,14 @@ test_expect_success '-L diff output includes index and new file mode' ' git log -L:func2:file.c --format= >actual && # Output should contain index headers (not present in old code path) - grep "^index $head_blob_old\.\.$head_blob_new 100644" actual && + test_grep "^index $head_blob_old\.\.$head_blob_new 100644" actual && # Root commit should show new file mode and null index - grep "^new file mode 100644" actual && - grep "^index $null_blob\.\.$root_blob$" actual && + test_grep "^new file mode 100644" actual && + test_grep "^index $null_blob\.\.$root_blob$" actual && # Hunk headers should include funcname context - grep "^@@ .* @@ int func1()" actual + test_grep "^@@ .* @@ int func1()" actual ' test_expect_success '-L with --word-diff' ' @@ -396,15 +396,15 @@ test_expect_success '-L with --word-diff' ' test_expect_success '-L with --no-prefix' ' git log -L:func2:file.c --no-prefix --format= >actual && - grep "^diff --git file.c file.c" actual && - grep "^--- file.c" actual && - ! grep "^--- a/" actual + test_grep "^diff --git file.c file.c" actual && + test_grep "^--- file.c" actual && + test_grep ! "^--- a/" actual ' test_expect_success '-L with --full-index' ' git log -L:func2:file.c --full-index --format= >actual && - grep "^index $head_blob_old_full\.\.$head_blob_new_full 100644" actual && - grep "^index $null_blob_full\.\.$root_blob_full$" actual + test_grep "^index $head_blob_old_full\.\.$head_blob_new_full 100644" actual && + test_grep "^index $null_blob_full\.\.$root_blob_full$" actual ' test_expect_success 'setup -L with whitespace change' ' @@ -521,29 +521,29 @@ test_expect_success '-L with --word-diff-regex' ' git log -L:func2:file.c --word-diff \ --word-diff-regex="[a-zA-Z0-9_]+" --format= >actual && # Word-diff markers must be present - grep "{+" actual && - grep "+}" actual && + test_grep "{+" actual && + test_grep "+}" actual && # No line-level +/- markers (word-diff replaces them); # exclude --- header lines from the check - ! grep "^+[^+]" actual && - ! grep "^-[^-]" actual + test_grep ! "^+[^+]" actual && + test_grep ! "^-[^-]" actual ' test_expect_success '-L with --src-prefix and --dst-prefix' ' git checkout parent-oids && git log -L:func2:file.c --src-prefix=old/ --dst-prefix=new/ \ --format= >actual && - grep "^diff --git old/file.c new/file.c" actual && - grep "^--- old/file.c" actual && - grep "^+++ new/file.c" actual && - ! grep "^--- a/" actual + test_grep "^diff --git old/file.c new/file.c" actual && + test_grep "^--- old/file.c" actual && + test_grep "^+++ new/file.c" actual && + test_grep ! "^--- a/" actual ' test_expect_success '-L with --abbrev' ' git checkout parent-oids && git log -L:func2:file.c --abbrev=4 --format= -1 >actual && # 4-char abbreviated hashes on index line - grep "^index [0-9a-f]\{4\}\.\.[0-9a-f]\{4\}" actual + test_grep "^index [0-9a-f]\{4\}\.\.[0-9a-f]\{4\}" actual ' test_expect_success '-L with -b suppresses whitespace-only diff' ' @@ -559,24 +559,24 @@ test_expect_success '-L with --output-indicator-*' ' git log -L:func2:file.c --output-indicator-new=">" \ --output-indicator-old="<" --output-indicator-context="|" \ --format= -1 >actual && - grep "^>" actual && - grep "^<" actual && - grep "^|" actual && + test_grep "^>" actual && + test_grep "^<" actual && + test_grep "^|" actual && # No standard +/-/space content markers; exclude ---/+++ headers - ! grep "^+[^+]" actual && - ! grep "^-[^-]" actual && - ! grep "^ " actual + test_grep ! "^+[^+]" actual && + test_grep ! "^-[^-]" actual && + test_grep ! "^ " actual ' test_expect_success '-L with -R reverses diff' ' git checkout parent-oids && git log -L:func2:file.c -R --format= -1 >actual && - grep "^diff --git b/file.c a/file.c" actual && - grep "^--- b/file.c" actual && - grep "^+++ a/file.c" actual && + test_grep "^diff --git b/file.c a/file.c" actual && + test_grep "^--- b/file.c" actual && + test_grep "^+++ a/file.c" actual && # The modification added "F2 + 2", so reversed it is removed - grep "^-.*F2 + 2" actual && - grep "^+.*return F2;" actual + test_grep "^-.*F2 + 2" actual && + test_grep "^+.*return F2;" actual ' test_expect_success 'setup for color-moved test' ' @@ -602,8 +602,8 @@ test_expect_success '-L with --color-moved' ' --color=always --format= -1 >actual.raw && test_decode_color actual && # Old moved lines: bold magenta; new moved lines: bold cyan - grep "BOLD;MAGENTA" actual && - grep "BOLD;CYAN" actual + test_grep "BOLD;MAGENTA" actual && + test_grep "BOLD;CYAN" actual ' test_expect_success 'setup for no-newline-at-eof tests' ' @@ -623,14 +623,14 @@ test_expect_success 'setup for no-newline-at-eof tests' ' # newline, the "\ No newline at end of file" marker should appear. test_expect_success '-L no-newline-at-eof appears in tracked range' ' git log -L:bot:noeol.c --format= -1 HEAD~1 >actual && - grep "No newline at end of file" actual + test_grep "No newline at end of file" actual ' # When tracking a function that ends before the no-newline content, # the marker should not appear in the output. test_expect_success '-L no-newline-at-eof suppressed outside range' ' git log -L:top:noeol.c --format= >actual && - ! grep "No newline at end of file" actual + test_grep ! "No newline at end of file" actual ' # When a commit removes a no-newline last line and replaces it with @@ -638,7 +638,7 @@ test_expect_success '-L no-newline-at-eof suppressed outside range' ' # old side of the diff). test_expect_success '-L no-newline-at-eof marker with deleted line' ' git log -L:bot:noeol.c --format= -1 >actual && - grep "No newline at end of file" actual + test_grep "No newline at end of file" actual ' test_expect_success 'setup for range boundary deletion test' ' @@ -698,7 +698,7 @@ test_expect_success '-L with -S filters to string-count changes' ' # combined with the -L range walk, this selects commits that # both touch func2 and change the count of "F2 + 2" in the file. test $(grep -c "^diff --git" actual) = 1 && - grep "F2 + 2" actual + test_grep "F2 + 2" actual ' test_expect_success '-L with -G filters to diff-text matches' ' @@ -708,7 +708,7 @@ test_expect_success '-L with -G filters to diff-text matches' ' # combined with -L, this selects commits that both touch func2 # and have "F2 + 2" in their diff. test $(grep -c "^diff --git" actual) = 1 && - grep "F2 + 2" actual + test_grep "F2 + 2" actual ' test_done diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh index 1064990de31413..76c1d2bda49791 100755 --- a/t/t4216-log-bloom.sh +++ b/t/t4216-log-bloom.sh @@ -75,7 +75,7 @@ test_bloom_filters_used () { log_args=$1 bloom_trace_prefix="statistics:{\"filter_not_present\":${2:-0},\"maybe\"" setup "$log_args" && - grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" && + test_grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" && test_cmp log_wo_bloom log_w_bloom && test_path_is_file "$TRASH_DIRECTORY/trace.perf" } @@ -98,7 +98,7 @@ test_bloom_filters_not_used () { data="$data\"definitely_not\":0," data="$data\"false_positive\":0}" - grep -q "$data" "$TRASH_DIRECTORY/trace.perf" + test_grep -q "$data" "$TRASH_DIRECTORY/trace.perf" fi && test_cmp log_wo_bloom log_w_bloom } @@ -209,7 +209,7 @@ test_bloom_filters_used_when_some_filters_are_missing () { log_args=$1 bloom_trace_prefix="statistics:{\"filter_not_present\":3,\"maybe\":6,\"definitely_not\":10" setup "$log_args" && - grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" && + test_grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" && test_cmp log_wo_bloom log_w_bloom } @@ -224,34 +224,34 @@ test_expect_success 'persist filter settings' ' GIT_TEST_BLOOM_SETTINGS_NUM_HASHES=9 \ GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY=15 \ git commit-graph write --reachable --changed-paths && - grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2.txt && + test_grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2.txt && GIT_TRACE2_EVENT="$(pwd)/trace2-auto.txt" \ git commit-graph write --reachable --changed-paths && - grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2-auto.txt + test_grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2-auto.txt ' test_max_changed_paths () { - grep "\"max_changed_paths\":$1" $2 + test_grep "\"max_changed_paths\":$1" $2 } test_filter_not_computed () { - grep "\"key\":\"filter-not-computed\",\"value\":\"$1\"" $2 + test_grep "\"key\":\"filter-not-computed\",\"value\":\"$1\"" $2 } test_filter_computed () { - grep "\"key\":\"filter-computed\",\"value\":\"$1\"" $2 + test_grep "\"key\":\"filter-computed\",\"value\":\"$1\"" $2 } test_filter_trunc_empty () { - grep "\"key\":\"filter-trunc-empty\",\"value\":\"$1\"" $2 + test_grep "\"key\":\"filter-trunc-empty\",\"value\":\"$1\"" $2 } test_filter_trunc_large () { - grep "\"key\":\"filter-trunc-large\",\"value\":\"$1\"" $2 + test_grep "\"key\":\"filter-trunc-large\",\"value\":\"$1\"" $2 } test_filter_upgraded () { - grep "\"key\":\"filter-upgraded\",\"value\":\"$1\"" $2 + test_grep "\"key\":\"filter-upgraded\",\"value\":\"$1\"" $2 } test_expect_success 'correctly report changes over limit' ' @@ -494,7 +494,7 @@ test_expect_success 'ensure Bloom filters with incompatible settings are ignored >expect 2>err && git -C $repo log --oneline --no-decorate -- file >actual 2>err && test_cmp expect actual && - grep "disabling Bloom filters for commit-graph layer .$layer." err + test_grep "disabling Bloom filters for commit-graph layer .$layer." err ' test_expect_success 'merge graph layers with incompatible Bloom settings' ' @@ -503,8 +503,8 @@ test_expect_success 'merge graph layers with incompatible Bloom settings' ' >trace2.txt && GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \ git -C $repo commit-graph write --reachable --changed-paths 2>err && - grep "disabling Bloom filters for commit-graph layer .$layer." err && - grep "{\"hash_version\":1,\"num_hashes\":7,\"bits_per_entry\":10,\"max_changed_paths\":512" trace2.txt && + test_grep "disabling Bloom filters for commit-graph layer .$layer." err && + test_grep "{\"hash_version\":1,\"num_hashes\":7,\"bits_per_entry\":10,\"max_changed_paths\":512" trace2.txt && test_path_is_file $repo/$graph && test_dir_is_empty $repo/$graphdir && @@ -516,7 +516,7 @@ test_expect_success 'merge graph layers with incompatible Bloom settings' ' git -C $repo log --oneline --no-decorate -- file >actual 2>err && test_cmp expect actual && - grep "statistics:{\"filter_not_present\":0," trace.perf && + test_grep "statistics:{\"filter_not_present\":0," trace.perf && test_must_be_empty err ' @@ -554,8 +554,8 @@ test_expect_success 'ensure Bloom filter with incompatible versions are ignored' >trace2.txt && GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \ git -C $repo -c commitGraph.changedPathsVersion=2 commit-graph write --reachable --changed-paths 2>err && - grep "disabling Bloom filters for commit-graph layer .$layer." err && - grep "{\"hash_version\":2,\"num_hashes\":7,\"bits_per_entry\":10,\"max_changed_paths\":512" trace2.txt + test_grep "disabling Bloom filters for commit-graph layer .$layer." err && + test_grep "{\"hash_version\":2,\"num_hashes\":7,\"bits_per_entry\":10,\"max_changed_paths\":512" trace2.txt ' get_first_changed_path_filter () { @@ -776,7 +776,7 @@ test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small data chunk test_expect_success PERL_TEST_HELPERS 'Bloom reader notices out-of-bounds filter offsets' ' check_corrupt_graph BIDX 12 FFFFFFFF && # use grep to avoid depending on exact chunk size - grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err + test_grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err ' test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small index chunk' ' diff --git a/t/t4252-am-options.sh b/t/t4252-am-options.sh index bda8822b3d1eb6..c36c7e90176f55 100755 --- a/t/t4252-am-options.sh +++ b/t/t4252-am-options.sh @@ -20,8 +20,8 @@ test_expect_success 'interrupted am --whitespace=fix' ' git reset --hard initial && test_must_fail git am --whitespace=fix "$tm"/am-test-1-? && git am --skip && - grep 3 file-1 && - grep "^Six$" file-2 + test_grep 3 file-1 && + test_grep "^Six$" file-2 ' test_expect_success 'interrupted am -C1' ' @@ -29,8 +29,8 @@ test_expect_success 'interrupted am -C1' ' git reset --hard initial && test_must_fail git am -C1 "$tm"/am-test-2-? && git am --skip && - grep 3 file-1 && - grep "^Three$" file-2 + test_grep 3 file-1 && + test_grep "^Three$" file-2 ' test_expect_success 'interrupted am -p2' ' @@ -38,8 +38,8 @@ test_expect_success 'interrupted am -p2' ' git reset --hard initial && test_must_fail git am -p2 "$tm"/am-test-3-? && git am --skip && - grep 3 file-1 && - grep "^Three$" file-2 + test_grep 3 file-1 && + test_grep "^Three$" file-2 ' test_expect_success 'interrupted am -C1 -p2' ' @@ -47,8 +47,8 @@ test_expect_success 'interrupted am -C1 -p2' ' git reset --hard initial && test_must_fail git am -p2 -C1 "$tm"/am-test-4-? && git am --skip && - grep 3 file-1 && - grep "^Three$" file-2 + test_grep 3 file-1 && + test_grep "^Three$" file-2 ' test_expect_success 'interrupted am --directory="frotz nitfol"' ' @@ -56,7 +56,7 @@ test_expect_success 'interrupted am --directory="frotz nitfol"' ' git reset --hard initial && test_must_fail git am --directory="frotz nitfol" "$tm"/am-test-5-? && git am --skip && - grep One "frotz nitfol/file-5" + test_grep One "frotz nitfol/file-5" ' test_expect_success 'apply to a funny path' ' @@ -71,9 +71,9 @@ test_expect_success 'am --reject' ' rm -rf .git/rebase-apply && git reset --hard initial && test_must_fail git am --reject "$tm"/am-test-6-1 && - grep "@@ -1,3 +1,3 @@" file-2.rej && + test_grep "@@ -1,3 +1,3 @@" file-2.rej && test_must_fail git diff-files --exit-code --quiet file-2 && - grep "[-]-reject" .git/rebase-apply/apply-opt + test_grep "[-]-reject" .git/rebase-apply/apply-opt ' test_done diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh index 96ddf3c53a45b9..f68b5d3127d3d7 100755 --- a/t/t4254-am-corrupt.sh +++ b/t/t4254-am-corrupt.sh @@ -73,16 +73,16 @@ test_expect_success "NUL in commit message's body" ' test_when_finished "git am --abort" && make_mbox_with_nul body >body.patch && test_must_fail git am body.patch 2>err && - grep "a NUL byte in commit log message not allowed" err + test_grep "a NUL byte in commit log message not allowed" err ' test_expect_success "NUL in commit message's header" " test_when_finished 'git am --abort' && make_mbox_with_nul subject >subject.patch && test_must_fail git mailinfo msg patch err && - grep \"a NUL byte in 'Subject' is not allowed\" err && + test_grep \"a NUL byte in 'Subject' is not allowed\" err && test_must_fail git am subject.patch 2>err && - grep \"a NUL byte in 'Subject' is not allowed\" err + test_grep \"a NUL byte in 'Subject' is not allowed\" err " test_done diff --git a/t/t4258-am-quoted-cr.sh b/t/t4258-am-quoted-cr.sh index 201915b45a8bd6..50e81b93305c0f 100755 --- a/t/t4258-am-quoted-cr.sh +++ b/t/t4258-am-quoted-cr.sh @@ -16,7 +16,7 @@ test_expect_success 'setup' ' test_expect_success 'am warn if quoted-cr is found' ' git reset --hard one && test_must_fail git am "$DATA/mbox" 2>err && - grep "quoted CRLF detected" err + test_grep "quoted CRLF detected" err ' test_expect_success 'am --quoted-cr=strip' ' diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index 6e117ee93c8b5b..b2684911d19cea 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -88,7 +88,7 @@ test_expect_success 'Clean merge' ' # Repeat the previous test, but turn off rename detection test_expect_success 'Failed merge without rename detection' ' test_must_fail git -c diff.renames=false merge-tree --write-tree side1 side3 >out && - grep "CONFLICT (modify/delete): numbers deleted" out + test_grep "CONFLICT (modify/delete): numbers deleted" out ' test_expect_success '--quiet on conflicted merge' ' @@ -161,13 +161,13 @@ test_expect_success 'Barf on misspelled option, with exit code other than 0 or 1 # Mis-spell with single "s" instead of double "s" test_expect_code 129 git merge-tree --write-tree --mesages FOOBAR side1 side2 2>expect && - grep "error: unknown option.*mesages" expect + test_grep "error: unknown option.*mesages" expect ' test_expect_success 'Barf on too many arguments' ' test_expect_code 129 git merge-tree --write-tree side1 side2 invalid 2>expect && - grep "^usage: git merge-tree" expect + test_grep "^usage: git merge-tree" expect ' anonymize_hash() { @@ -352,7 +352,7 @@ test_expect_success 'rename/add handling' ' # hash=$(tr "\0" "\n" all_blobs && - ! grep $hash all_blobs && + test_grep ! $hash all_blobs && # # Second, check anonymized hash output against expectation @@ -419,7 +419,7 @@ test_expect_success SYMLINKS 'rename/add, where add is a mode conflict' ' # hash=$(tr "\0" "\n" all_blobs && - ! grep $hash all_blobs && + test_grep ! $hash all_blobs && # # Second, check anonymized hash output against expectation @@ -670,8 +670,8 @@ test_expect_success 'mod6: chains of rename/rename(1to2) and add/add via collidi hash1=$(tr "\0" "\n" all_blobs && - ! grep $hash1 all_blobs && - ! grep $hash2 all_blobs && + test_grep ! $hash1 all_blobs && + test_grep ! $hash2 all_blobs && # # Now compare anonymized hash output with expectation @@ -857,7 +857,7 @@ test_expect_success 'NUL terminated conflicted file "lines"' ' test_expect_success 'error out by default for unrelated histories' ' test_expect_code 128 git merge-tree --write-tree side1 unrelated 2>error && - grep "refusing to merge unrelated histories" error + test_grep "refusing to merge unrelated histories" error ' test_expect_success 'can override merge of unrelated histories' ' @@ -924,7 +924,7 @@ test_expect_success '--stdin with both a successful and a conflicted merge' ' test_expect_success '--merge-base is incompatible with --stdin' ' test_must_fail git merge-tree --merge-base=side1 --stdin 2>expect && - grep "^fatal: .*merge-base.*stdin.* cannot be used together" expect + test_grep "^fatal: .*merge-base.*stdin.* cannot be used together" expect ' # specify merge-base as parent of branch2 diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index a8c28533dc73f8..3ad600c7932b68 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -323,14 +323,14 @@ test_expect_success 'setup tar filters' ' test_expect_success 'archive --list mentions user filter' ' git archive --list >output && - grep "^tar\.foo\$" output && - grep "^bar\$" output + test_grep "^tar\.foo\$" output && + test_grep "^bar\$" output ' test_expect_success 'archive --list shows only enabled remote filters' ' git archive --list --remote=. >output && - ! grep "^tar\.foo\$" output && - grep "^bar\$" output + test_grep ! "^tar\.foo\$" output && + test_grep "^bar\$" output ' test_expect_success 'invoke tar filter by format' ' @@ -440,7 +440,7 @@ test_expect_success 'catch non-matching pathspec' ' test_expect_success 'reject paths outside the current directory' ' test_must_fail git -C a/bin archive HEAD .. >/dev/null 2>err && - grep "outside the current directory" err + test_grep "outside the current directory" err ' test_expect_success 'allow pathspecs that resolve to the current directory' ' diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index df513a42694966..768b0ff85d031e 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -205,7 +205,7 @@ test_expect_success EXPENSIVE,LONG_IS_64BIT,UNZIP,UNZIP_ZIP64_SUPPORT,ZIPINFO \ "$GIT_UNZIP" -t big.zip && "$ZIPINFO" big.zip >big.lst && - grep $size big.lst + test_grep $size big.lst ' build_tree() { diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index e57e1ae7395b13..e01078abe748aa 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -265,7 +265,7 @@ test_expect_success 'mailinfo warn CR in base64 encoded email' ' check_quoted_cr_mail quoted-cr/0001 && test_must_be_empty quoted-cr/0001.err && check_quoted_cr_mail quoted-cr/0002 && - grep "quoted CRLF detected" quoted-cr/0002.err && + test_grep "quoted CRLF detected" quoted-cr/0002.err && check_quoted_cr_mail quoted-cr/0001 --quoted-cr=nowarn && test_must_be_empty quoted-cr/0001.err && check_quoted_cr_mail quoted-cr/0002 --quoted-cr=nowarn && diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index 270ce6ea48796a..67c5dc7e85fddb 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -130,8 +130,8 @@ test_expect_success 'pull request when forgot to push' ' test_must_fail git request-pull initial "$downstream_url" \ 2>../err ) && - grep "No match for commit .*" err && - grep "Are you sure you pushed" err + test_grep "No match for commit .*" err && + test_grep "Are you sure you pushed" err ' @@ -230,7 +230,7 @@ test_expect_success 'pull request format' ' cd local && git request-pull initial "$downstream_url" full ) >request && - grep " tags/full\$" request + test_grep " tags/full\$" request ' test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' ' @@ -260,8 +260,8 @@ test_expect_success 'request-pull quotes regex metacharacters properly' ' test_must_fail git request-pull initial "$downstream_url" tags/v2.0 \ 2>../err ) && - grep "No match for commit .*" err && - grep "Are you sure you pushed" err + test_grep "No match for commit .*" err && + test_grep "Are you sure you pushed" err ' @@ -277,8 +277,8 @@ test_expect_success 'pull request with mismatched object' ' test_must_fail git request-pull initial "$downstream_url" tags/full \ 2>../err ) && - grep "points to a different object" err && - grep "Are you sure you pushed" err + test_grep "points to a different object" err && + test_grep "Are you sure you pushed" err ' @@ -295,8 +295,8 @@ test_expect_success 'pull request with stale object' ' test_must_fail git request-pull initial "$downstream_url" tags/full \ 2>../err ) && - grep "points to a different object" err && - grep "Are you sure you pushed" err + test_grep "points to a different object" err && + test_grep "Are you sure you pushed" err ' diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 73445782e74451..9dabb3615aff56 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -548,18 +548,18 @@ test_expect_success !PTHREADS,!FAIL_PREREQS \ test_must_fail git index-pack --threads=2 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && - grep -F "no threads support, ignoring --threads=2" err && + test_grep -F "no threads support, ignoring --threads=2" err && test_must_fail git -c pack.threads=2 index-pack 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && - grep -F "no threads support, ignoring pack.threads" err && + test_grep -F "no threads support, ignoring pack.threads" err && test_must_fail git -c pack.threads=2 index-pack --threads=4 2>err && grep ^warning: err >warnings && test_line_count = 2 warnings && - grep -F "no threads support, ignoring --threads=4" err && - grep -F "no threads support, ignoring pack.threads" err + test_grep -F "no threads support, ignoring --threads=4" err && + test_grep -F "no threads support, ignoring pack.threads" err ' test_expect_success !PTHREADS,!FAIL_PREREQS \ @@ -567,18 +567,18 @@ test_expect_success !PTHREADS,!FAIL_PREREQS \ git pack-objects --threads=2 --stdout --all /dev/null 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && - grep -F "no threads support, ignoring --threads" err && + test_grep -F "no threads support, ignoring --threads" err && git -c pack.threads=2 pack-objects --stdout --all /dev/null 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && - grep -F "no threads support, ignoring pack.threads" err && + test_grep -F "no threads support, ignoring pack.threads" err && git -c pack.threads=2 pack-objects --threads=4 --stdout --all /dev/null 2>err && grep ^warning: err >warnings && test_line_count = 2 warnings && - grep -F "no threads support, ignoring --threads" err && - grep -F "no threads support, ignoring pack.threads" err + test_grep -F "no threads support, ignoring --threads" err && + test_grep -F "no threads support, ignoring pack.threads" err ' test_expect_success 'pack-objects in too-many-packs mode' ' @@ -720,14 +720,14 @@ test_expect_success '--name-hash-version=2 and --write-bitmap-index are incompat # --stdout option silently removes --write-bitmap-index git pack-objects --stdout --all --name-hash-version=2 --write-bitmap-index >out 2>err && - ! test_grep "currently, --write-bitmap-index requires --name-hash-version=1" err + test_grep ! "currently, --write-bitmap-index requires --name-hash-version=1" err ' test_expect_success '--path-walk pack everything' ' git -C server rev-parse HEAD >in && GIT_PROGRESS_DELAY=0 git -C server pack-objects \ --stdout --revs --path-walk --progress out.pack 2>err && - grep "Compressing objects by path" err && + test_grep "Compressing objects by path" err && git -C server index-pack --stdin out.pack 2>err && - grep "Compressing objects by path" err && + test_grep "Compressing objects by path" err && git -C server index-pack --fix-thin --stdin err && - grep "^warning:.* expected .tagger. line" err + test_grep "^warning:.* expected .tagger. line" err ' test_expect_success 'index-pack --fsck-objects also warns upon missing tagger in tag' ' git index-pack --fsck-objects tag-test-${pack1}.pack 2>err && - grep "^warning:.* expected .tagger. line" err + test_grep "^warning:.* expected .tagger. line" err ' test_expect_success 'index-pack -v --stdin produces progress for both phases' ' @@ -290,7 +290,7 @@ test_expect_success 'too-large packs report the breach' ' sz="$(test_file_size pack-$pack.pack)" && test "$sz" -gt 20 && test_must_fail git index-pack --max-input-size=20 pack-$pack.pack 2>err && - grep "maximum allowed size (20 bytes)" err + test_grep "maximum allowed size (20 bytes)" err ' # git-index-pack(1) uses the default hash algorithm outside of the repository, diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 2be7cd30dece6e..db8e389c2c13b1 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -120,7 +120,7 @@ test_expect_success 'prune: prune former HEAD after checking out branch' ' git checkout --quiet main && git reflog expire --all && git prune -v >prune_actual && - grep "$head_oid" prune_actual + test_grep "$head_oid" prune_actual ' test_expect_success 'prune: do not prune heads listed as an argument' ' @@ -214,7 +214,7 @@ test_expect_success 'garbage report in count-objects -v' ' >.git/objects/pack/fake2.keep && >.git/objects/pack/fake3.idx && git count-objects -v 2>stderr && - grep "index file .git/objects/pack/fake.idx is too small" stderr && + test_grep "index file .git/objects/pack/fake.idx is too small" stderr && grep "^warning:" stderr | sort >actual && cat >expected <<\EOF && warning: garbage found: .git/objects/pack/fake.bar @@ -252,8 +252,8 @@ test_expect_success 'prune .git/shallow' ' oid=$(echo hi|git commit-tree HEAD^{tree}) && echo $oid >.git/shallow && git prune --dry-run >out && - grep $oid .git/shallow && - grep $oid out && + test_grep $oid .git/shallow && + test_grep $oid out && git prune && test_path_is_missing .git/shallow ' diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index efeb71593bf7f6..65011cb21f9ea1 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -23,7 +23,7 @@ list_packed_objects () { # tests whether content-file has any entry from pattern-file with entries being # whole lines. has_any () { - grep -Ff "$1" "$2" + test_grep -Ff "$1" "$2" } # Since name-hash values are stored in the .bitmap files, add a test @@ -81,8 +81,8 @@ test_bitmap_cases () { git repack -ad && ls .git/objects/pack/ | grep bitmap >output && test_line_count = 1 output && - grep "\"key\":\"num_selected_commits\",\"value\":\"106\"" trace && - grep "\"key\":\"num_maximal_commits\",\"value\":\"107\"" trace + test_grep "\"key\":\"num_selected_commits\",\"value\":\"106\"" trace && + test_grep "\"key\":\"num_maximal_commits\",\"value\":\"107\"" trace ' basic_bitmap_tests @@ -532,8 +532,8 @@ test_bitmap_cases () { test_line_count = 2 bitmaps && GIT_TRACE2_EVENT=$(pwd)/trace2.txt git rev-list --use-bitmap-index HEAD && - grep "opened bitmap" trace2.txt && - grep "ignoring extra bitmap" trace2.txt + test_grep "opened bitmap" trace2.txt && + test_grep "ignoring extra bitmap" trace2.txt ) ' @@ -598,7 +598,7 @@ test_expect_success 'boundary-based traversal is used when requested' ' do eval "GIT_TRACE2_EVENT=1 $argv rev-list --objects \ --use-bitmap-index second..other 2>perf" && - grep "\"region_enter\".*\"label\":\"haves/boundary\"" perf || + test_grep "\"region_enter\".*\"label\":\"haves/boundary\"" perf || return 1 done && @@ -610,7 +610,7 @@ test_expect_success 'boundary-based traversal is used when requested' ' do eval "GIT_TRACE2_EVENT=1 $argv rev-list --objects \ --use-bitmap-index second..other 2>perf" && - grep "\"region_enter\".*\"label\":\"haves/classic\"" perf || + test_grep "\"region_enter\".*\"label\":\"haves/classic\"" perf || return 1 done ' @@ -632,7 +632,7 @@ test_bitmap_cases "pack.writeBitmapLookupTable" test_expect_success 'verify writing bitmap lookup table when enabled' ' GIT_TRACE2_EVENT="$(pwd)/trace2" \ git repack -ad && - grep "\"label\":\"writing_lookup_table\"" trace2 + test_grep "\"label\":\"writing_lookup_table\"" trace2 ' test_expect_success 'truncated bitmap fails gracefully (lookup table)' ' diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index dddb79ba627036..f3106970561bdf 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -35,7 +35,7 @@ test_expect_success 'verify blob count in normal packfile' ' git -C r1 index-pack ../all.pack && git -C r1 verify-pack -v ../all.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -49,7 +49,7 @@ test_expect_success 'verify blob:none packfile has no blobs' ' git -C r1 index-pack ../filter.pack && git -C r1 verify-pack -v ../filter.pack >verify_result && - ! grep blob verify_result + test_grep ! blob verify_result ' test_expect_success 'verify blob:none packfile without --stdout' ' @@ -57,17 +57,17 @@ test_expect_success 'verify blob:none packfile without --stdout' ' HEAD EOF git -C r1 verify-pack -v "mypackname-$(cat packhash).pack" >verify_result && - ! grep blob verify_result + test_grep ! blob verify_result ' test_expect_success 'verify normal and blob:none packfiles have same commits/trees' ' git -C r1 verify-pack -v ../all.pack >verify_result && - grep -E "commit|tree" verify_result | + test_grep -E "commit|tree" verify_result | parse_verify_pack_blob_oid | sort >expected && git -C r1 verify-pack -v ../filter.pack >verify_result && - grep -E "commit|tree" verify_result | + test_grep -E "commit|tree" verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -85,7 +85,7 @@ test_expect_success 'get an error for missing tree object' ' test_must_fail git -C r5 pack-objects --revs --stdout 2>bad_tree <<-EOF && HEAD EOF - grep "bad tree object" bad_tree + test_grep "bad tree object" bad_tree ' test_expect_success 'setup for tests of tree:0' ' @@ -101,7 +101,7 @@ test_expect_success 'verify tree:0 packfile has no blobs or trees' ' EOF git -C r1 index-pack ../commitsonly.pack && git -C r1 verify-pack -v ../commitsonly.pack >objs && - ! grep -E "tree|blob" objs + test_grep ! -E "tree|blob" objs ' test_expect_success 'grab tree directly when using tree:0' ' @@ -142,7 +142,7 @@ test_expect_success 'verify blob count in normal packfile' ' git -C r2 index-pack ../all.pack && git -C r2 verify-pack -v ../all.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -156,7 +156,7 @@ test_expect_success 'verify blob:limit=500 omits all blobs' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - ! grep blob verify_result + test_grep ! blob verify_result ' test_expect_success 'verify blob:limit=1000' ' @@ -166,7 +166,7 @@ test_expect_success 'verify blob:limit=1000' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - ! grep blob verify_result + test_grep ! blob verify_result ' test_expect_success 'verify blob:limit=1001' ' @@ -180,7 +180,7 @@ test_expect_success 'verify blob:limit=1001' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -198,7 +198,7 @@ test_expect_success 'verify blob:limit=10001' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -216,7 +216,7 @@ test_expect_success 'verify blob:limit=1k' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -234,7 +234,7 @@ test_expect_success 'verify explicitly specifying oversized blob in input' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -252,7 +252,7 @@ test_expect_success 'verify blob:limit=1m' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -261,12 +261,12 @@ test_expect_success 'verify blob:limit=1m' ' test_expect_success 'verify normal and blob:limit packfiles have same commits/trees' ' git -C r2 verify-pack -v ../all.pack >verify_result && - grep -E "commit|tree" verify_result | + test_grep -E "commit|tree" verify_result | parse_verify_pack_blob_oid | sort >expected && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep -E "commit|tree" verify_result | + test_grep -E "commit|tree" verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -285,7 +285,7 @@ test_expect_success 'verify small limit and big limit results in small limit' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -304,7 +304,7 @@ test_expect_success 'verify big limit and small limit results in small limit' ' git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -347,7 +347,7 @@ test_expect_success 'verify blob count in normal packfile' ' git -C r3 index-pack ../all.pack && git -C r3 verify-pack -v ../all.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -400,7 +400,7 @@ test_expect_success 'verify blob count in normal packfile' ' git -C r4 index-pack ../all.pack && git -C r4 verify-pack -v ../all.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -420,7 +420,7 @@ test_expect_success 'verify sparse:oid=OID' ' git -C r4 index-pack ../filter.pack && git -C r4 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -438,7 +438,7 @@ test_expect_success 'verify sparse:oid=oid-ish' ' git -C r4 index-pack ../filter.pack && git -C r4 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | + test_grep blob verify_result | parse_verify_pack_blob_oid | sort >observed && @@ -529,16 +529,16 @@ test_expect_success 'sparse:oid with --path-walk produces same blobs' ' git -C pw_sparse verify-pack -v ../pathwalk.pack >pathwalk_verify && # Blobs must match exactly - grep -E "^[0-9a-f]{40} blob" standard_verify | + test_grep -E "^[0-9a-f]{40} blob" standard_verify | awk "{print \$1}" | sort >standard_blobs && - grep -E "^[0-9a-f]{40} blob" pathwalk_verify | + test_grep -E "^[0-9a-f]{40} blob" pathwalk_verify | awk "{print \$1}" | sort >pathwalk_blobs && test_cmp standard_blobs pathwalk_blobs && # Commits must match exactly - grep -E "^[0-9a-f]{40} commit" standard_verify | + test_grep -E "^[0-9a-f]{40} commit" standard_verify | awk "{print \$1}" | sort >standard_commits && - grep -E "^[0-9a-f]{40} commit" pathwalk_verify | + test_grep -E "^[0-9a-f]{40} commit" pathwalk_verify | awk "{print \$1}" | sort >pathwalk_commits && test_cmp standard_commits pathwalk_commits ' @@ -546,9 +546,9 @@ test_expect_success 'sparse:oid with --path-walk produces same blobs' ' test_expect_success 'sparse:oid with --path-walk includes all trees' ' # The sparse:oid filter restricts only blobs, not trees. # Both standard and path-walk should include the same trees. - grep -E "^[0-9a-f]{40} tree" standard_verify | + test_grep -E "^[0-9a-f]{40} tree" standard_verify | awk "{print \$1}" | sort >standard_trees && - grep -E "^[0-9a-f]{40} tree" pathwalk_verify | + test_grep -E "^[0-9a-f]{40} tree" pathwalk_verify | awk "{print \$1}" | sort >pathwalk_trees && test_cmp standard_trees pathwalk_trees @@ -596,9 +596,9 @@ test_expect_success 'shared tree OID: --path-walk blobs match standard' ' git -C pw_shared index-pack ../shared_pw.pack && git -C pw_shared verify-pack -v ../shared_pw.pack >shared_pw_verify && - grep -E "^[0-9a-f]{40} blob" shared_std_verify | + test_grep -E "^[0-9a-f]{40} blob" shared_std_verify | awk "{print \$1}" | sort >shared_std_blobs && - grep -E "^[0-9a-f]{40} blob" shared_pw_verify | + test_grep -E "^[0-9a-f]{40} blob" shared_pw_verify | awk "{print \$1}" | sort >shared_pw_blobs && test_cmp shared_std_blobs shared_pw_blobs ' diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 1c40f904f8bb31..6cecfbeaa1dc70 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -14,7 +14,7 @@ test_expect_success 'usage' ' test_expect_success 'usage shown without sub-command' ' test_expect_code 129 git commit-graph 2>err && - grep usage: err + test_grep usage: err ' test_expect_success 'usage shown with an error on unknown sub-command' ' @@ -679,12 +679,12 @@ test_expect_success 'git fsck (checks commit-graph when config unset)' ' test_expect_success 'git fsck shows commit-graph output with --progress' ' git -C "$TRASH_DIRECTORY/full" fsck --progress 2>err && - grep "Verifying commits in commit graph" err + test_grep "Verifying commits in commit graph" err ' test_expect_success 'git fsck suppresses commit-graph output with --no-progress' ' git -C "$TRASH_DIRECTORY/full" fsck --no-progress 2>err && - ! grep "Verifying commits in commit graph" err + test_grep ! "Verifying commits in commit graph" err ' test_expect_success 'setup non-the_repository tests' ' @@ -962,7 +962,7 @@ test_expect_success 'stale commit cannot be parsed when traversing graph' ' git rev-parse HEAD~2 && # ... but fail when we are paranoid. test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git rev-parse HEAD~2 2>error && - grep "error: commit $oid exists in commit-graph but not in the object database" error + test_grep "error: commit $oid exists in commit-graph but not in the object database" error ) ' diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh index fa0d4046f753b8..68143cb5b76952 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -130,7 +130,7 @@ test_expect_success 'corrupt idx reports errors' ' test_copy_bytes 1064 $objdir/pack/$idx && git -c core.multiPackIndex=true rev-list --objects --all 2>err && - grep "index unavailable" err + test_grep "index unavailable" err ' test_expect_success 'add more objects' ' @@ -326,7 +326,7 @@ test_expect_success 'preferred packs must be non-empty' ' test_must_fail git multi-pack-index write \ --preferred-pack=pack-$empty.pack 2>err && - grep "with no objects" err + test_grep "with no objects" err ) ' @@ -548,14 +548,14 @@ test_expect_success 'git-fsck incorrect offset' ' test_expect_success 'git fsck shows MIDX output with --progress' ' git fsck --progress 2>err && - grep "Verifying OID order in multi-pack-index" err && - grep "Verifying object offsets" err + test_grep "Verifying OID order in multi-pack-index" err && + test_grep "Verifying object offsets" err ' test_expect_success 'git fsck suppresses MIDX output with --no-progress' ' git fsck --no-progress 2>err && - ! grep "Verifying OID order in multi-pack-index" err && - ! grep "Verifying object offsets" err + test_grep ! "Verifying OID order in multi-pack-index" err && + test_grep ! "Verifying object offsets" err ' test_expect_success 'corrupt MIDX is not reused' ' @@ -1175,12 +1175,12 @@ test_expect_success 'load reverse index when missing .idx, .pack' ' test_expect_success 'usage shown without sub-command' ' test_expect_code 129 git multi-pack-index 2>err && - ! test_grep "unrecognized subcommand" err + test_grep ! "unrecognized subcommand" err ' test_expect_success 'complains when run outside of a repository' ' nongit test_must_fail git multi-pack-index write 2>err && - grep "not a git repository" err + test_grep "not a git repository" err ' test_expect_success 'repack with delta islands' ' diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index 49a057cc2eb65d..89c0c4f9017296 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -297,7 +297,7 @@ test_expect_success 'verify notices chain slice which is bogus (base)' ' echo "garbage" >$base_file && test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err && - grep "commit-graph file is too small" err + test_grep "commit-graph file is too small" err ) ' @@ -310,7 +310,7 @@ test_expect_success 'verify notices chain slice which is bogus (tip)' ' echo "garbage" >$tip_file && test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err && - grep "commit-graph file is too small" err + test_grep "commit-graph file is too small" err ) ' @@ -379,7 +379,7 @@ test_expect_success 'verify notices too-short chain file' ' echo "garbage" >$graphdir/commit-graph-chain && test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err && - grep "commit-graph chain file too small" err + test_grep "commit-graph chain file too small" err ) ' @@ -410,7 +410,7 @@ test_expect_success PERL_TEST_HELPERS 'reader bounds-checks base-graph chunk' ' git -c core.commitGraph=false log >expect.out && git -c core.commitGraph=true log >out 2>err && test_cmp expect.out out && - grep "commit-graph base graphs chunk is too small" err + test_grep "commit-graph base graphs chunk is too small" err ) ' @@ -421,7 +421,7 @@ test_expect_success 'add octopus merge' ' git commit-graph write --reachable --split && git commit-graph verify --progress 2>err && test_line_count = 1 err && - grep "Verifying commits in commit graph: 100% (18/18)" err && + test_grep "Verifying commits in commit graph: 100% (18/18)" err && test_grep ! warning err && test_line_count = 3 $graphdir/commit-graph-chain ' diff --git a/t/t5325-reverse-index.sh b/t/t5325-reverse-index.sh index 285c8b4a49555b..45d706464cf79f 100755 --- a/t/t5325-reverse-index.sh +++ b/t/t5325-reverse-index.sh @@ -65,7 +65,7 @@ test_expect_success 'index-pack can verify reverse indexes' ' test_must_fail git index-pack --rev-index --verify \ $packdir/pack-$pack.pack 2>err && - grep "validation error" err + test_grep "validation error" err ' test_expect_success 'index-pack infers reverse index name with -o' ' @@ -172,7 +172,7 @@ corrupt_rev_and_verify () { printf "$value" | dd of=$revfile bs=1 seek="$pos" conv=notrunc && test_must_fail git fsck 2>err && - grep "$error" err + test_grep "$error" err ) } diff --git a/t/t5326-multi-pack-bitmaps.sh b/t/t5326-multi-pack-bitmaps.sh index 62bd973d92afc9..18464d2fc03780 100755 --- a/t/t5326-multi-pack-bitmaps.sh +++ b/t/t5326-multi-pack-bitmaps.sh @@ -121,7 +121,7 @@ test_midx_bitmap_cases () { EOF test_must_fail git multi-pack-index write --bitmap 2>err && - grep "doesn.t have full closure" err && + test_grep "doesn.t have full closure" err && test_path_is_missing $midx ) ' @@ -215,8 +215,8 @@ test_midx_bitmap_cases () { test_path_is_file $midx-$(midx_checksum $objdir).bitmap && test-tool bitmap list-commits | sort >bitmaps && - grep "$(git rev-parse one)" bitmaps && - grep "$(git rev-parse two)" bitmaps && + test_grep "$(git rev-parse one)" bitmaps && + test_grep "$(git rev-parse two)" bitmaps && rm -fr $midx-$(midx_checksum $objdir).bitmap && rm -fr $midx && @@ -229,8 +229,8 @@ test_midx_bitmap_cases () { test_path_is_file $midx-$(midx_checksum $objdir).bitmap && test-tool bitmap list-commits | sort >bitmaps && - grep "$(git rev-parse one)" bitmaps && - ! grep "$(git rev-parse two)" bitmaps + test_grep "$(git rev-parse one)" bitmaps && + test_grep ! "$(git rev-parse two)" bitmaps ) ' @@ -258,7 +258,7 @@ test_midx_bitmap_cases () { test_line_count = 1 before && ( - grep -vf before commits.raw && + test_grep -vf before commits.raw && # mark missing commits as preferred sed "s/^/+/" before ) >snapshot && @@ -321,7 +321,7 @@ test_midx_bitmap_cases () { git multi-pack-index write --bitmap --stdin-packs \ err && - grep "bitmap without any objects" err && + test_grep "bitmap without any objects" err && test_path_is_file $midx && test_path_is_missing $midx-$(midx_checksum $objdir).bitmap @@ -344,7 +344,7 @@ test_midx_bitmap_cases () { GIT_TEST_MIDX_READ_RIDX=0 \ git rev-list --use-bitmap-index HEAD 2>err && - ! grep "ignoring extra bitmap file" err + test_grep ! "ignoring extra bitmap file" err ) ' } @@ -364,7 +364,7 @@ test_expect_success 'multi-pack-index write writes lookup table if enabled' ' git repack -ad && GIT_TRACE2_EVENT="$(pwd)/trace" \ git multi-pack-index write --bitmap && - grep "\"label\":\"writing_lookup_table\"" trace + test_grep "\"label\":\"writing_lookup_table\"" trace ) ' @@ -432,7 +432,7 @@ test_expect_success 'tagged commits are selected for bitmapping' ' git rev-parse HEAD >want && test-tool bitmap list-commits >actual && - grep $(cat want) actual + test_grep $(cat want) actual ) ' @@ -488,17 +488,17 @@ test_expect_success 'git fsck correctly identifies good and bad bitmaps' ' corrupt_file "$packbitmap" && test_must_fail git fsck 2>err && - grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err && + test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err && cp "$packbitmap.bak" "$packbitmap" && corrupt_file "$midxbitmap" && test_must_fail git fsck 2>err && - grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && + test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && corrupt_file "$packbitmap" && test_must_fail git fsck 2>err && - grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && - grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err + test_grep "bitmap file '\''$midxbitmap'\'' has invalid checksum" err && + test_grep "bitmap file '\''$packbitmap'\'' has invalid checksum" err ' test_expect_success 'corrupt MIDX with bitmap causes fallback' ' diff --git a/t/t5328-commit-graph-64bit-time.sh b/t/t5328-commit-graph-64bit-time.sh index d8891e6a922463..4e86aff5099362 100755 --- a/t/t5328-commit-graph-64bit-time.sh +++ b/t/t5328-commit-graph-64bit-time.sh @@ -80,7 +80,7 @@ test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds generation o git commit-graph write --reachable && corrupt_chunk_file $graph GDO2 clear && test_must_fail git log 2>err && - grep "commit-graph overflow generation data is too small" err + test_grep "commit-graph overflow generation data is too small" err ' test_done diff --git a/t/t5329-pack-objects-cruft.sh b/t/t5329-pack-objects-cruft.sh index 25ddda5cf3832e..12cda063730372 100755 --- a/t/t5329-pack-objects-cruft.sh +++ b/t/t5329-pack-objects-cruft.sh @@ -468,8 +468,8 @@ test_expect_success 'cruft --local drops unreachable objects' ' test-tool pack-mtimes "$(basename $(ls $packdir/pack-*.mtimes))" \ >objects && - ! grep $object objects && - grep $cruft objects + test_grep ! $object objects && + test_grep $cruft objects ) ' @@ -515,7 +515,7 @@ test_expect_success 'cruft objects are freshend via loose' ' test_path_is_missing "$loose" && test-tool pack-mtimes "$(basename "$(ls $packdir/pack-*.mtimes)")" >cruft && - grep "$blob" cruft && + test_grep "$blob" cruft && # write the same object again git hash-object -w -t blob contents && @@ -657,7 +657,7 @@ test_expect_success 'multi-valued gc.recentObjectsHook' ' # ensure that a dirty exit halts cruft pack generation git config --add gc.recentObjectsHook ./extra-tips.c && test_must_fail git repack --cruft --cruft-expiration=now -d 2>err && - grep "unable to enumerate additional recent objects" err && + test_grep "unable to enumerate additional recent objects" err && # and that the existing cruft pack is left alone test_path_is_file "$mtimes" diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh index 305d6771082d55..7e6793e6d6f1d2 100755 --- a/t/t5333-pseudo-merge-bitmaps.sh +++ b/t/t5333-pseudo-merge-bitmaps.sh @@ -249,7 +249,7 @@ test_expect_success 'pseudo-merge pattern with capture groups' ' for m in $(test_seq 0 $(($(wc -l oids && - grep -f oids refs | + test_grep -f oids refs | sed -n "s|refs/remotes/\([0-9][0-9]*\)/|\1|p" && sort -u || return 1 done >remotes && diff --git a/t/t5334-incremental-multi-pack-index.sh b/t/t5334-incremental-multi-pack-index.sh index 68a103d13d23c3..f0b82b5f65cf40 100755 --- a/t/t5334-incremental-multi-pack-index.sh +++ b/t/t5334-incremental-multi-pack-index.sh @@ -29,7 +29,7 @@ test_expect_success 'convert non-incremental MIDX to incremental' ' test_path_is_missing $packdir/multi-pack-index && test_path_is_file $midx_chain && test_line_count = 2 $midx_chain && - grep $old_hash $midx_chain + test_grep $old_hash $midx_chain ' compare_results_with_midx 'incremental MIDX' diff --git a/t/t5335-compact-multi-pack-index.sh b/t/t5335-compact-multi-pack-index.sh index ec1dafe89fcfce..0f75ef2ccc96b3 100755 --- a/t/t5335-compact-multi-pack-index.sh +++ b/t/t5335-compact-multi-pack-index.sh @@ -321,8 +321,8 @@ test_expect_success 'MIDX compaction with --no-write-chain-file' ' } >$midx_chain && test-tool read-midx $objdir $layer >midx.data && - grep "^pack-B-.*\.idx" midx.data && - grep "^pack-C-.*\.idx" midx.data + test_grep "^pack-B-.*\.idx" midx.data && + test_grep "^pack-C-.*\.idx" midx.data ) ' diff --git a/t/t5351-unpack-large-objects.sh b/t/t5351-unpack-large-objects.sh index d76eb4be932eeb..7f621c53311539 100755 --- a/t/t5351-unpack-large-objects.sh +++ b/t/t5351-unpack-large-objects.sh @@ -32,7 +32,7 @@ test_expect_success 'set memory limitation to 1MB' ' test_expect_success 'unpack-objects failed under memory limitation' ' prepare_dest 2m && test_must_fail git -C dest.git unpack-objects err && - grep "fatal: attempting to allocate" err + test_grep "fatal: attempting to allocate" err ' test_expect_success 'unpack-objects works with memory limitation in dry-run mode' ' diff --git a/t/t5402-post-merge-hook.sh b/t/t5402-post-merge-hook.sh index 915af2de95e162..c77aa56421c5e2 100755 --- a/t/t5402-post-merge-hook.sh +++ b/t/t5402-post-merge-hook.sh @@ -46,7 +46,7 @@ test_expect_success 'post-merge runs as expected ' ' ' test_expect_success 'post-merge from normal merge receives the right argument ' ' - grep 0 clone1/.git/post-merge.args + test_grep 0 clone1/.git/post-merge.args ' test_expect_success 'post-merge from squash merge runs as expected ' ' @@ -55,7 +55,7 @@ test_expect_success 'post-merge from squash merge runs as expected ' ' ' test_expect_success 'post-merge from squash merge receives the right argument ' ' - grep 1 clone2/.git/post-merge.args + test_grep 1 clone2/.git/post-merge.args ' test_done diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index cb0300b2d2b2f0..39009ce327b6bd 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -100,7 +100,7 @@ test_rebase () { echo untracked >three.t && test_when_finished "rm three.t" && test_must_fail git rebase $args HEAD rebase-fast-forward 2>err && - grep "untracked working tree files would be overwritten by checkout" err && + test_grep "untracked working tree files would be overwritten by checkout" err && test_path_is_missing .git/post-checkout.args ' diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh index cc078896673ae2..a1661d34f24509 100755 --- a/t/t5404-tracking-branches.sh +++ b/t/t5404-tracking-branches.sh @@ -59,7 +59,7 @@ test_expect_success 'deleted branches have their tracking branches removed' ' test_expect_success 'already deleted tracking branches ignored' ' git branch -d -r origin/b3 && git push origin :b3 >output 2>&1 && - ! grep "^error: " output + test_grep ! "^error: " output ' test_done diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh index ad7f8c6f00202c..ed9896e27a4e78 100755 --- a/t/t5407-post-rewrite-hook.sh +++ b/t/t5407-post-rewrite-hook.sh @@ -195,19 +195,19 @@ test_expect_success 'git rebase with failed pick' ' set_replace_editor todo && test_must_fail git rebase -i D D 2>err ) && - grep "would be overwritten" err && + test_grep "would be overwritten" err && rm bar && test_must_fail git rebase --continue 2>err && - grep "would be overwritten" err && + test_grep "would be overwritten" err && rm G && test_must_fail git rebase --continue 2>err && - grep "would be overwritten" err && + test_grep "would be overwritten" err && rm H && test_must_fail git rebase --continue 2>err && - grep "would be overwritten" err && + test_grep "would be overwritten" err && rm I && git rebase --continue && diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh index 3010913bb113e4..e5ade7b78785cc 100755 --- a/t/t5409-colorize-remote-messages.sh +++ b/t/t5409-colorize-remote-messages.sh @@ -32,32 +32,32 @@ test_expect_success 'setup' ' test_expect_success 'keywords' ' git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/keywords 2>output && test_decode_color decoded && - grep "error: error" decoded && - grep "hint:" decoded && - grep "success:" decoded && - grep "SUCCESS" decoded && - grep "warning:" decoded + test_grep "error: error" decoded && + test_grep "hint:" decoded && + test_grep "success:" decoded && + test_grep "SUCCESS" decoded && + test_grep "warning:" decoded ' test_expect_success 'whole words at line start' ' git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/whole-words 2>output && test_decode_color decoded && - grep "hint:" decoded && - grep "hinting: not highlighted" decoded && - grep "prefixerror: error" decoded + test_grep "hint:" decoded && + test_grep "hinting: not highlighted" decoded && + test_grep "prefixerror: error" decoded ' test_expect_success 'short line' ' git -C child -c color.remote=always push -f origin HEAD:short-line 2>output && test_decode_color decoded && - grep "remote: Err" decoded + test_grep "remote: Err" decoded ' test_expect_success 'case-insensitive' ' git --git-dir child/.git -c color.remote=always push -f origin HEAD:refs/heads/case-insensitive 2>output && test_decode_color decoded && - grep "error: error" decoded && - grep "ERROR: also highlighted" decoded + test_grep "error: error" decoded && + test_grep "ERROR: also highlighted" decoded ' test_expect_success 'leading space' ' @@ -69,33 +69,33 @@ test_expect_success 'leading space' ' test_expect_success 'spaces only' ' git -C child -c color.remote=always push -f origin HEAD:only-space 2>output && test_decode_color decoded && - grep "remote: " decoded + test_grep "remote: " decoded ' test_expect_success 'no coloring for redirected output' ' git --git-dir child/.git push -f origin HEAD:refs/heads/redirected-output 2>output && test_decode_color decoded && - grep "error: error" decoded + test_grep "error: error" decoded ' test_expect_success 'push with customized color' ' git --git-dir child/.git -c color.remote=always -c color.remote.error=blue push -f origin HEAD:refs/heads/customized-color 2>output && test_decode_color decoded && - grep "error:" decoded && - grep "success:" decoded + test_grep "error:" decoded && + test_grep "success:" decoded ' test_expect_success 'error in customized color' ' git --git-dir child/.git -c color.remote=always -c color.remote.error=i-am-not-a-color push -f origin HEAD:refs/heads/error-customized-color 2>output && test_decode_color decoded && - grep "success:" decoded + test_grep "success:" decoded ' test_expect_success 'fallback to color.ui' ' git --git-dir child/.git -c color.ui=always push -f origin HEAD:refs/heads/fallback-color-ui 2>output && test_decode_color decoded && - grep "error: error" decoded + test_grep "error: error" decoded ' test_expect_success 'disallow (color) control sequences in sideband' ' diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 649a615ec9af15..7270684f4be5fa 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -135,15 +135,15 @@ test_expect_success 'single given branch clone' ' GIT_TRACE2_EVENT="$(pwd)/branch-a/trace2_event" \ git clone --single-branch --branch A "file://$(pwd)/." branch-a && test_must_fail git --git-dir=branch-a/.git rev-parse origin/B && - grep \"fetch-info\".*\"haves\":0 branch-a/trace2_event && - grep \"fetch-info\".*\"wants\":1 branch-a/trace2_event + test_grep \"fetch-info\".*\"haves\":0 branch-a/trace2_event && + test_grep \"fetch-info\".*\"wants\":1 branch-a/trace2_event ' test_expect_success 'clone shallow depth 1' ' GIT_TRACE2_EVENT="$(pwd)/shallow0/trace2_event" \ git clone --no-single-branch --depth 1 "file://$(pwd)/." shallow0 && test "$(git --git-dir=shallow0/.git rev-list --count HEAD)" = 1 && - grep \"fetch-info\".*\"depth\":1 shallow0/trace2_event + test_grep \"fetch-info\".*\"depth\":1 shallow0/trace2_event ' test_expect_success 'clone shallow depth 1 with fsck' ' @@ -167,7 +167,7 @@ test_expect_success 'clone shallow object count' ' cd shallow && git count-objects -v ) > count.shallow && - grep "^in-pack: 12" count.shallow + test_grep "^in-pack: 12" count.shallow ' test_expect_success 'clone shallow object count (part 2)' ' @@ -230,7 +230,7 @@ test_expect_success 'clone shallow object count' ' cd shallow && git count-objects -v ) > count.shallow && - grep "^count: 6" count.shallow + test_grep "^count: 6" count.shallow ' test_expect_success 'add two more (part 2)' ' @@ -243,8 +243,8 @@ test_expect_success 'deepening pull in shallow repo' ' cd shallow && GIT_TRACE2_EVENT="$(pwd)/trace2_event" \ git pull --depth 4 .. B && - grep \"fetch-info\".*\"depth\":4 trace2_event && - grep \"fetch-info\".*\"shallows\":2 trace2_event + test_grep \"fetch-info\".*\"depth\":4 trace2_event && + test_grep \"fetch-info\".*\"shallows\":2 trace2_event ) ' @@ -253,7 +253,7 @@ test_expect_success 'clone shallow object count' ' cd shallow && git count-objects -v ) > count.shallow && - grep "^count: 12" count.shallow + test_grep "^count: 12" count.shallow ' test_expect_success 'deepening fetch in shallow repo' ' @@ -268,7 +268,7 @@ test_expect_success 'clone shallow object count' ' cd shallow && git count-objects -v ) > count.shallow && - grep "^count: 18" count.shallow + test_grep "^count: 18" count.shallow ' test_expect_success 'pull in shallow repo with missing merge base' ' @@ -298,7 +298,7 @@ test_expect_success 'clone shallow object count' ' git prune && git count-objects -v ) > count.shallow && - grep "^count: 54" count.shallow + test_grep "^count: 54" count.shallow ' test_expect_success 'fetch --no-shallow on full repo' ' @@ -319,8 +319,8 @@ test_expect_success 'turn shallow to complete repository' ' git fetch --unshallow && ! test -f .git/shallow && git fsck --full && - grep \"fetch-info\".*\"shallows\":2 trace2_event && - grep \"fetch-info\".*\"depth\":2147483647 trace2_event + test_grep \"fetch-info\".*\"shallows\":2 trace2_event && + test_grep \"fetch-info\".*\"depth\":2147483647 trace2_event ) ' @@ -333,7 +333,7 @@ test_expect_success 'clone shallow object count' ' cd shallow2 && git count-objects -v ) > count.shallow2 && - grep "^in-pack: 3" count.shallow2 + test_grep "^in-pack: 3" count.shallow2 ' test_expect_success 'clone shallow with --branch' ' @@ -446,7 +446,7 @@ test_expect_success 'in_vain reset upon ACK' ' # and should reset in_vain. This allows negotiation to continue until # the client reports that first_anotherbranch_commit is common. GIT_TRACE2_EVENT="$(pwd)/trace2" git -C myclient fetch --progress origin main 2>log && - grep \"key\":\"total_rounds\",\"value\":\"6\" trace2 && + test_grep \"key\":\"total_rounds\",\"value\":\"6\" trace2 && test_grep "Total 3 " log ' @@ -852,7 +852,7 @@ test_expect_success 'fetch shallow since ...' ' two EOF test_cmp expected actual && - grep \"fetch-info\".*\"deepen-since\":true shallow11/trace2_event + test_grep \"fetch-info\".*\"deepen-since\":true shallow11/trace2_event ' test_expect_success 'clone shallow since selects no commits' ' @@ -935,7 +935,7 @@ test_expect_success 'fetch exclude tag one as revision' ' test_when_finished rm -f rev err && git -C shallow-exclude rev-parse one >rev && test_must_fail git -C shallow12 fetch --shallow-exclude $(cat rev) origin 2>err && - grep "deepen-not is not a ref:" err + test_grep "deepen-not is not a ref:" err ' test_expect_success 'fetching deepen' ' @@ -1005,17 +1005,17 @@ test_negotiation_algorithm_default () { cp -r client clientv0 && GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \ "$@" fetch origin server_has both_have_2 && - grep "have $(git -C client rev-parse client_has)" trace && - grep "have $(git -C client rev-parse both_have_2)" trace && - ! grep "have $(git -C client rev-parse both_have_2^)" trace && + test_grep "have $(git -C client rev-parse client_has)" trace && + test_grep "have $(git -C client rev-parse both_have_2)" trace && + test_grep ! "have $(git -C client rev-parse both_have_2^)" trace && rm -f trace && cp -r client clientv2 && GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv2 -c protocol.version=2 \ "$@" fetch origin server_has both_have_2 && - grep "have $(git -C client rev-parse client_has)" trace && - grep "have $(git -C client rev-parse both_have_2)" trace && - ! grep "have $(git -C client rev-parse both_have_2^)" trace + test_grep "have $(git -C client rev-parse client_has)" trace && + test_grep "have $(git -C client rev-parse both_have_2)" trace && + test_grep ! "have $(git -C client rev-parse both_have_2^)" trace } test_expect_success 'use ref advertisement to prune "have" lines sent' ' @@ -1059,9 +1059,9 @@ test_expect_success 'filtering by size' ' commit=$(git -C server rev-parse HEAD) && blob=$(git hash-object server/one.t) && git -C client rev-list --objects --missing=allow-any "$commit" >oids && - ! grep "$blob" oids && + test_grep ! "$blob" oids && - grep \"fetch-info\".*\"filter\":\"blob:limit\" client/trace2_event + test_grep \"fetch-info\".*\"filter\":\"blob:limit\" client/trace2_event ' test_expect_success 'filtering by size has no effect if support for it is not advertised' ' @@ -1076,7 +1076,7 @@ test_expect_success 'filtering by size has no effect if support for it is not ad commit=$(git -C server rev-parse HEAD) && blob=$(git hash-object server/one.t) && git -C client rev-list --objects --missing=allow-any "$commit" >oids && - grep "$blob" oids && + test_grep "$blob" oids && test_grep "filtering not recognized by server" err ' @@ -1100,8 +1100,8 @@ fetch_filter_blob_limit_zero () { commit=$(git -C "$SERVER" rev-parse two) && blob=$(git hash-object "$SERVER/two.t") && git -C client rev-list --objects --missing=allow-any "$commit" >oids && - grep "$commit" oids && - ! grep "$blob" oids + test_grep "$commit" oids && + test_grep ! "$blob" oids } test_expect_success 'fetch with --filter=blob:limit=0' ' diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 438250c75ed0a2..75b2b87999a08d 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -298,13 +298,13 @@ test_expect_success 'push with receive.fsck.missingEmail=warn' ' git --git-dir=dst/.git config \ receive.fsck.missingEmail warn && git push --porcelain dst bogus >act 2>&1 && - grep "missingEmail" act && + test_grep "missingEmail" act && test_grep "skipping unknown msg id.*whatever" act && git --git-dir=dst/.git branch -D bogus && git --git-dir=dst/.git config --add \ receive.fsck.missingEmail ignore && git push --porcelain dst bogus >act 2>&1 && - ! grep "missingEmail" act + test_grep ! "missingEmail" act ' test_expect_success 'fetch with fetch.fsck.missingEmail=warn' ' @@ -326,7 +326,7 @@ test_expect_success 'fetch with fetch.fsck.missingEmail=warn' ' git --git-dir=dst/.git config \ fetch.fsck.missingEmail warn && git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && - grep "missingEmail" act && + test_grep "missingEmail" act && test_grep "Skipping unknown msg id.*whatever" act && rm -rf dst && git init dst && @@ -334,7 +334,7 @@ test_expect_success 'fetch with fetch.fsck.missingEmail=warn' ' git --git-dir=dst/.git config \ fetch.fsck.missingEmail ignore && git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 && - ! grep "missingEmail" act + test_grep ! "missingEmail" act ' test_expect_success \ @@ -345,7 +345,7 @@ test_expect_success \ git --git-dir=dst/.git config \ receive.fsck.unterminatedheader warn && test_must_fail git push --porcelain dst HEAD >act 2>&1 && - grep "Cannot demote unterminatedheader" act + test_grep "Cannot demote unterminatedheader" act ' test_expect_success \ @@ -356,7 +356,7 @@ test_expect_success \ git --git-dir=dst/.git config \ fetch.fsck.unterminatedheader warn && test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" HEAD && - grep "Cannot demote unterminatedheader" act + test_grep "Cannot demote unterminatedheader" act ' test_expect_success PERL_TEST_HELPERS 'badFilemode is not a strict error' ' @@ -373,7 +373,7 @@ test_expect_success PERL_TEST_HELPERS 'badFilemode is not a strict error' ' git -C dst.git config transfer.fsckObjects true && git -C badmode.git push ../dst.git $tree:refs/tags/tree 2>err && - grep "$tree: badFilemode" err + test_grep "$tree: badFilemode" err ' test_done diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index e592c0bcde91e9..6f5e86dedeb209 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -91,28 +91,28 @@ test_expect_success 'filters for promisor remotes are listed by git remote -v' ' test_when_finished "rm -rf pc" && git clone --filter=blob:none "file://$(pwd)/srv.bare" pc && git -C pc remote -v >out && - grep "srv.bare (fetch) \[blob:none\]" out && + test_grep "srv.bare (fetch) \[blob:none\]" out && git -C pc config remote.origin.partialCloneFilter object:type=commit && git -C pc remote -v >out && - grep "srv.bare (fetch) \[object:type=commit\]" out + test_grep "srv.bare (fetch) \[object:type=commit\]" out ' test_expect_success 'filters should not be listed for non promisor remotes (remote -v)' ' test_when_finished "rm -rf pc" && git clone one pc && git -C pc remote -v >out && - ! grep "(fetch) \[.*\]" out + test_grep ! "(fetch) \[.*\]" out ' test_expect_success 'filters are listed by git remote -v only' ' test_when_finished "rm -rf pc" && git clone --filter=blob:none "file://$(pwd)/srv.bare" pc && git -C pc remote >out && - ! grep "\[blob:none\]" out && + test_grep ! "\[blob:none\]" out && git -C pc remote show >out && - ! grep "\[blob:none\]" out + test_grep ! "\[blob:none\]" out ' test_expect_success 'check remote-tracking' ' @@ -261,7 +261,7 @@ test_expect_success 'without subcommand accepts -v' ' test_expect_success 'without subcommand does not take arguments' ' test_expect_code 129 git -C test remote origin 2>err && - grep "^error: unknown subcommand:" err + test_grep "^error: unknown subcommand:" err ' cat >test/expect <../test/output && git tag -l foobar-tag >../test/output && git config remote.origin.tagopt >>../test/output @@ -972,7 +972,7 @@ test_expect_success 'rename a remote' ' GIT_TRACE2_EVENT=$(pwd)/trace \ git remote rename --progress origin upstream && test_region progress "Renaming remote references" trace && - grep "pushRemote" .git/config && + test_grep "pushRemote" .git/config && test -z "$(git for-each-ref refs/remotes/origin)" && test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" && test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" && @@ -989,7 +989,7 @@ test_expect_success 'rename a remote renames repo remote.pushDefault' ' cd four.1 && git config remote.pushDefault origin && git remote rename origin upstream && - grep pushDefault .git/config && + test_grep pushDefault .git/config && test "$(git config --local remote.pushDefault)" = "upstream" ) ' @@ -1198,7 +1198,7 @@ test_expect_success 'remote prune to cause a dangling symref' ' cd eight && git branch -a ) 2>err && - ! grep "points nowhere" err && + test_grep ! "points nowhere" err && ( cd eight && test_must_fail git branch nomore origin diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index eca9a973b5cb16..1a2e5053967c4f 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -750,7 +750,7 @@ test_expect_success 'fetch from GIT URL with a non-applying branch..merge # the strange name is: a\!'b test_expect_success 'quoting of a strangely named repo' ' test_must_fail git fetch "a\\!'\''b" > result 2>&1 && - grep "fatal: '\''a\\\\!'\''b'\''" result + test_grep "fatal: '\''a\\\\!'\''b'\''" result ' test_expect_success 'bundle should record HEAD correctly' ' @@ -904,14 +904,14 @@ test_expect_success 'fetch --dry-run does not touch FETCH_HEAD, but still prints rm -f .git/FETCH_HEAD err && git fetch --dry-run . 2>err && ! test -f .git/FETCH_HEAD && - grep FETCH_HEAD err + test_grep FETCH_HEAD err ' test_expect_success '--no-write-fetch-head does not touch FETCH_HEAD, and does not print what would be written' ' rm -f .git/FETCH_HEAD err && git fetch --no-write-fetch-head . 2>err && ! test -f .git/FETCH_HEAD && - ! grep FETCH_HEAD err + test_grep ! FETCH_HEAD err ' test_expect_success '--write-fetch-head gets defeated by --dry-run' ' @@ -1329,7 +1329,7 @@ test_expect_success 'fetching with auto-gc does not lock up' ' git config maintenance.strategy gc && GIT_ASK_YESNO="$TRASH_DIRECTORY/askyesno" git fetch --verbose >fetch.out 2>&1 && test_grep "Auto packing the repository" fetch.out && - ! grep "Should I try again" fetch.out + test_grep ! "Should I try again" fetch.out ) ' @@ -1338,7 +1338,7 @@ do test_expect_success "$section.hideRefs affects connectivity check" ' GIT_TRACE="$PWD"/trace git -c $section.hideRefs=refs -c \ $section.hideRefs="!refs/tags/" fetch && - grep "git rev-list .*--exclude-hidden=fetch" trace + test_grep "git rev-list .*--exclude-hidden=fetch" trace ' done @@ -1357,9 +1357,9 @@ validate_store_type () { git -C dest count-objects -v >actual && case "$store_type" in packed) - grep "^count: 0$" actual ;; + test_grep "^count: 0$" actual ;; loose) - grep "^packs: 0$" actual ;; + test_grep "^packs: 0$" actual ;; esac || { echo "store_type is $store_type" cat actual @@ -1418,13 +1418,13 @@ setup_negotiation_tip () { check_negotiation_tip () { # Ensure that {alpha,beta}_1 are sent as "have", but not {alpha_beta}_2 ALPHA_1=$(git -C client rev-parse alpha_1) && - grep "fetch> have $ALPHA_1" trace && + test_grep "fetch> have $ALPHA_1" trace && BETA_1=$(git -C client rev-parse beta_1) && - grep "fetch> have $BETA_1" trace && + test_grep "fetch> have $BETA_1" trace && ALPHA_2=$(git -C client rev-parse alpha_2) && - ! grep "fetch> have $ALPHA_2" trace && + test_grep ! "fetch> have $ALPHA_2" trace && BETA_2=$(git -C client rev-parse beta_2) && - ! grep "fetch> have $BETA_2" trace + test_grep ! "fetch> have $BETA_2" trace } test_expect_success '--negotiation-tip limits "have" lines sent' ' diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 5930f55186db23..fe44f39871cde9 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -245,8 +245,8 @@ do git config --add $configsection.hiderefs "!refs/tags/magic" && git config --add $configsection.hiderefs refs/tags/magic/one && git ls-remote . >actual && - grep refs/tags/magic/two actual && - ! grep refs/tags/magic/one actual + test_grep refs/tags/magic/two actual && + test_grep ! refs/tags/magic/one actual ' done @@ -255,13 +255,13 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs' test_config uploadpack.hiderefs refs/tags && test_config transfer.hiderefs "!refs/tags/magic" && git ls-remote . >actual && - grep refs/tags/magic actual + test_grep refs/tags/magic actual ' test_expect_success 'protocol v2 supports hiderefs' ' test_config uploadpack.hiderefs refs/tags && git -c protocol.version=2 ls-remote . >actual && - ! grep refs/tags actual + test_grep ! refs/tags actual ' test_expect_success 'ls-remote --symref' ' diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh index 523aff626828ae..5d79472c39f671 100755 --- a/t/t5514-fetch-multiple.sh +++ b/t/t5514-fetch-multiple.sh @@ -217,7 +217,7 @@ test_expect_success 'parallel' ' test_must_fail env GIT_TRACE="$PWD/trace" \ git fetch --jobs=2 --multiple one two 2>err && - grep "preparing to run up to 2 tasks" trace && + test_grep "preparing to run up to 2 tasks" trace && test_grep "could not fetch .one.*128" err && test_grep "could not fetch .two.*128" err ' diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 4d1672de1e264b..1f7c9eaccb0c7b 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -124,7 +124,7 @@ do do test_expect_success "reject 'git $cmd --no-$opt'" ' test_must_fail git $cmd --no-$opt 2>err && - grep "unknown option .no-$opt" err + test_grep "unknown option .no-$opt" err ' done done @@ -190,7 +190,7 @@ test_expect_success 'fetch with pushInsteadOf (should not rewrite)' ' grep_wrote () { object_count=$1 file_name=$2 - grep 'write_pack_file/wrote.*"value":"'$1'"' $2 + test_grep 'write_pack_file/wrote.*"value":"'$1'"' $2 } test_expect_success 'push without negotiation' ' @@ -212,7 +212,7 @@ test_expect_success 'push with negotiation' ' GIT_TRACE2_EVENT="$(pwd)/event" \ git -c protocol.version=2 -c push.negotiate=1 \ push testrepo refs/heads/main:refs/remotes/origin/main && - grep \"key\":\"total_rounds\",\"value\":\"1\" event && + test_grep \"key\":\"total_rounds\",\"value\":\"1\" event && grep_wrote 2 event # 1 commit, 1 tree ' @@ -250,8 +250,8 @@ test_expect_success 'push with negotiation does not attempt to fetch submodules' GIT_TRACE2_EVENT="$(pwd)/event" git -c submodule.recurse=true \ -c protocol.version=2 -c push.negotiate=1 \ push testrepo refs/heads/main:refs/remotes/origin/main 2>err && - grep \"key\":\"total_rounds\",\"value\":\"1\" event && - ! grep "Fetching submodule" err + test_grep \"key\":\"total_rounds\",\"value\":\"1\" event && + test_grep ! "Fetching submodule" err ' test_expect_success 'push with negotiation and remote..negotiationInclude' ' @@ -637,7 +637,7 @@ test_expect_success 'push rejects empty branch name entries' ' test_config branch.main.remote one && test_config branch.main.merge refs/heads/main && test_must_fail git push 2>err && - grep "bad config variable .branch\.\." err + test_grep "bad config variable .branch\.\." err ' test_expect_success 'push ignores "branch." config without subsection' ' @@ -923,7 +923,7 @@ test_expect_success 'warn on push to HEAD of non-bare repository' ' git config receive.denyCurrentBranch warn ) && git push testrepo main 2>stderr && - grep "warning: updating the current branch" stderr + test_grep "warning: updating the current branch" stderr ' test_expect_success 'deny push to HEAD of non-bare repository' ' @@ -945,7 +945,7 @@ test_expect_success 'allow push to HEAD of bare repository (bare)' ' git config core.bare true ) && git push testrepo main 2>stderr && - ! grep "warning: updating the current branch" stderr + test_grep ! "warning: updating the current branch" stderr ' test_expect_success 'allow push to HEAD of non-bare repository (config)' ' @@ -956,7 +956,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' ' git config receive.denyCurrentBranch false ) && git push testrepo main 2>stderr && - ! grep "warning: updating the current branch" stderr + test_grep ! "warning: updating the current branch" stderr ' test_expect_success !WITH_BREAKING_CHANGES 'fetch with branches' ' @@ -1068,7 +1068,7 @@ test_expect_success 'push into aliased refs (inconsistent)' ' git commit -a -m child2 && git branch bar && test_must_fail git push ../child1 foo bar 2>stderr && - grep "refusing inconsistent update" stderr + test_grep "refusing inconsistent update" stderr ) ' @@ -1161,7 +1161,7 @@ test_expect_success 'push --porcelain' ' test_expect_success 'push --porcelain bad url' ' mk_empty testrepo && test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/main:refs/remotes/origin/main && - ! grep -q Done .git/bar + test_grep ! -q Done .git/bar ' test_expect_success 'push --porcelain rejected' ' diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 0e0019347e85e9..27f38ab3c83c85 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -356,8 +356,8 @@ test_expect_success '--rebase with rebase.autostash succeeds on ff' ' echo "dirty" >>dst/file && test_config -C dst rebase.autostash true && git -C dst pull --rebase >actual 2>&1 && - grep -q "Fast-forward" actual && - grep -q "Applied autostash." actual + test_grep -q "Fast-forward" actual && + test_grep -q "Applied autostash." actual ' test_expect_success '--rebase with conflicts shows advice' ' diff --git a/t/t5524-pull-msg.sh b/t/t5524-pull-msg.sh index b2be3605f5a3f0..493156a2b8843f 100755 --- a/t/t5524-pull-msg.sh +++ b/t/t5524-pull-msg.sh @@ -31,7 +31,7 @@ test_expect_success pull ' git pull --no-rebase --log && git log -2 && git cat-file commit HEAD >result && - grep Dollar result + test_grep Dollar result ) ' @@ -44,8 +44,8 @@ test_expect_success '--log=1 limits shortlog length' ' git pull --no-rebase --log=1 && git log -3 && git cat-file commit HEAD >result && - grep Dollar result && - ! grep "second commit" result + test_grep Dollar result && + test_grep ! "second commit" result ) ' diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 1242ee918526ea..24fba58084b403 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -199,7 +199,7 @@ test_expect_success "fetch --recurse-submodules -j2 has the same output behaviou ) && test_must_be_empty actual.out && verify_fetch_result actual.err && - grep "2 tasks" trace.out + test_grep "2 tasks" trace.out ' test_expect_success "fetch alone only fetches superproject" ' @@ -723,25 +723,25 @@ test_expect_success 'fetching submodules respects parallel settings' ' ( cd downstream && GIT_TRACE=$(pwd)/trace.out git fetch && - grep "1 tasks" trace.out && + test_grep "1 tasks" trace.out && >trace.out && GIT_TRACE=$(pwd)/trace.out git fetch --jobs 7 && - grep "7 tasks" trace.out && + test_grep "7 tasks" trace.out && >trace.out && git config submodule.fetchJobs 8 && GIT_TRACE=$(pwd)/trace.out git fetch && - grep "8 tasks" trace.out && + test_grep "8 tasks" trace.out && >trace.out && GIT_TRACE=$(pwd)/trace.out git fetch --jobs 9 && - grep "9 tasks" trace.out && + test_grep "9 tasks" trace.out && >trace.out && GIT_TRACE=$(pwd)/trace.out git -c submodule.fetchJobs=0 fetch && - grep "preparing to run up to [0-9]* tasks" trace.out && - ! grep "up to 0 tasks" trace.out && + test_grep "preparing to run up to [0-9]* tasks" trace.out && + test_grep ! "up to 0 tasks" trace.out && >trace.out ) ' @@ -1073,7 +1073,7 @@ fetch_with_recursion_abort () { git -C "$1" fetch --recurse-submodules 2>&1 | sed "/Fetching submodule $2[^$]/q" >out && - ! grep "Fetching submodule $2[^$]" out + test_grep ! "Fetching submodule $2[^$]" out } test_expect_success 'setup recursive fetch with uninit submodule' ' @@ -1259,7 +1259,7 @@ test_expect_success "fetch --all with --no-recurse-submodules only fetches super git config submodule.recurse true && git fetch --all --no-recurse-submodules 2>../fetch-log ) && - ! grep "Fetching submodule" fetch-log + test_grep ! "Fetching submodule" fetch-log ' test_done diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh index 80b06a0cd2886d..35b1f212a8156f 100755 --- a/t/t5529-push-errors.sh +++ b/t/t5529-push-errors.sh @@ -44,14 +44,14 @@ test_expect_success 'detect missing sha1 expressions early' ' # 'builtin/push.c:set_refspecs()' and we want to test that regression. test_expect_success 'detect empty remote with existing local ref' ' test_must_fail git push "" main 2> stderr && - grep "fatal: bad repository ${SQ}${SQ}" stderr + test_grep "fatal: bad repository ${SQ}${SQ}" stderr ' # While similar to the previous test, here we want to ensure that # even targeted refspecs are handled. test_expect_success 'detect empty remote with targeted refspec' ' test_must_fail git push "" HEAD:refs/heads/main 2> stderr && - grep "fatal: bad repository ${SQ}${SQ}" stderr + test_grep "fatal: bad repository ${SQ}${SQ}" stderr ' test_expect_success 'detect ambiguous refs early' ' diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh index d40292cfb7b48f..25d409fc94d2be 100755 --- a/t/t5530-upload-pack-error.sh +++ b/t/t5530-upload-pack-error.sh @@ -44,16 +44,16 @@ test_expect_success 'upload-pack fails due to error in rev-list' ' $(($hexsz + 10)) $(git rev-parse HEAD) \ $(($hexsz + 12)) $(git rev-parse HEAD^) >input && test_must_fail git upload-pack . /dev/null 2>output.err && - grep "bad tree object" output.err + test_grep "bad tree object" output.err ' test_expect_success 'upload-pack fails due to bad want (no object)' ' printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ $(($hexsz + 29)) $(test_oid deadbeef) >input && test_must_fail git upload-pack . output 2>output.err && - grep "not our ref" output.err && - grep "ERR" output && - ! grep multi_ack_detailed output.err + test_grep "not our ref" output.err && + test_grep "ERR" output && + test_grep ! multi_ack_detailed output.err ' test_expect_success 'upload-pack fails due to bad want (not tip)' ' @@ -61,17 +61,17 @@ test_expect_success 'upload-pack fails due to bad want (not tip)' ' printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \ $(($hexsz + 29)) "$oid" >input && test_must_fail git upload-pack . output 2>output.err && - grep "not our ref" output.err && - grep "ERR" output && - ! grep multi_ack_detailed output.err + test_grep "not our ref" output.err && + test_grep "ERR" output && + test_grep ! multi_ack_detailed output.err ' test_expect_success 'upload-pack fails due to error in pack-objects enumeration' ' printf "%04xwant %s\n00000009done\n0000" \ $((hexsz + 10)) $(git rev-parse HEAD) >input && test_must_fail git upload-pack . /dev/null 2>output.err && - grep "bad tree object" output.err && - grep "pack-objects died" output.err + test_grep "bad tree object" output.err && + test_grep "pack-objects died" output.err ' test_expect_success 'upload-pack tolerates EOF just after stateless client wants' ' diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh index 05debd1134db49..7d239dd31f5ef6 100755 --- a/t/t5531-deep-submodule-push.sh +++ b/t/t5531-deep-submodule-push.sh @@ -559,7 +559,7 @@ test_expect_success 'push with push.recurseSubmodules=only on superproject and t test_must_fail git -C upstream rev-parse refs/heads/downstream-branch && git -C upstream/sub rev-parse refs/heads/downstream-branch && git -C upstream/sub/deepsub rev-parse refs/heads/downstream-branch && - grep "recursing into submodule with push.recurseSubmodules=only; using on-demand instead" err + test_grep "recursing into submodule with push.recurseSubmodules=only; using on-demand instead" err ' test_expect_success 'push propagating the remotes name to a submodule' ' diff --git a/t/t5532-fetch-proxy.sh b/t/t5532-fetch-proxy.sh index 95d0f33b29531c..ccbca7c2f28e97 100755 --- a/t/t5532-fetch-proxy.sh +++ b/t/t5532-fetch-proxy.sh @@ -52,7 +52,7 @@ test_expect_success 'fetch through proxy works' ' test_expect_success 'funny hostnames are rejected before running proxy' ' test_must_fail git fetch git://-remote/repo.git 2>stderr && - ! grep "proxying for" stderr + test_grep ! "proxying for" stderr ' test_done diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index cba26a872dde46..2e14aecaa2ba29 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -69,7 +69,7 @@ test_expect_success 'push to update (protected)' ' cd dst && test_commit D && test_must_fail git push --force-with-lease=main:main origin main 2>err && - grep "stale info" err + test_grep "stale info" err ) && git ls-remote . refs/heads/main >expect && git ls-remote src refs/heads/main >actual && @@ -82,7 +82,7 @@ test_expect_success 'push to update (protected, forced)' ' cd dst && test_commit D && git push --force --force-with-lease=main:main origin main 2>err && - grep "forced update" err + test_grep "forced update" err ) && git ls-remote dst refs/heads/main >expect && git ls-remote src refs/heads/main >actual && @@ -147,7 +147,7 @@ test_expect_success 'push to update (allowed, tracking)' ' cd dst && test_commit D && git push --force-with-lease=main origin main 2>err && - ! grep "forced update" err + test_grep ! "forced update" err ) && git ls-remote dst refs/heads/main >expect && git ls-remote src refs/heads/main >actual && @@ -161,7 +161,7 @@ test_expect_success 'push to update (allowed even though no-ff)' ' git reset --hard HEAD^ && test_commit D && git push --force-with-lease=main origin main 2>err && - grep "forced update" err + test_grep "forced update" err ) && git ls-remote dst refs/heads/main >expect && git ls-remote src refs/heads/main >actual && @@ -194,7 +194,7 @@ test_expect_success 'push to delete (allowed)' ' ( cd dst && git push --force-with-lease=main origin :main 2>err && - grep deleted err + test_grep deleted err ) && git ls-remote src refs/heads/main >actual && test_must_be_empty actual @@ -350,7 +350,7 @@ test_expect_success '"--force-if-includes" should be disabled for --force-with-l remote_head="$(git rev-parse refs/remotes/origin/main)" && git fetch --all && test_must_fail git push --force-if-includes --force-with-lease="main:$remote_head" 2>err && - grep "stale info" err + test_grep "stale info" err ) && git ls-remote dst refs/heads/main >actual.main && test_cmp expect.main actual.main diff --git a/t/t5534-push-signed.sh b/t/t5534-push-signed.sh index 2a782214ee1f64..21f0262cbdf09a 100755 --- a/t/t5534-push-signed.sh +++ b/t/t5534-push-signed.sh @@ -126,8 +126,8 @@ test_expect_success GPG 'signed push sends push certificate' ' noop=$(git rev-parse noop) && ff=$(git rev-parse ff) && noff=$(git rev-parse noff) && - grep "$noop $ff refs/heads/ff" dst/push-cert && - grep "$noop $noff refs/heads/noff" dst/push-cert && + test_grep "$noop $ff refs/heads/ff" dst/push-cert && + test_grep "$noop $noff refs/heads/noff" dst/push-cert && test_cmp expect dst/push-cert-status ' @@ -172,8 +172,8 @@ test_expect_success GPGSSH 'ssh signed push sends push certificate' ' noop=$(git rev-parse noop) && ff=$(git rev-parse ff) && noff=$(git rev-parse noff) && - grep "$noop $ff refs/heads/ff" dst/push-cert && - grep "$noop $noff refs/heads/noff" dst/push-cert && + test_grep "$noop $ff refs/heads/ff" dst/push-cert && + test_grep "$noop $noff refs/heads/noff" dst/push-cert && test_cmp expect dst/push-cert-status ' @@ -211,7 +211,7 @@ test_expect_success GPG 'inconsistent push options in signed push not allowed' ' git -C dst config receive.advertisepushoptions 1 && git receive-pack dst out && git -C dst rev-parse ff && - grep "inconsistent push options" out + test_grep "inconsistent push options" out ' test_expect_success GPG 'fail without key and heed user.signingkey' ' @@ -257,8 +257,8 @@ test_expect_success GPG 'fail without key and heed user.signingkey' ' noop=$(git rev-parse noop) && ff=$(git rev-parse ff) && noff=$(git rev-parse noff) && - grep "$noop $ff refs/heads/ff" dst/push-cert && - grep "$noop $noff refs/heads/noff" dst/push-cert && + test_grep "$noop $ff refs/heads/ff" dst/push-cert && + test_grep "$noop $noff refs/heads/noff" dst/push-cert && test_cmp expect dst/push-cert-status ' @@ -309,8 +309,8 @@ test_expect_success GPGSM 'fail without key and heed user.signingkey x509' ' noop=$(git rev-parse noop) && ff=$(git rev-parse ff) && noff=$(git rev-parse noff) && - grep "$noop $ff refs/heads/ff" dst/push-cert && - grep "$noop $noff refs/heads/noff" dst/push-cert && + test_grep "$noop $ff refs/heads/ff" dst/push-cert && + test_grep "$noop $noff refs/heads/noff" dst/push-cert && test_cmp expect dst/push-cert-status ' @@ -362,8 +362,8 @@ test_expect_success GPGSSH 'fail without key and heed user.signingkey ssh' ' noop=$(git rev-parse noop) && ff=$(git rev-parse ff) && noff=$(git rev-parse noff) && - grep "$noop $ff refs/heads/ff" dst/push-cert && - grep "$noop $noff refs/heads/noff" dst/push-cert && + test_grep "$noop $ff refs/heads/ff" dst/push-cert && + test_grep "$noop $noff refs/heads/noff" dst/push-cert && test_cmp expect dst/push-cert-status ' diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index 9982dd2aa6d499..f323ceebd2a7c2 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -244,7 +244,7 @@ test_expect_success '.git/shallow is edited by repack' ' origin "+refs/heads/*:refs/remotes/origin/*" && git -C shallow-client repack -adfl && test_must_fail git -C shallow-client rev-parse --verify $d^0 && - ! grep $d shallow-client/.git/shallow && + test_grep ! $d shallow-client/.git/shallow && git -C shallow-server branch branch-orig $d && git -C shallow-client fetch --prune --depth=2 \ diff --git a/t/t5538-push-shallow.sh b/t/t5538-push-shallow.sh index dc0e972943a6f6..afab456b327049 100755 --- a/t/t5538-push-shallow.sh +++ b/t/t5538-push-shallow.sh @@ -65,7 +65,7 @@ test_expect_success 'push from shallow clone, with grafted roots' ' ( cd shallow2 && test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err && - grep "shallow2/main.*shallow update not allowed" err + test_grep "shallow2/main.*shallow update not allowed" err ) && test_must_fail git rev-parse shallow2/main && git fsck diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh index 3ea75d34ca0e7a..44e6f609dff761 100755 --- a/t/t5539-fetch-http-shallow.sh +++ b/t/t5539-fetch-http-shallow.sh @@ -76,8 +76,8 @@ test_expect_success 'no shallow lines after receiving ACK ready' ' # might be able to run this test in all protocol versions. GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \ git fetch --depth=2 && - grep "fetch-pack< ACK .* ready" ../trace && - ! grep "fetch-pack> done" ../trace + test_grep "fetch-pack< ACK .* ready" ../trace && + test_grep ! "fetch-pack> done" ../trace ) ' diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 538b603f03a1f8..8c348330277907 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -56,8 +56,8 @@ test_expect_success 'push to remote repository (standard)' ' git commit -m path2 && HEAD=$(git rev-parse --verify HEAD) && GIT_TRACE_CURL=true git push -v -v 2>err && - ! grep "Expect: 100-continue" err && - grep "POST git-receive-pack ([0-9]* bytes)" err && + test_grep ! "Expect: 100-continue" err && + test_grep "POST git-receive-pack ([0-9]* bytes)" err && (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && test $HEAD = $(git rev-parse --verify HEAD)) ' @@ -84,7 +84,7 @@ test_expect_success 'push to remote repository (standard) with sending Accept-La git commit -m path_lang && HEAD=$(git rev-parse --verify HEAD) && GIT_TRACE_CURL=true LANGUAGE="ko_KR.UTF-8" git push -v -v 2>err && - ! grep "Expect: 100-continue" err && + test_grep ! "Expect: 100-continue" err && grep "=> Send header: Accept-Language:" err >err.language && test_cmp exp err.language @@ -148,8 +148,8 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he test_must_fail git push -v origin +main main:niam >output 2>&1' test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' ' - grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *main -> main (forced update)$" output && - grep "^ ! \[rejected\] *main -> niam (non-fast-forward)$" output + test_grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *main -> main (forced update)$" output && + test_grep "^ ! \[rejected\] *main -> niam (non-fast-forward)$" output ' test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: our output' ' @@ -163,7 +163,7 @@ test_expect_success 'push (chunked)' ' HEAD=$(git rev-parse --verify HEAD) && test_config http.postbuffer 4 && git push -v -v origin $BRANCH 2>err && - grep "POST git-receive-pack (chunked)" err && + test_grep "POST git-receive-pack (chunked)" err && (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git && test $HEAD = $(git rev-parse --verify HEAD)) ' @@ -215,15 +215,15 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat test_cmp expected actual && # the failed refs should be indicated to the user - grep "^ ! .*rejected.* main -> main" output && + test_grep "^ ! .*rejected.* main -> main" output && # the collateral failure refs should be indicated to the user - grep "^ ! .*rejected.* atomic -> atomic .*atomic push failed" output && - grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output && + test_grep "^ ! .*rejected.* atomic -> atomic .*atomic push failed" output && + test_grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output && # never report what we do not push - ! grep "^ ! .*rejected.* atomic1 " output && - ! grep "^ ! .*rejected.* other " output + test_grep ! "^ ! .*rejected.* atomic1 " output && + test_grep ! "^ ! .*rejected.* other " output ' test_expect_success 'push --atomic fails on server-side errors' ' @@ -247,10 +247,10 @@ test_expect_success 'push --atomic fails on server-side errors' ' test_must_fail git -C "$d" show-ref --verify refs/heads/other && # the failed refs should be indicated to the user - grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output && + test_grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output && # the collateral failure refs should be indicated to the user - grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output + test_grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output ' test_expect_success 'push --all can push to empty repo' ' @@ -442,7 +442,7 @@ test_expect_success 'push status output scrubs password' ' "$HTTPD_URL_USER_PASS/smart/test_repo.git" \ +HEAD:scrub >status && # should have been scrubbed down to vanilla URL - grep "^To $HTTPD_URL/smart/test_repo.git" status + test_grep "^To $HTTPD_URL/smart/test_repo.git" status ' test_expect_success 'clone/fetch scrubs password from reflogs' ' @@ -456,8 +456,8 @@ test_expect_success 'clone/fetch scrubs password from reflogs' ' +main:main && # should have been scrubbed down to vanilla URL git log -g main >reflog && - grep "$HTTPD_URL" reflog && - ! grep "$HTTPD_URL_USER_PASS" reflog + test_grep "$HTTPD_URL" reflog && + test_grep ! "$HTTPD_URL_USER_PASS" reflog ' test_expect_success 'Non-ASCII branch name can be used with --force-with-lease' ' diff --git a/t/t5544-pack-objects-hook.sh b/t/t5544-pack-objects-hook.sh index 89147a052e72cd..908d3b8ebea08d 100755 --- a/t/t5544-pack-objects-hook.sh +++ b/t/t5544-pack-objects-hook.sh @@ -27,7 +27,7 @@ test_expect_success 'hook runs via global config' ' clear_hook_results && test_config_global uploadpack.packObjectsHook ./hook && git clone --no-local . dst.git 2>stderr && - grep "hook running" stderr + test_grep "hook running" stderr ' test_expect_success 'hook outputs are sane' ' @@ -38,7 +38,7 @@ test_expect_success 'hook outputs are sane' ' # the full argument list or the exact pack contents, as it would make # the test brittle. So just sanity check that we could replay # the packing procedure. - grep "^git" .git/hook.args && + test_grep "^git" .git/hook.args && $(cat .git/hook.args) <.git/hook.stdin >replay ' @@ -47,14 +47,14 @@ test_expect_success 'hook runs from -c config' ' git clone --no-local \ -u "git -c uploadpack.packObjectsHook=./hook upload-pack" \ . dst.git 2>stderr && - grep "hook running" stderr + test_grep "hook running" stderr ' test_expect_success 'hook does not run from repo config' ' clear_hook_results && test_config uploadpack.packObjectsHook "./hook" && git clone --no-local . dst.git 2>stderr && - ! grep "hook running" stderr && + test_grep ! "hook running" stderr && test_path_is_missing .git/hook.args && test_path_is_missing .git/hook.stdin && test_path_is_missing .git/hook.stdout && @@ -62,7 +62,7 @@ test_expect_success 'hook does not run from repo config' ' # check that global config is used instead test_config_global uploadpack.packObjectsHook ./hook && git clone --no-local . dst2.git 2>stderr && - grep "hook running" stderr + test_grep "hook running" stderr ' test_expect_success 'hook works with partial clone' ' @@ -72,7 +72,7 @@ test_expect_success 'hook works with partial clone' ' git clone --bare --no-local --filter=blob:none . dst.git && git -C dst.git rev-list --objects --missing=allow-any --no-object-names --all >objects && git -C dst.git cat-file --batch-check="%(objecttype)" types && - ! grep blob types + test_grep ! blob types ' test_done diff --git a/t/t5546-receive-limits.sh b/t/t5546-receive-limits.sh index f1e61c9f09572e..83efe3e40a5df7 100755 --- a/t/t5546-receive-limits.sh +++ b/t/t5546-receive-limits.sh @@ -12,9 +12,9 @@ validate_store_type () { git -C dest count-objects -v >actual && case "$store_type" in index) - grep "^count: 0$" actual ;; + test_grep "^count: 0$" actual ;; unpack) - grep "^packs: 0$" actual ;; + test_grep "^packs: 0$" actual ;; esac || { echo "store_type is $store_type" cat actual diff --git a/t/t5549-fetch-push-http.sh b/t/t5549-fetch-push-http.sh index 2cdebcb7356332..19d65f4b1eef11 100755 --- a/t/t5549-fetch-push-http.sh +++ b/t/t5549-fetch-push-http.sh @@ -15,7 +15,7 @@ URI="$HTTPD_URL/smart/server" grep_wrote () { object_count=$1 file_name=$2 - grep 'write_pack_file/wrote.*"value":"'$1'"' $2 + test_grep 'write_pack_file/wrote.*"value":"'$1'"' $2 } setup_client_and_server () { diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh index b0080bf2047899..f00eeae48f8554 100755 --- a/t/t5550-http-fetch-dumb.sh +++ b/t/t5550-http-fetch-dumb.sh @@ -124,7 +124,7 @@ test_expect_success 'netrc authorized but forbidden credentials (fail on 403)' ' set_netrc 127.0.0.1 forbidden-user@host pass@host && test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-netrc-403 2>err && expect_askpass none && - grep "The requested URL returned error: 403" err + test_grep "The requested URL returned error: 403" err ' test_expect_success 'http auth can use user/pass in URL' ' @@ -280,7 +280,7 @@ test_expect_success 'http-fetch --packfile' ' --index-pack-arg=--keep \ "$HTTPD_URL"/dumb/repo_pack.git/$p >out && - grep -E "^keep.[0-9a-f]{16,}$" out && + test_grep -E "^keep.[0-9a-f]{16,}$" out && cut -c6- out >packhash && # Ensure that the expected files are generated diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index e236e526f0defb..c127d51b2c68bf 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -164,8 +164,8 @@ test_expect_success 'fetch changes via http' ' test_expect_success 'used upload-pack service' ' strip_access_log >log && - grep "GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/[0-9.]* 200" log && - grep "POST /smart/repo.git/git-upload-pack HTTP/[0-9.]* 200" log + test_grep "GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/[0-9.]* 200" log && + test_grep "POST /smart/repo.git/git-upload-pack HTTP/[0-9.]* 200" log ' test_expect_success 'follow redirects (301)' ' @@ -264,7 +264,7 @@ test_expect_success 'GIT_TRACE_CURL redacts auth details' ' # Ensure that there is no "Basic" followed by a base64 string, but that # the auth details are redacted - ! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace && + test_grep ! -i "Authorization: Basic [0-9a-zA-Z+/]" trace && grep -i "Authorization: Basic " trace ' @@ -276,7 +276,7 @@ test_expect_success 'GIT_CURL_VERBOSE redacts auth details' ' # Ensure that there is no "Basic" followed by a base64 string, but that # the auth details are redacted - ! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace && + test_grep ! -i "Authorization: Basic [0-9a-zA-Z+/]" trace && grep -i "Authorization: Basic " trace ' @@ -287,7 +287,7 @@ test_expect_success 'GIT_TRACE_CURL does not redact auth details if GIT_TRACE_RE git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth && expect_askpass both user%40host && - grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace + test_grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace ' test_expect_success 'disable dumb http on server' ' @@ -553,10 +553,10 @@ test_expect_success 'cookies are redacted by default' ' GIT_TRACE_CURL=true \ git -c "http.cookieFile=$(pwd)/cookies" clone \ $HTTPD_URL/smart/repo.git clone 2>err && - grep -i "Cookie:.*Foo=" err && - grep -i "Cookie:.*Bar=" err && - ! grep -i "Cookie:.*Foo=1" err && - ! grep -i "Cookie:.*Bar=2" err + test_grep -i "Cookie:.*Foo=" err && + test_grep -i "Cookie:.*Bar=" err && + test_grep ! -i "Cookie:.*Foo=1" err && + test_grep ! -i "Cookie:.*Bar=2" err ' test_expect_success 'empty values of cookies are also redacted' ' @@ -565,7 +565,7 @@ test_expect_success 'empty values of cookies are also redacted' ' GIT_TRACE_CURL=true \ git -c "http.cookieFile=$(pwd)/cookies" clone \ $HTTPD_URL/smart/repo.git clone 2>err && - grep -i "Cookie:.*Foo=" err + test_grep -i "Cookie:.*Foo=" err ' test_expect_success 'GIT_TRACE_REDACT=0 disables cookie redaction' ' @@ -575,20 +575,20 @@ test_expect_success 'GIT_TRACE_REDACT=0 disables cookie redaction' ' GIT_TRACE_REDACT=0 GIT_TRACE_CURL=true \ git -c "http.cookieFile=$(pwd)/cookies" clone \ $HTTPD_URL/smart/repo.git clone 2>err && - grep -i "Cookie:.*Foo=1" err && - grep -i "Cookie:.*Bar=2" err + test_grep -i "Cookie:.*Foo=1" err && + test_grep -i "Cookie:.*Bar=2" err ' test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' ' rm -rf clone && GIT_TRACE_CURL=true \ git clone $HTTPD_URL/smart/repo.git clone 2>err && - grep "=> Send data" err && + test_grep "=> Send data" err && rm -rf clone && GIT_TRACE_CURL=true GIT_TRACE_CURL_NO_DATA=1 \ git clone $HTTPD_URL/smart/repo.git clone 2>err && - ! grep "=> Send data" err + test_grep ! "=> Send data" err ' test_expect_success 'server-side error detected' ' @@ -643,7 +643,7 @@ test_expect_success 'client falls back from v2 to v0 to match server' ' git clone $HTTPD_URL/smart_v0/repo.git repo-v0 && # check for v0; there the HEAD symref is communicated in the capability # line; v2 uses a different syntax on each ref advertisement line - grep symref=HEAD:refs/heads/ trace + test_grep symref=HEAD:refs/heads/ trace ' test_expect_success 'create empty http-accessible SHA-256 repository' ' @@ -691,7 +691,7 @@ test_expect_success 'clone warns or fails when using username:password' ' git -c transfer.credentialsInUrl=allow \ clone $url_userpass attempt1 2>err && - ! grep "$message" err && + test_grep ! "$message" err && git -c transfer.credentialsInUrl=warn \ clone $url_userpass attempt2 2>err && @@ -720,12 +720,12 @@ test_expect_success 'clone does not detect username:password when it is https:// esac && git -c transfer.credentialsInUrl=warn clone $url_user attempt1 2>err && - ! grep "uses plaintext credentials" err + test_grep ! "uses plaintext credentials" err ' test_expect_success 'fetch warns or fails when using username:password' ' git -c transfer.credentialsInUrl=allow fetch $url_userpass 2>err && - ! grep "$message" err && + test_grep ! "$message" err && git -c transfer.credentialsInUrl=warn fetch $url_userpass 2>err && grep "warning: $message" err >warnings && @@ -745,7 +745,7 @@ test_expect_success 'fetch warns or fails when using username:password' ' test_expect_success 'push warns or fails when using username:password' ' git -c transfer.credentialsInUrl=allow push $url_userpass 2>err && - ! grep "$message" err && + test_grep ! "$message" err && git -c transfer.credentialsInUrl=warn push $url_userpass 2>err && grep "warning: $message" err >warnings && @@ -762,7 +762,7 @@ test_expect_success 'no empty path components' ' git clone $HTTPD_URL/smart/repo.git/ clone-with-slash && strip_access_log >log && - ! grep "//" log + test_grep ! "//" log ' test_expect_success 'tag following always works over v0 http' ' diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index eeddb85b1deaea..36edda4c66ad4d 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -23,7 +23,7 @@ test_expect_success 'fetch.negotiationalgorithm config' ' have_sent () { while test "$#" -ne 0 do - grep "fetch> have $(git -C client rev-parse $1)" trace + test_grep "fetch> have $(git -C client rev-parse $1)" trace if test $? -ne 0 then echo "No have $(git -C client rev-parse $1) ($1)" @@ -36,7 +36,7 @@ have_sent () { have_not_sent () { while test "$#" -ne 0 do - grep "fetch> have $(git -C client rev-parse $1)" trace + test_grep "fetch> have $(git -C client rev-parse $1)" trace if test $? -eq 0 then return 1 @@ -201,7 +201,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC export GIT_TEST_PROTOCOL_VERSION && trace_fetch client "$(pwd)/server" to_fetch ) && - grep " fetch" trace && + test_grep " fetch" trace && # fetch-pack sends 2 requests each containing 16 "have" lines before # processing the first response. In these 2 requests, 4 commits from @@ -211,8 +211,8 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC # While fetch-pack is processing the first response, it should read that # the server ACKs b1.c19 and b1.c17. - grep "fetch< ACK $(git -C client rev-parse b1.c19) common" trace && - grep "fetch< ACK $(git -C client rev-parse b1.c17) common" trace && + test_grep "fetch< ACK $(git -C client rev-parse b1.c19) common" trace && + test_grep "fetch< ACK $(git -C client rev-parse b1.c17) common" trace && # fetch-pack should thus not send any more commits in the b1 branch, but # should still send the others (in this test, just check b2). diff --git a/t/t5554-noop-fetch-negotiator.sh b/t/t5554-noop-fetch-negotiator.sh index 17e73b606d5324..d50ffe55b6b755 100755 --- a/t/t5554-noop-fetch-negotiator.sh +++ b/t/t5554-noop-fetch-negotiator.sh @@ -16,8 +16,8 @@ test_expect_success 'noop negotiator does not emit any "have"' ' test_config -C client fetch.negotiationalgorithm noop && GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" && - ! grep "fetch> have" trace && - grep "fetch> done" trace + test_grep ! "fetch> have" trace && + test_grep "fetch> done" trace ' test_done diff --git a/t/t5557-http-get.sh b/t/t5557-http-get.sh index 67fcc23f1105c1..e8ffe3f8e9714b 100755 --- a/t/t5557-http-get.sh +++ b/t/t5557-http-get.sh @@ -18,7 +18,7 @@ test_expect_success 'get by URL: 404' ' test_must_fail git remote-http $url err && test_path_is_missing file1 && - grep "failed to download file at URL" err + test_grep "failed to download file at URL" err ' test_expect_success 'get by URL: 200' ' diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh index 7a0943bd365a1a..f58647422da042 100755 --- a/t/t5558-clone-bundle-uri.sh +++ b/t/t5558-clone-bundle-uri.sh @@ -8,14 +8,14 @@ test_description='test fetching bundles with --bundle-uri' test_expect_success 'fail to clone from non-existent file' ' test_when_finished rm -rf test && git clone --bundle-uri="$(pwd)/does-not-exist" . test 2>err && - grep "failed to download bundle from URI" err + test_grep "failed to download bundle from URI" err ' test_expect_success 'fail to clone from non-bundle file' ' test_when_finished rm -rf test && echo bogus >bogus && git clone --bundle-uri="$(pwd)/bogus" . test 2>err && - grep "is not a bundle" err + test_grep "is not a bundle" err ' test_expect_success 'create bundle' ' @@ -197,7 +197,7 @@ test_expect_success 'clone bundle list (file, no heuristic)' ' git clone --bundle-uri="file://$(pwd)/bundle-list" \ clone-from clone-list-file 2>err && - ! grep "Repository lacks these prerequisite commits" err && + test_grep ! "Repository lacks these prerequisite commits" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-list-file cat-file --batch-check err && - ! grep "Repository lacks these prerequisite commits" err && - ! grep "fatal" err && - grep "warning: failed to download bundle from URI" err && + test_grep ! "Repository lacks these prerequisite commits" err && + test_grep ! "fatal" err && + test_grep "warning: failed to download bundle from URI" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-all-some cat-file --batch-check err && - ! grep "Repository lacks these prerequisite commits" err && - ! grep "fatal" err && - grep "warning: failed to download bundle from URI" err && + test_grep ! "Repository lacks these prerequisite commits" err && + test_grep ! "fatal" err && + test_grep "warning: failed to download bundle from URI" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-all-fail cat-file --batch-check refs && - ! grep "refs/bundles/heads/" refs + test_grep ! "refs/bundles/heads/" refs ' test_expect_success 'clone bundle list (file, any mode)' ' @@ -306,7 +306,7 @@ test_expect_success 'clone bundle list (file, any mode)' ' git clone --bundle-uri="file://$(pwd)/bundle-list" \ clone-from clone-any-file 2>err && - ! grep "Repository lacks these prerequisite commits" err && + test_grep ! "Repository lacks these prerequisite commits" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-any-file cat-file --batch-check err && - ! grep "fatal" err && - grep "warning: failed to download bundle from URI" err && + test_grep ! "fatal" err && + test_grep "warning: failed to download bundle from URI" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-any-fail cat-file --batch-check refs && - ! grep "refs/bundles/heads/" refs + test_grep ! "refs/bundles/heads/" refs ' test_expect_success 'negotiation: bundle with part of wanted commits' ' @@ -477,14 +477,14 @@ start_httpd test_expect_success 'fail to fetch from non-existent HTTP URL' ' test_when_finished rm -rf test && git clone --bundle-uri="$HTTPD_URL/does-not-exist" . test 2>err && - grep "failed to download bundle from URI" err + test_grep "failed to download bundle from URI" err ' test_expect_success 'fail to fetch from non-bundle HTTP URL' ' test_when_finished rm -rf test && echo bogus >"$HTTPD_DOCUMENT_ROOT_PATH/bogus" && git clone --bundle-uri="$HTTPD_URL/bogus" . test 2>err && - grep "is not a bundle" err + test_grep "is not a bundle" err ' test_expect_success 'clone HTTP bundle' ' @@ -536,7 +536,7 @@ test_expect_success 'clone bundle list (HTTP, no heuristic)' ' GIT_TRACE2_EVENT="$(pwd)/trace-clone.txt" \ git clone --bundle-uri="$HTTPD_URL/bundle-list" \ clone-from clone-list-http 2>err && - ! grep "Repository lacks these prerequisite commits" err && + test_grep ! "Repository lacks these prerequisite commits" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-list-http cat-file --batch-check err && - ! grep "fatal" err && - grep "warning: failed to download bundle from URI" err && + test_grep ! "fatal" err && + test_grep "warning: failed to download bundle from URI" err && git -C clone-from for-each-ref --format="%(objectname)" >oids && git -C clone-any-http cat-file --batch-check bundle-fetches && test_line_count = 1 bundle-fetches ' diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index b6ee06f5c8f597..59c6a50dd29c63 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -163,7 +163,7 @@ test_expect_success 'CONTENT_LENGTH overflow ssite_t' ' REQUEST_METHOD=POST \ CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \ git http-backend /dev/null 2>err && - grep "fatal:.*CONTENT_LENGTH" err + test_grep "fatal:.*CONTENT_LENGTH" err ' test_expect_success 'empty CONTENT_LENGTH' ' diff --git a/t/t5564-http-proxy.sh b/t/t5564-http-proxy.sh index 817cd1f98418d3..acd3f2d14153bf 100755 --- a/t/t5564-http-proxy.sh +++ b/t/t5564-http-proxy.sh @@ -20,7 +20,7 @@ setup_askpass_helper test_expect_success 'proxy requires password' ' test_config_global http.proxy $HTTPD_DEST && test_must_fail git clone $HTTPD_URL/smart/repo.git 2>err && - grep "error.*407" err + test_grep "error.*407" err ' test_expect_success 'clone through proxy with auth' ' @@ -71,7 +71,7 @@ test_atexit ' # later), but this is not easy to test right now. Instead, we || the tests with # this function. old_libcurl_error() { - grep -Fx "fatal: libcurl 7.84 or later is required to support paths in proxy URLs" "$1" + test_grep -Fx "fatal: libcurl 7.84 or later is required to support paths in proxy URLs" "$1" } test_expect_success SOCKS_PROXY 'clone via Unix socket' ' @@ -82,7 +82,7 @@ test_expect_success SOCKS_PROXY 'clone via Unix socket' ' GIT_TRACE_CURL=$PWD/trace \ GIT_TRACE_CURL_COMPONENTS=socks \ git clone "$HTTPD_URL/smart/repo.git" clone 2>err && - grep -i "SOCKS4 request granted" trace + test_grep -i "SOCKS4 request granted" trace } || old_libcurl_error err } diff --git a/t/t5581-http-curl-verbose.sh b/t/t5581-http-curl-verbose.sh index cded79c16b5d60..6788cf817180e3 100755 --- a/t/t5581-http-curl-verbose.sh +++ b/t/t5581-http-curl-verbose.sh @@ -23,7 +23,7 @@ test_expect_success 'failure in git-upload-pack is shown' ' test_might_fail env GIT_CURL_VERBOSE=1 \ git clone "$HTTPD_URL/error_git_upload_pack/smart/repo.git" \ 2>curl_log && - grep "<= Recv header: HTTP/1.1 500 Intentional Breakage" curl_log + test_grep "<= Recv header: HTTP/1.1 500 Intentional Breakage" curl_log ' test_done diff --git a/t/t5583-push-branches.sh b/t/t5583-push-branches.sh index e7e1b6dab66fb3..1ccfaee75ae75f 100755 --- a/t/t5583-push-branches.sh +++ b/t/t5583-push-branches.sh @@ -60,21 +60,21 @@ test_expect_success '--all or --branches can not be combined with refspecs' ' test_must_fail git push remote-1 --all main >actual.all 2>&1 && test_must_fail git push remote-1 --branches main >actual.branches 2>&1 && test_cmp actual.all actual.branches && - grep "be combined with refspecs" actual.all + test_grep "be combined with refspecs" actual.all ' test_expect_success '--all or --branches can not be combined with --mirror' ' test_must_fail git push remote-1 --all --mirror >actual.all 2>&1 && test_must_fail git push remote-1 --branches --mirror >actual.branches 2>&1 && test_cmp actual.all actual.branches && - grep "cannot be used together" actual.all + test_grep "cannot be used together" actual.all ' test_expect_success '--all or --branches can not be combined with --tags' ' test_must_fail git push remote-1 --all --tags >actual.all 2>&1 && test_must_fail git push remote-1 --branches --tags >actual.branches 2>&1 && test_cmp actual.all actual.branches && - grep "cannot be used together" actual.all + test_grep "cannot be used together" actual.all ' @@ -82,7 +82,7 @@ test_expect_success '--all or --branches can not be combined with --delete' ' test_must_fail git push remote-1 --all --delete >actual.all 2>&1 && test_must_fail git push remote-1 --branches --delete >actual.branches 2>&1 && test_cmp actual.all actual.branches && - grep "cannot be used together" actual.all + test_grep "cannot be used together" actual.all ' test_expect_success '--all or --branches combines with --follow-tags have same behavior' ' diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 3dd229c1867244..b6167582a185c0 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -159,8 +159,8 @@ test_expect_success 'clone --mirror does not repeat tags' ' git clone --mirror src mirror2 && (cd mirror2 && git show-ref 2> clone.err > clone.out) && - ! grep Duplicate mirror2/clone.err && - grep some-tag mirror2/clone.out + test_grep ! Duplicate mirror2/clone.err && + test_grep some-tag mirror2/clone.out ' @@ -224,12 +224,12 @@ test_expect_success 'clone a void' ' cd src-0 && git init ) && git clone "file://$(pwd)/src-0" target-6 2>err-6 && - ! grep "fatal:" err-6 && + test_grep ! "fatal:" err-6 && ( cd src-0 && test_commit A ) && git clone "file://$(pwd)/src-0" target-7 2>err-7 && - ! grep "fatal:" err-7 && + test_grep ! "fatal:" err-7 && # There is no reason to insist they are bit-for-bit # identical, but this test should suffice for now. test_cmp target-6/.git/config target-7/.git/config @@ -298,22 +298,22 @@ test_expect_success 'clone separate gitdir where target already exists' ' rm -rf dst && echo foo=bar >>realgitdir/config && test_must_fail git clone --separate-git-dir realgitdir src dst && - grep foo=bar realgitdir/config + test_grep foo=bar realgitdir/config ' test_expect_success 'clone --reference from original' ' git clone --shared --bare src src-1 && git clone --bare src src-2 && git clone --reference=src-2 --bare src-1 target-8 && - grep /src-2/ target-8/objects/info/alternates + test_grep /src-2/ target-8/objects/info/alternates ' test_expect_success 'clone with more than one --reference' ' git clone --bare src src-3 && git clone --bare src src-4 && git clone --reference=src-3 --reference=src-4 src target-9 && - grep /src-3/ target-9/.git/objects/info/alternates && - grep /src-4/ target-9/.git/objects/info/alternates + test_grep /src-3/ target-9/.git/objects/info/alternates && + test_grep /src-4/ target-9/.git/objects/info/alternates ' test_expect_success 'clone from original with relative alternate' ' @@ -321,7 +321,7 @@ test_expect_success 'clone from original with relative alternate' ' git clone --bare src nest/src-5 && echo ../../../src/.git/objects >nest/src-5/objects/info/alternates && git clone --bare nest/src-5 target-10 && - grep /src/\\.git/objects target-10/objects/info/alternates + test_grep /src/\\.git/objects target-10/objects/info/alternates ' test_expect_success 'clone checking out a tag' ' @@ -663,8 +663,8 @@ test_expect_success PERL_TEST_HELPERS 'clone on case-insensitive fs' ' ' test_expect_success PERL_TEST_HELPERS,CASE_INSENSITIVE_FS 'colliding file detection' ' - grep X icasefs/warning && - grep x icasefs/warning && + test_grep X icasefs/warning && + test_grep x icasefs/warning && test_grep "the following paths have collided" icasefs/warning ' @@ -857,7 +857,7 @@ test_expect_success 'auto-discover bundle URI from HTTP clone' ' cat >pattern <<-EOF && "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\] EOF - grep -f pattern trace.txt + test_grep -f pattern trace.txt ' test_expect_success 'auto-discover multiple bundles from HTTP clone' ' @@ -888,11 +888,11 @@ test_expect_success 'auto-discover multiple bundles from HTTP clone' ' cat >pattern <<-EOF && "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/everything.bundle"\] EOF - grep -f pattern trace.txt && + test_grep -f pattern trace.txt && cat >pattern <<-EOF && "event":"child_start".*"argv":\["git-remote-https","$HTTPD_URL/new.bundle"\] EOF - grep -f pattern trace.txt + test_grep -f pattern trace.txt ' test_expect_success 'auto-discover multiple bundles from HTTP clone: creationToken heuristic' ' diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index c232ab8c15a59d..39a0c318dfb2d4 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -65,7 +65,7 @@ test_expect_success 'cloning with reference (no -l -s)' ' test_expect_success 'fetched no objects' ' test -s "$U.D" && - ! grep " want" "$U.D" + test_grep ! " want" "$U.D" ' test_expect_success 'existence of info/alternates' ' @@ -157,9 +157,9 @@ test_expect_success 'fetch with incomplete alternates' ' ) && main_object=$(git -C A rev-parse --verify refs/heads/main) && test -s "$U.K" && - ! grep " want $main_object" "$U.K" && + test_grep ! " want $main_object" "$U.K" && tag_object=$(git -C A rev-parse --verify refs/tags/foo) && - ! grep " want $tag_object" "$U.K" + test_grep ! " want $tag_object" "$U.K" ' test_expect_success 'clone using repo with gitfile as a reference' ' @@ -357,7 +357,7 @@ test_expect_success SYMLINKS 'clone repo with symlinked objects directory' ' test_must_fail git clone --local malicious clone 2>err && test_path_is_missing clone && - grep "is a symlink, refusing to clone with --local" err + test_grep "is a symlink, refusing to clone with --local" err ' test_expect_success 'dissociate from repo with commit graph' ' diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index 2397f8fa618054..156362f145b071 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -172,7 +172,7 @@ test_expect_success REFFILES 'local clone from repo with corrupt refs fails grac echo a >corrupt/.git/refs/heads/topic && test_must_fail git clone corrupt working 2>err && - grep "has neither a valid OID nor a target" err + test_grep "has neither a valid OID nor a target" err ' test_done diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 8a1523773684bc..1b48da496b346e 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -63,7 +63,7 @@ test_expect_success 'disallows --bundle-uri with shallow options' ' for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD do test_must_fail git clone --bundle-uri=bundle $option from to 2>err && - grep "bundle-uri.* cannot be used together" err || return 1 + test_grep "bundle-uri.* cannot be used together" err || return 1 done ' @@ -147,7 +147,7 @@ test_expect_success 'prefers --origin over -c config' ' test_expect_success 'redirected clone does not show progress' ' git clone "file://$(pwd)/parent" clone-redirected >out 2>err && - ! grep % err && + test_grep ! % err && test_grep ! "Checking connectivity" err ' @@ -156,7 +156,7 @@ test_expect_success 'redirected clone -v does show progress' ' git clone --progress "file://$(pwd)/parent" clone-redirected-progress \ >out 2>err && - grep % err + test_grep % err ' diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh index 3126cfd7e9d6bd..dd1fe0abb46b6a 100755 --- a/t/t5612-clone-refspec.sh +++ b/t/t5612-clone-refspec.sh @@ -97,7 +97,7 @@ test_expect_success 'by default no tags will be kept updated' ' test_expect_success 'clone with --no-tags' ' ( cd dir_all_no_tags && - grep tagOpt .git/config && + test_grep tagOpt .git/config && git fetch && git for-each-ref refs/tags >../actual ) && diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh index 1c2805accac636..ddbf2b72c6cd39 100755 --- a/t/t5616-partial-clone.sh +++ b/t/t5616-partial-clone.sh @@ -60,8 +60,8 @@ test_expect_success 'verify that .promisor file contains refs fetched' ' ls pc1/.git/objects/pack/pack-*.promisor >promisorlist && test_line_count = 1 promisorlist && git -C srv.bare rev-parse --verify HEAD >headhash && - grep "$(cat headhash) HEAD" $(cat promisorlist) && - grep "$(cat headhash) refs/heads/main" $(cat promisorlist) + test_grep "$(cat headhash) HEAD" $(cat promisorlist) && + test_grep "$(cat headhash) refs/heads/main" $(cat promisorlist) ' # checkout main to force dynamic object fetch of blobs at HEAD. @@ -230,8 +230,8 @@ test_expect_success 'fetch --refetch triggers repacking' ' GIT_TRACE2_EVENT="$PWD/trace1.event" \ git -C pc1 fetch --refetch origin && test_subcommand git maintenance run --auto --no-quiet --no-detach tree_contents && - grep file.txt tree_contents && + test_grep file.txt tree_contents && # fsck still works after an auto-fetch of a tree. git -C dst fsck && @@ -333,14 +333,14 @@ test_expect_success 'implicitly construct combine: filter with repeated flags' ' GIT_TRACE=$(pwd)/trace git clone --bare \ --filter=blob:none --filter=tree:1 \ "file://$(pwd)/srv.bare" pc2 && - grep "trace:.* git pack-objects .*--filter=combine:blob:none+tree:1" \ + test_grep "trace:.* git pack-objects .*--filter=combine:blob:none+tree:1" \ trace && git -C pc2 rev-list --objects --missing=allow-any HEAD >objects && # We should have gotten some root trees. - grep " $" objects && + test_grep " $" objects && # Should not have gotten any non-root trees or blobs. - ! grep " ." objects && + test_grep ! " ." objects && xargs -n 1 git -C pc2 cat-file -t types && sort -u types >unique_types.actual && @@ -409,7 +409,7 @@ test_expect_success 'partial clone fetches blobs pointed to by refs even if norm git -C src tag myblob "$BLOB" && git clone --filter="blob:none" "file://$(pwd)/src" dst 2>err && - ! grep "does not point to a valid object" err && + test_grep ! "does not point to a valid object" err && git -C dst fsck ' @@ -424,10 +424,10 @@ test_expect_success 'fetch what is specified on CLI even if already promised' ' git clone --bare --filter=blob:none "file://$(pwd)/src" dst.git && git -C dst.git rev-list --objects --quiet --missing=print HEAD >missing_before && - grep "?$(cat blob)" missing_before && + test_grep "?$(cat blob)" missing_before && git -C dst.git fetch origin $(cat blob) && git -C dst.git rev-list --objects --quiet --missing=print HEAD >missing_after && - ! grep "?$(cat blob)" missing_after + test_grep ! "?$(cat blob)" missing_after ' test_expect_success 'setup src repo for sparse filter' ' @@ -449,8 +449,8 @@ test_expect_success 'partial clone with sparse filter succeeds' ' ( cd dst.git && git rev-list --objects --missing=print HEAD >out && - grep "^$(git rev-parse HEAD:one.t)" out && - grep "^?$(git rev-parse HEAD:two.t)" out + test_grep "^$(git rev-parse HEAD:one.t)" out && + test_grep "^?$(git rev-parse HEAD:two.t)" out ) ' @@ -521,7 +521,7 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas' ' # Verify the assumption that the client needed to fetch the delta base # to resolve the delta. git -C server rev-parse HEAD~1^{tree} >hash && - grep "want $(cat hash)" trace + test_grep "want $(cat hash)" trace ' test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' ' @@ -538,12 +538,12 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' ' fetch "file://$(pwd)/server" main && # Verify that protocol version 2 was used. - grep "fetch< version 2" trace && + test_grep "fetch< version 2" trace && # Verify the assumption that the client needed to fetch the delta base # to resolve the delta. git -C server rev-parse HEAD~1^{tree} >hash && - grep "want $(cat hash)" trace + test_grep "want $(cat hash)" trace ' test_expect_success 'fetch does not lazy-fetch missing targets of its refs' ' @@ -563,7 +563,7 @@ test_expect_success 'fetch does not lazy-fetch missing targets of its refs' ' --no-tags --recurse-submodules=no \ origin refs/tags/bar && FOO_HASH=$(git -C server rev-parse foo) && - ! grep "want $FOO_HASH" trace + test_grep ! "want $FOO_HASH" trace ' # The following two tests must be in this order. It is important that @@ -621,7 +621,7 @@ test_expect_success 'fetch from a partial clone, protocol v0' ' test_config -C client protocol.version 0 && test_commit -C client bar && GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "file://$(pwd)/server" && - ! grep "version 2" trace + test_grep ! "version 2" trace ' test_expect_success 'fetch from a partial clone, protocol v2' ' @@ -640,7 +640,7 @@ test_expect_success 'fetch from a partial clone, protocol v2' ' test_config -C client protocol.version 2 && test_commit -C client bar && GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "file://$(pwd)/server" && - grep "version 2" trace + test_grep "version 2" trace ' test_expect_success 'repack does not loosen promisor objects' ' @@ -648,7 +648,7 @@ test_expect_success 'repack does not loosen promisor objects' ' git clone --bare --filter=blob:none "file://$(pwd)/srv.bare" client && test_when_finished "rm -rf client trace" && GIT_TRACE2_PERF="$(pwd)/trace" git -C client repack -A -d && - grep "loosen_unused_packed_objects/loosened:0" trace + test_grep "loosen_unused_packed_objects/loosened:0" trace ' test_expect_success 'lazy-fetch in submodule succeeds' ' @@ -824,7 +824,7 @@ test_expect_success 'when partial cloning, tolerate server not sending target of # Exercise to make sure it works. git -c protocol.version=2 clone \ --filter=blob:none $HTTPD_URL/one_time_script/server repo 2> err && - ! grep "missing object referenced by" err && + test_grep ! "missing object referenced by" err && # Ensure that the one-time-script script was used. ! test -e "$HTTPD_ROOT_PATH/one-time-script" @@ -881,13 +881,13 @@ test_expect_success PERL_TEST_HELPERS 'tolerate server sending REF_DELTA against # by any 3 nybbles, then the OID of the delta base. printf "f.,..%s" $(intersperse "," want && hex_unpack have && - grep $(cat want) have && + test_grep $(cat want) have && # Ensure that the pack contains one delta against HEAD^:have.txt, # similar to the above. printf "f.,..%s" $(intersperse "," want && hex_unpack have && - grep $(cat want) have && + test_grep $(cat want) have && replace_packfile thin.pack && @@ -901,8 +901,8 @@ test_expect_success PERL_TEST_HELPERS 'tolerate server sending REF_DELTA against # Ensure that the missing delta base was directly fetched, but not the # one that the client has. - grep "want $(cat deltabase_missing)" trace && - ! grep "want $(cat deltabase_have)" trace && + test_grep "want $(cat deltabase_missing)" trace && + test_grep ! "want $(cat deltabase_have)" trace && # Ensure that the one-time-script script was used. ! test -e "$HTTPD_ROOT_PATH/one-time-script" diff --git a/t/t5619-clone-local-ambiguous-transport.sh b/t/t5619-clone-local-ambiguous-transport.sh index cce62bf78d3351..e4218e5c7f9f50 100755 --- a/t/t5619-clone-local-ambiguous-transport.sh +++ b/t/t5619-clone-local-ambiguous-transport.sh @@ -64,7 +64,7 @@ test_expect_success 'ambiguous transport does not lead to arbitrary file-inclusi # # This works for now, and if we ever fix the URL detection, it # is OK to change this to detect the transport error. - grep "protocol .* is not supported" err + test_grep "protocol .* is not supported" err ' test_done diff --git a/t/t5620-backfill.sh b/t/t5620-backfill.sh index d2ea68e065304d..74622804700d99 100755 --- a/t/t5620-backfill.sh +++ b/t/t5620-backfill.sh @@ -144,7 +144,7 @@ test_expect_success 'do partial clone 2, backfill min batch size' ' test_expect_success 'backfill --sparse without sparse-checkout fails' ' git init not-sparse && test_must_fail git -C not-sparse backfill --sparse 2>err && - grep "problem loading sparse-checkout" err + test_grep "problem loading sparse-checkout" err ' test_expect_success 'backfill --sparse' ' @@ -422,7 +422,7 @@ test_expect_success 'backfill range with include-edges enables fetch-free git-lo -C backfill-log log -p HEAD~2..HEAD >log-output && # No promisor fetches should have been needed. - ! grep "fetch_count" log-trace + test_grep ! "fetch_count" log-trace ' test_expect_success 'backfill range without include edges causes on-demand fetches in git-log' ' @@ -439,7 +439,7 @@ test_expect_success 'backfill range without include edges causes on-demand fetch GIT_TRACE2_EVENT="$(pwd)/log-no-bdy-trace" git \ -C backfill-log-no-bdy log -p HEAD~2..HEAD >log-output && - grep "fetch_count" log-no-bdy-trace + test_grep "fetch_count" log-no-bdy-trace ' test_expect_success 'backfill range enables fetch-free replay' ' @@ -470,7 +470,7 @@ test_expect_success 'backfill range enables fetch-free replay' ' GIT_TRACE2_EVENT="$(pwd)/replay-trace" git -C replay-dest.git \ replay --onto main topic~1..topic >replay-out && - ! grep "fetch_count" replay-trace + test_grep ! "fetch_count" replay-trace ' test_expect_success 'backfill enables fetch-free merge' ' @@ -501,7 +501,7 @@ test_expect_success 'backfill enables fetch-free merge' ' GIT_TRACE2_EVENT="$(pwd)/merge-trace" git -C merge-dest \ merge origin/side -m "test merge" && - ! grep "fetch_count" merge-trace + test_grep ! "fetch_count" merge-trace ' . "$TEST_DIRECTORY"/lib-httpd.sh @@ -530,7 +530,7 @@ test_expect_success 'backfilling over HTTP succeeds' ' awk "{print \$1;}" oids && GIT_TRACE2_EVENT="$(pwd)/walk-trace" git -C backfill-http \ cat-file --batch-check batch-out && - ! grep missing batch-out + test_grep ! missing batch-out ' # DO NOT add non-httpd-specific tests here, because the last part of this diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh index a73b4d4ff6a0d2..ffeb01afaef462 100755 --- a/t/t5700-protocol-v1.sh +++ b/t/t5700-protocol-v1.sh @@ -33,9 +33,9 @@ test_expect_success 'clone with git:// using protocol v1' ' test_cmp expect actual && # Client requested to use protocol v1 - grep "clone> .*\\\0\\\0version=1\\\0$" log && + test_grep "clone> .*\\\0\\\0version=1\\\0$" log && # Server responded using protocol v1 - grep "clone< version 1" log + test_grep "clone< version 1" log ' test_expect_success 'fetch with git:// using protocol v1' ' @@ -49,9 +49,9 @@ test_expect_success 'fetch with git:// using protocol v1' ' test_cmp expect actual && # Client requested to use protocol v1 - grep "fetch> .*\\\0\\\0version=1\\\0$" log && + test_grep "fetch> .*\\\0\\\0version=1\\\0$" log && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'pull with git:// using protocol v1' ' @@ -63,9 +63,9 @@ test_expect_success 'pull with git:// using protocol v1' ' test_cmp expect actual && # Client requested to use protocol v1 - grep "fetch> .*\\\0\\\0version=1\\\0$" log && + test_grep "fetch> .*\\\0\\\0version=1\\\0$" log && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'push with git:// using protocol v1' ' @@ -81,9 +81,9 @@ test_expect_success 'push with git:// using protocol v1' ' test_cmp expect actual && # Client requested to use protocol v1 - grep "push> .*\\\0\\\0version=1\\\0$" log && + test_grep "push> .*\\\0\\\0version=1\\\0$" log && # Server responded using protocol v1 - grep "push< version 1" log + test_grep "push< version 1" log ' stop_git_daemon @@ -104,7 +104,7 @@ test_expect_success 'clone with file:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "clone< version 1" log + test_grep "clone< version 1" log ' test_expect_success 'fetch with file:// using protocol v1' ' @@ -118,7 +118,7 @@ test_expect_success 'fetch with file:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'pull with file:// using protocol v1' ' @@ -130,7 +130,7 @@ test_expect_success 'pull with file:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'push with file:// using protocol v1' ' @@ -146,7 +146,7 @@ test_expect_success 'push with file:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "push< version 1" log + test_grep "push< version 1" log ' test_expect_success 'cloning branchless tagless but not refless remote' ' @@ -196,7 +196,7 @@ test_expect_success 'clone with ssh:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "clone< version 1" log + test_grep "clone< version 1" log ' test_expect_success 'fetch with ssh:// using protocol v1' ' @@ -211,7 +211,7 @@ test_expect_success 'fetch with ssh:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'pull with ssh:// using protocol v1' ' @@ -224,7 +224,7 @@ test_expect_success 'pull with ssh:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "fetch< version 1" log + test_grep "fetch< version 1" log ' test_expect_success 'push with ssh:// using protocol v1' ' @@ -241,7 +241,7 @@ test_expect_success 'push with ssh:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "push< version 1" log + test_grep "push< version 1" log ' test_expect_success 'clone propagates object-format from empty repo' ' @@ -277,9 +277,9 @@ test_expect_success 'clone with http:// using protocol v1' ' test_cmp expect actual && # Client requested to use protocol v1 - grep "Git-Protocol: version=1" log && + test_grep "Git-Protocol: version=1" log && # Server responded using protocol v1 - grep "git< version 1" log + test_grep "git< version 1" log ' test_expect_success 'clone with http:// using protocol v1 with empty SHA-256 repo' ' @@ -291,9 +291,9 @@ test_expect_success 'clone with http:// using protocol v1 with empty SHA-256 rep test_cmp expect actual && # Client requested to use protocol v1 - grep "Git-Protocol: version=1" log && + test_grep "Git-Protocol: version=1" log && # Server responded using protocol v1 - grep "git< version 1" log + test_grep "git< version 1" log ' test_expect_success 'fetch with http:// using protocol v1' ' @@ -307,7 +307,7 @@ test_expect_success 'fetch with http:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "git< version 1" log + test_grep "git< version 1" log ' test_expect_success 'pull with http:// using protocol v1' ' @@ -319,7 +319,7 @@ test_expect_success 'pull with http:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "git< version 1" log + test_grep "git< version 1" log ' test_expect_success 'push with http:// using protocol v1' ' @@ -335,7 +335,7 @@ test_expect_success 'push with http:// using protocol v1' ' test_cmp expect actual && # Server responded using protocol v1 - grep "git< version 1" log + test_grep "git< version 1" log ' # DO NOT add non-httpd-specific tests here, because the last part of this diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh index d4c28bae39e2ad..108eb30945247b 100755 --- a/t/t5701-git-serve.sh +++ b/t/t5701-git-serve.sh @@ -97,7 +97,7 @@ test_expect_success 'request capability as command' ' 0000 EOF test_must_fail test-tool serve-v2 --stateless-rpc 2>err err err err /dev/null 2>err && - grep "unexpected line: .this-is-not-a-command." err + test_grep "unexpected line: .this-is-not-a-command." err ' # Test the basics of object-info @@ -410,7 +410,7 @@ test_expect_success 'object-info missing from capabilities when disabled' ' --advertise-capabilities >out && test-tool pkt-line unpack actual && - ! grep object.info actual + test_grep ! object.info actual ' test_expect_success 'object-info commands rejected when disabled' ' @@ -421,7 +421,7 @@ test_expect_success 'object-info commands rejected when disabled' ' EOF test_must_fail test-tool serve-v2 --stateless-rpc err && - grep invalid.command err + test_grep invalid.command err ' test_done diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 9f6cf4142d5b83..08ed09e45a80ee 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -27,9 +27,9 @@ test_expect_success 'list refs with git:// using protocol v2' ' ls-remote --symref "$GIT_DAEMON_URL/parent" >actual && # Client requested to use protocol v2 - grep "ls-remote> .*\\\0\\\0version=2\\\0$" log && + test_grep "ls-remote> .*\\\0\\\0version=2\\\0$" log && # Server responded using protocol v2 - grep "ls-remote< version 2" log && + test_grep "ls-remote< version 2" log && git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect && test_cmp expect actual @@ -59,9 +59,9 @@ test_expect_success 'clone with git:// using protocol v2' ' test_cmp expect actual && # Client requested to use protocol v2 - grep "clone> .*\\\0\\\0version=2\\\0$" log && + test_grep "clone> .*\\\0\\\0version=2\\\0$" log && # Server responded using protocol v2 - grep "clone< version 2" log + test_grep "clone< version 2" log ' test_expect_success 'fetch with git:// using protocol v2' ' @@ -77,9 +77,9 @@ test_expect_success 'fetch with git:// using protocol v2' ' test_cmp expect actual && # Client requested to use protocol v2 - grep "fetch> .*\\\0\\\0version=2\\\0$" log && + test_grep "fetch> .*\\\0\\\0version=2\\\0$" log && # Server responded using protocol v2 - grep "fetch< version 2" log + test_grep "fetch< version 2" log ' test_expect_success 'fetch by hash without tag following with protocol v2 does not list refs' ' @@ -91,8 +91,8 @@ test_expect_success 'fetch by hash without tag following with protocol v2 does n GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \ fetch --no-tags origin $(cat two_a_hash) && - grep "fetch< version 2" log && - ! grep "fetch> command=ls-refs" log + test_grep "fetch< version 2" log && + test_grep ! "fetch> command=ls-refs" log ' test_expect_success 'pull with git:// using protocol v2' ' @@ -106,9 +106,9 @@ test_expect_success 'pull with git:// using protocol v2' ' test_cmp expect actual && # Client requested to use protocol v2 - grep "fetch> .*\\\0\\\0version=2\\\0$" log && + test_grep "fetch> .*\\\0\\\0version=2\\\0$" log && # Server responded using protocol v2 - grep "fetch< version 2" log + test_grep "fetch< version 2" log ' test_expect_success 'push with git:// and a config of v2 does not request v2' ' @@ -130,9 +130,9 @@ test_expect_success 'push with git:// and a config of v2 does not request v2' ' test_cmp expect actual && # Client requested to use protocol v2 - ! grep "push> .*\\\0\\\0version=2\\\0$" log && + test_grep ! "push> .*\\\0\\\0version=2\\\0$" log && # Server responded using protocol v2 - ! grep "push< version 2" log + test_grep ! "push< version 2" log ' stop_git_daemon @@ -151,7 +151,7 @@ test_expect_success 'list refs with file:// using protocol v2' ' ls-remote --symref "file://$(pwd)/file_parent" >actual && # Server responded using protocol v2 - grep "ls-remote< version 2" log && + test_grep "ls-remote< version 2" log && git ls-remote --symref "file://$(pwd)/file_parent" >expect && test_cmp expect actual @@ -181,8 +181,8 @@ test_expect_success 'server-options are sent when using ls-remote' ' EOF test_cmp expect actual && - grep "server-option=hello" log && - grep "server-option=world" log + test_grep "server-option=hello" log && + test_grep "server-option=world" log ' test_expect_success 'server-options from configuration are used by ls-remote' ' @@ -241,12 +241,12 @@ test_expect_success 'clone with file:// using protocol v2' ' test_cmp expect actual && # Server responded using protocol v2 - grep "clone< version 2" log && + test_grep "clone< version 2" log && # Client sent ref-prefixes to filter the ref-advertisement - grep "ref-prefix HEAD" log && - grep "ref-prefix refs/heads/" log && - grep "ref-prefix refs/tags/" log + test_grep "ref-prefix HEAD" log && + test_grep "ref-prefix refs/heads/" log && + test_grep "ref-prefix refs/tags/" log ' test_expect_success 'clone of empty repo propagates name of default branch' ' @@ -311,7 +311,7 @@ test_expect_success 'clone propagates unborn HEAD from non-empty repo' ' echo "refs/heads/mydefaultbranch" >expect && git -C file_unborn_child symbolic-ref HEAD >actual && test_cmp expect actual && - grep "warning: remote HEAD refers to nonexistent ref" stderr + test_grep "warning: remote HEAD refers to nonexistent ref" stderr ' test_expect_success 'clone propagates object-format from empty repo' ' @@ -343,7 +343,7 @@ test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' ' echo "refs/heads/mydefaultbranch" >expect && git -C file_unborn_child.git symbolic-ref HEAD >actual && test_cmp expect actual && - ! grep "warning:" stderr + test_grep ! "warning:" stderr ' test_expect_success 'defaulted HEAD uses remote branch if available' ' @@ -366,7 +366,7 @@ test_expect_success 'defaulted HEAD uses remote branch if available' ' git -C file_unborn_child symbolic-ref HEAD >actual && test_cmp expect actual && test_path_is_file file_unborn_child/stuff.t && - ! grep "warning:" stderr + test_grep ! "warning:" stderr ' test_expect_success 'fetch with file:// using protocol v2' ' @@ -382,7 +382,7 @@ test_expect_success 'fetch with file:// using protocol v2' ' test_cmp expect actual && # Server responded using protocol v2 - grep "fetch< version 2" log + test_grep "fetch< version 2" log ' test_expect_success 'ref advertisement is filtered during fetch using protocol v2' ' @@ -398,8 +398,8 @@ test_expect_success 'ref advertisement is filtered during fetch using protocol v git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && - grep "refs/heads/main" log && - ! grep "refs/heads/unwanted-branch" log + test_grep "refs/heads/main" log && + test_grep ! "refs/heads/unwanted-branch" log ' test_expect_success 'server-options are sent when fetching' ' @@ -414,8 +414,8 @@ test_expect_success 'server-options are sent when fetching' ' git -C file_parent log -1 --format=%s >expect && test_cmp expect actual && - grep "server-option=hello" log && - grep "server-option=world" log + test_grep "server-option=hello" log && + test_grep "server-option=world" log ' test_expect_success 'server-options are sent when fetch multiple remotes' ' @@ -485,8 +485,8 @@ test_expect_success 'server-options are sent when cloning' ' clone --server-option=hello --server-option=world \ "file://$(pwd)/file_parent" myclone && - grep "server-option=hello" log && - grep "server-option=world" log + test_grep "server-option=hello" log && + test_grep "server-option=world" log ' test_expect_success 'server-options from configuration are used by git-clone' ' @@ -578,12 +578,12 @@ test_expect_success 'setup filter tests' ' test_expect_success 'partial clone' ' GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \ clone --filter=blob:none "file://$(pwd)/server" client && - grep "version 2" trace && + test_grep "version 2" trace && # Ensure that the old version of the file is missing git -C client rev-list --quiet --objects --missing=print main \ >observed.oids && - grep "$(git -C server rev-parse message1:a.txt)" observed.oids && + test_grep "$(git -C server rev-parse message1:a.txt)" observed.oids && # Ensure that client passes fsck git -C client fsck @@ -593,11 +593,11 @@ test_expect_success 'dynamically fetch missing object' ' rm "$(pwd)/trace" && GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ cat-file -p $(git -C server rev-parse message1:a.txt) && - grep "version 2" trace + test_grep "version 2" trace ' test_expect_success 'when dynamically fetching missing object, do not list refs' ' - ! grep "git> command=ls-refs" trace + test_grep ! "git> command=ls-refs" trace ' test_expect_success 'partial fetch' ' @@ -607,12 +607,12 @@ test_expect_success 'partial fetch' ' GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ fetch --filter=blob:none "$SERVER" main:refs/heads/other && - grep "version 2" trace && + test_grep "version 2" trace && # Ensure that the old version of the file is missing git -C client rev-list --quiet --objects --missing=print other \ >observed.oids && - grep "$(git -C server rev-parse message1:a.txt)" observed.oids && + test_grep "$(git -C server rev-parse message1:a.txt)" observed.oids && # Ensure that client passes fsck git -C client fsck @@ -625,14 +625,14 @@ test_expect_success 'do not advertise filter if not configured to do so' ' git -C server config uploadpack.allowfilter 1 && GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \ ls-remote "$SERVER" && - grep "fetch=.*filter" trace && + test_grep "fetch=.*filter" trace && rm "$(pwd)/trace" && git -C server config uploadpack.allowfilter 0 && GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \ ls-remote "$SERVER" && grep "fetch=" trace >fetch_capabilities && - ! grep filter fetch_capabilities + test_grep ! filter fetch_capabilities ' test_expect_success 'partial clone warns if filter is not advertised' ' @@ -658,7 +658,7 @@ test_expect_success 'even with handcrafted request, filter does not work if not test_must_fail test-tool -C server serve-v2 --stateless-rpc \ /dev/null 2>err && - grep "unexpected line: .filter blob:none." err && + test_grep "unexpected line: .filter blob:none." err && # Exercise to ensure that if advertised, filter works git -C server config uploadpack.allowfilter 1 && @@ -675,8 +675,8 @@ test_expect_success 'default refspec is used to filter ref when fetching' ' git -C file_parent log -1 --format=%s three >expect && test_cmp expect actual && - grep "ref-prefix refs/heads/" log && - grep "ref-prefix refs/tags/" log + test_grep "ref-prefix refs/heads/" log && + test_grep "ref-prefix refs/tags/" log ' test_expect_success 'set up parent for prefix tests' ' @@ -750,9 +750,9 @@ test_expect_success 'fetch supports various ways of have lines' ' "$(git -C server rev-parse fetch-by-sha1)" && # Ensure that the appropriate prefixes are sent (using a sample) - grep "fetch> ref-prefix dwim" trace && - grep "fetch> ref-prefix refs/heads/dwim" trace && - grep "fetch> ref-prefix refs/tags/prefix" trace && + test_grep "fetch> ref-prefix dwim" trace && + test_grep "fetch> ref-prefix refs/heads/dwim" trace && + test_grep "fetch> ref-prefix refs/tags/prefix" trace && # Ensure that the correct objects are returned git -C client cat-file -e $(git -C server rev-parse dwim) && @@ -779,9 +779,9 @@ test_expect_success 'fetch supports include-tag and tag following' ' GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ fetch "$(pwd)/server" to_fetch:to_fetch && - grep "fetch> ref-prefix to_fetch" trace && - grep "fetch> ref-prefix refs/tags/" trace && - grep "fetch> include-tag" trace && + test_grep "fetch> ref-prefix to_fetch" trace && + test_grep "fetch> ref-prefix refs/tags/" trace && + test_grep "fetch> include-tag" trace && git -C client cat-file -e $(git -C client rev-parse annotated_tag) ' @@ -805,7 +805,7 @@ test_expect_success 'upload-pack respects client shallows' ' GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ fetch origin newbranch && # Ensure that protocol v2 is used - grep "fetch< version 2" trace + test_grep "fetch< version 2" trace ' test_expect_success 'ensure that multiple fetches in same process from a shallow repo works' ' @@ -823,7 +823,7 @@ test_expect_success 'ensure that multiple fetches in same process from a shallow GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ fetch --shallow-exclude one origin && # Ensure that protocol v2 is used - grep "fetch< version 2" trace + test_grep "fetch< version 2" trace ' test_expect_success 'deepen-relative' ' @@ -844,7 +844,7 @@ test_expect_success 'deepen-relative' ' GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \ fetch --deepen=1 origin && # Ensure that protocol v2 is used - grep "fetch< version 2" trace && + test_grep "fetch< version 2" trace && git -C client log --pretty=tformat:%s origin/main >actual && cat >expected <<-\EOF && @@ -909,7 +909,7 @@ test_expect_success 'file:// --negotiate-only' ' --negotiation-tip=$(git -C client rev-parse HEAD) \ origin >out && COMMON=$(git -C "$SERVER" rev-parse two) && - grep "$COMMON" out + test_grep "$COMMON" out ' test_expect_success 'file:// --negotiate-only with protocol v0' ' @@ -932,7 +932,7 @@ test_expect_success 'push with custom path does not request v2' ' --receive-pack="env >../env.trace; git-receive-pack" \ origin HEAD:refs/heads/custom-push-test && test_path_is_file env.trace && - ! grep ^GIT_PROTOCOL env.trace + test_grep ! ^GIT_PROTOCOL env.trace ' test_expect_success 'fetch with custom path does request v2' ' @@ -940,7 +940,7 @@ test_expect_success 'fetch with custom path does request v2' ' git -C client fetch \ --upload-pack="env >../env.trace; git-upload-pack" \ origin HEAD && - grep ^GIT_PROTOCOL=version=2 env.trace + test_grep ^GIT_PROTOCOL=version=2 env.trace ' test_expect_success 'archive with custom path does not request v2' ' @@ -950,7 +950,7 @@ test_expect_success 'archive with custom path does not request v2' ' --remote=origin \ HEAD >/dev/null && test_path_is_file env.trace && - ! grep ^GIT_PROTOCOL env.trace + test_grep ! ^GIT_PROTOCOL env.trace ' test_expect_success 'reject client packfile-uris if not advertised' ' @@ -994,11 +994,11 @@ test_expect_success 'clone with http:// using protocol v2' ' test_cmp expect actual && # Client requested to use protocol v2 - grep "Git-Protocol: version=2" log && + test_grep "Git-Protocol: version=2" log && # Server responded using protocol v2 - grep "git< version 2" log && + test_grep "git< version 2" log && # Verify that the chunked encoding sending codepath is NOT exercised - ! grep "Send header: Transfer-Encoding: chunked" log + test_grep ! "Send header: Transfer-Encoding: chunked" log ' test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline length' ' @@ -1011,9 +1011,9 @@ test_expect_success 'clone repository with http:// using protocol v2 with incomp clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err && # Client requested to use protocol v2 - grep "Git-Protocol: version=2" log && + test_grep "Git-Protocol: version=2" log && # Server responded using protocol v2 - grep "git< version 2" log && + test_grep "git< version 2" log && # Client reported appropriate failure test_grep "bytes of length header were received" err ' @@ -1028,9 +1028,9 @@ test_expect_success 'clone repository with http:// using protocol v2 with incomp clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err && # Client requested to use protocol v2 - grep "Git-Protocol: version=2" log && + test_grep "Git-Protocol: version=2" log && # Server responded using protocol v2 - grep "git< version 2" log && + test_grep "git< version 2" log && # Client reported appropriate failure test_grep "bytes of body are still expected" err ' @@ -1043,9 +1043,9 @@ test_expect_success 'clone with http:// using protocol v2 and invalid parameters clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid && # Client requested to use protocol v2 - grep "Git-Protocol: version=2" log && + test_grep "Git-Protocol: version=2" log && # Server responded using protocol v2 - grep "git< version 2" log + test_grep "git< version 2" log ' test_expect_success 'clone big repository with http:// using protocol v2' ' @@ -1070,11 +1070,11 @@ test_expect_success 'clone big repository with http:// using protocol v2' ' clone "$HTTPD_URL/smart/big" big_child && # Client requested to use protocol v2 - grep "Git-Protocol: version=2" log && + test_grep "Git-Protocol: version=2" log && # Server responded using protocol v2 - grep "git< version 2" log && + test_grep "git< version 2" log && # Verify that the chunked encoding sending codepath is exercised - grep "Send header: Transfer-Encoding: chunked" log + test_grep "Send header: Transfer-Encoding: chunked" log ' test_expect_success 'fetch with http:// using protocol v2' ' @@ -1090,7 +1090,7 @@ test_expect_success 'fetch with http:// using protocol v2' ' test_cmp expect actual && # Server responded using protocol v2 - grep "git< version 2" log + test_grep "git< version 2" log ' test_expect_success 'fetch with http:// by hash without tag following with protocol v2 does not list refs' ' @@ -1102,8 +1102,8 @@ test_expect_success 'fetch with http:// by hash without tag following with proto GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \ fetch --no-tags origin $(cat two_a_hash) && - grep "fetch< version 2" log && - ! grep "fetch> command=ls-refs" log + test_grep "fetch< version 2" log && + test_grep ! "fetch> command=ls-refs" log ' test_expect_success 'fetch from namespaced repo respects namespaces' ' @@ -1120,7 +1120,7 @@ test_expect_success 'fetch from namespaced repo respects namespaces' ' refs/heads/main:refs/heads/theirs && # Server responded using protocol v2 - grep "fetch< version 2" log && + test_grep "fetch< version 2" log && git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect && git -C http_child rev-parse theirs >actual && @@ -1157,9 +1157,9 @@ test_expect_success 'push with http:// and a config of v2 does not request v2' ' test_cmp expect actual && # Client did not request to use protocol v2 - ! grep "Git-Protocol: version=2" log && + test_grep ! "Git-Protocol: version=2" log && # Server did not respond using protocol v2 - ! grep "git< version 2" log + test_grep ! "git< version 2" log ' test_expect_success 'when server sends "ready", expect DELIM' ' @@ -1207,8 +1207,8 @@ test_expect_success 'when server does not send "ready", expect FLUSH' ' test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \ -c protocol.version=2 \ fetch "$HTTPD_URL/one_time_script/http_parent" 2> err && - grep "fetch< .*acknowledgments" log && - ! grep "fetch< .*ready" log && + test_grep "fetch< .*acknowledgments" log && + test_grep ! "fetch< .*ready" log && test_grep "expected no other sections to be sent after no .ready." err ' @@ -1247,7 +1247,7 @@ test_expect_success 'part of packfile response provided as URI' ' do git verify-pack --object-format=$(test_oid algo) --verbose $idx >out && { - grep -E "^[0-9a-f]{16,} " out || : + test_grep -E "^[0-9a-f]{16,} " out || : } >out.objectlist && if test_line_count = 1 out.objectlist then @@ -1446,7 +1446,7 @@ test_expect_success 'packfile-uri path redacted in trace' ' -c fetch.uriprotocols=http,https \ clone "$HTTPD_URL/smart/http_parent" http_child && - grep -F "clone< \\1$(cat packh) $HTTPD_URL/" log + test_grep -F "clone< \\1$(cat packh) $HTTPD_URL/" log ' test_expect_success 'packfile-uri path not redacted in trace when GIT_TRACE_REDACT=0' ' @@ -1472,7 +1472,7 @@ test_expect_success 'packfile-uri path not redacted in trace when GIT_TRACE_REDA -c fetch.uriprotocols=http,https \ clone "$HTTPD_URL/smart/http_parent" http_child && - grep -F "clone< \\1$(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" log + test_grep -F "clone< \\1$(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" log ' test_expect_success 'http:// --negotiate-only' ' @@ -1487,7 +1487,7 @@ test_expect_success 'http:// --negotiate-only' ' --negotiation-tip=$(git -C client rev-parse HEAD) \ origin >out && COMMON=$(git -C "$SERVER" rev-parse two) && - grep "$COMMON" out + test_grep "$COMMON" out ' test_expect_success 'http:// --negotiate-only without wait-for-done support' ' diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index 249137b46734e0..330d049b2c05b5 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -101,7 +101,7 @@ test_expect_success 'invalid want-ref line' ' test-tool pkt-line pack in && test_must_fail test-tool serve-v2 --stateless-rpc 2>out expected && git -C local rev-parse refs/heads/actual >actual && test_cmp expected actual && - grep "want $oid" log + test_grep "want $oid" log ' test_expect_success 'fetching multiple refs' ' @@ -252,8 +252,8 @@ test_expect_success 'fetching multiple refs' ' git -C "$REPO" rev-parse "main" "baz" >expected && git -C local rev-parse refs/remotes/origin/main refs/remotes/origin/baz >actual && test_cmp expected actual && - grep "want-ref refs/heads/main" log && - grep "want-ref refs/heads/baz" log + test_grep "want-ref refs/heads/main" log && + test_grep "want-ref refs/heads/baz" log ' test_expect_success 'fetching ref and exact OID' ' @@ -268,8 +268,8 @@ test_expect_success 'fetching ref and exact OID' ' git -C "$REPO" rev-parse "main" "b" >expected && git -C local rev-parse refs/remotes/origin/main refs/heads/actual >actual && test_cmp expected actual && - grep "want $oid" log && - grep "want-ref refs/heads/main" log + test_grep "want $oid" log && + test_grep "want-ref refs/heads/main" log ' test_expect_success 'fetching with wildcard that does not match any refs' ' @@ -291,8 +291,8 @@ test_expect_success 'fetching with wildcard that matches multiple refs' ' git -C "$REPO" rev-parse "o/foo" "o/bar" >expected && git -C local rev-parse "o/foo" "o/bar" >actual && test_cmp expected actual && - grep "want-ref refs/heads/o/foo" log && - grep "want-ref refs/heads/o/bar" log + test_grep "want-ref refs/heads/o/foo" log && + test_grep "want-ref refs/heads/o/bar" log ' REPO="$(pwd)/repo-ns" @@ -345,7 +345,7 @@ test_expect_success 'with namespace: want-ref outside namespace is unknown' ' test_must_fail env GIT_NAMESPACE=ns \ test-tool -C "$REPO" serve-v2 --stateless-rpc >out out