Skip to content

allow "grep -E", remove {e,f}grep usage

Đoàn Trần Công Danh git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 1 replyIn review
  2. v14 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Change wording in 2/4
- Change regex in 2/4 to be more readable
- Remove '-F' from some regex in 4/4 when the regex doesn't have any special characters

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4CodingGuidelines: allow grep -EDocumentation/CodingGuidelines+0 -20 replies
2/4t: remove \{m,n\} from BRE grep usaget/t3200-branch.sh t/t3305-notes-fanout.sh t/t3404-rebase-interactive.sh +2 more+8 -81 reply
3/4t: convert egrep usage to "grep -E"t/perf/run t/t1304-default-acl.sh t/t3702-add-edit.sh +8 more+29 -290 replies
4/4t: convert fgrep usage to "grep -F"t/t3700-add.sh t/t7003-filter-branch.sh t/t9133-git-svn-nested-git-repo.sh +3 more+16 -160 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] allow "grep -E", remove {e,f}grep usage

Our CodingGuidelines says that we should avoid "grep -E" and/or "grep \{m,n\}". However they're still in use and noone has complained, yet.

In addition, GNU grep 3.8 started to warn about the continuation of deprecation process for egrep and fgrep.

This series aim to allow "grep -E" and replace {e,f}grep usage with "grep -{E,F}"

While there're idea to lift the restriction for \{m,n\}, too. Their usage are limited and could be replaced with other alternatives. Let's skip them for now.

Change from v1:
- Change wording in 2/4
- Change regex in 2/4 to be more readable
- Remove '-F' from some regex in 4/4 when the regex doesn't have any special characters

Đoàn Trần Công Danh (4):
CodingGuidelines: allow grep -E
t: remove \{m,n\} from BRE grep usage
t: convert egrep usage to "grep -E"
t: convert fgrep usage to "grep -F"

 Documentation/CodingGuidelines       |  2 --
 t/perf/run                           |  4 ++--
 t/t1304-default-acl.sh               |  4 ++--
 t/t3200-branch.sh                    |  4 ++--
 t/t3305-notes-fanout.sh              |  2 +-
 t/t3404-rebase-interactive.sh        |  6 +++---
 t/t3700-add.sh                       |  2 +-
 t/t3702-add-edit.sh                  |  2 +-
 t/t4014-format-patch.sh              |  8 ++++----
 t/t5320-delta-islands.sh             |  2 +-
 t/t5550-http-fetch-dumb.sh           |  2 +-
 t/t5702-protocol-v2.sh               |  2 +-
 t/t7003-filter-branch.sh             |  4 ++--
 t/t7527-builtin-fsmonitor.sh         | 18 +++++++++---------
 t/t7701-repack-unpack-unreachable.sh |  4 ++--
 t/t9001-send-email.sh                |  8 ++++----
 t/t9133-git-svn-nested-git-repo.sh   |  6 +++---
 t/t9134-git-svn-ignore-paths.sh      |  8 ++++----
 t/t9140-git-svn-reset.sh             |  4 ++--
 t/t9147-git-svn-include-paths.sh     |  8 ++++----
 t/t9814-git-p4-rename.sh             |  2 +-
 t/t9815-git-p4-submit-fail.sh        |  4 ++--
 t/test-lib-functions.sh              |  2 +-
 23 files changed, 53 insertions(+), 55 deletions(-)

Range-diff against v1:

1:  a8dadaf2d1 = 1:  4ad1ac9d9b CodingGuidelines: allow grep -E
2:  9d5fcda278 ! 2:  ebaf6cec07 t: remove \{m,n\} from BRE grep usage
    @@ Metadata
      ## Commit message ##
         t: remove \{m,n\} from BRE grep usage
     
    -    \{m,n\} is a GNU extension to BRE, and it's forbidden by our
    -    CodingGuidelines.
    +    The CodingGuidelines says we should avoid \{m,n\} in BRE usage.
    +    And their usages in our code base is limited, and subjectively
    +    hard to read.
     
    -    Change to fixed strings or ERE.
    +    Replace them with ERE.
    +
    +    Except for "0\{40\}" which would be changed to "$ZERO_OID",
    +    which is a better value for testing with:
    +    GIT_TEST_DEFAULT_HASH=sha256
     
         Signed-off-by: Đoàn Trần Công Danh <[email protected]>
     
    @@ t/t3200-branch.sh: test_expect_success 'git branch -M baz bam should succeed whe
      	msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
     -	grep " 0\{40\}.*$msg$" .git/logs/HEAD &&
     -	grep "^0\{40\}.*$msg$" .git/logs/HEAD
    -+	zero="00000000" &&
    -+	zero="$zero$zero$zero$zero$zero" &&
    -+	grep " $zero.*$msg$" .git/logs/HEAD &&
    -+	grep "^$zero.*$msg$" .git/logs/HEAD
    ++	grep " $ZERO_OID.*$msg$" .git/logs/HEAD &&
    ++	grep "^$ZERO_OID.*$msg$" .git/logs/HEAD
      '
      
      test_expect_success 'git branch -M should leave orphaned HEAD alone' '
    @@ t/t3305-notes-fanout.sh: path_has_fanout() {
      	fanout=$2 &&
      	after_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&
     -	echo $path | grep -q "^\([0-9a-f]\{2\}/\)\{$fanout\}[0-9a-f]\{$after_last_slash\}$"
    -+	echo $path | grep -q -E "^([0-9a-f][0-9a-f]/){$fanout}[0-9a-f]{$after_last_slash}$"
    ++	echo $path | grep -q -E "^([0-9a-f]{2}/){$fanout}[0-9a-f]{$after_last_slash}$"
      }
      
      touched_one_note_with_fanout() {
3:  a131160033 = 3:  b7c0629603 t: convert egrep usage to "grep -E"
4:  50d009b368 ! 4:  b65a3d7749 t: convert fgrep usage to "grep -F"
    @@ t/t7003-filter-branch.sh: test_expect_success 'result is really identical' '
      	(git config core.bare true && cd .git &&
      	 git filter-branch branch > filter-output 2>&1 &&
     -	! fgrep fatal filter-output)
    -+	! grep -F fatal filter-output)
    ++	! grep fatal filter-output)
      '
      git config core.bare false
      test_expect_success 'result is really identical' '
    @@ t/t7003-filter-branch.sh: test_expect_success 'rewrite repository including refs
      	git reset --hard HEAD &&
      	git filter-branch -f -- --all >filter-output 2>&1 &&
     -	! fgrep fatal filter-output
    -+	! grep -F fatal filter-output
    ++	! grep fatal filter-output
      '
      
      test_expect_success 'filter-branch handles ref deletion' '
    @@ t/t9134-git-svn-ignore-paths.sh: test_expect_success 'init+fetch an SVN reposito
      	(
      	    cd g &&
     -	    git config --get svn-remote.svn.ignore-paths | fgrep "www"
    -+	    git config --get svn-remote.svn.ignore-paths | grep -F "www"
    ++	    git config --get svn-remote.svn.ignore-paths | grep www
      	)
      '
      
    @@ t/t9134-git-svn-ignore-paths.sh: test_expect_success 'SVN-side change outside of
      		svn_cmd commit -m "SVN-side change outside of www" &&
      		svn_cmd up &&
     -		svn_cmd log -v | fgrep "SVN-side change outside of www"
    -+		svn_cmd log -v | grep -F "SVN-side change outside of www"
    ++		svn_cmd log -v | grep "SVN-side change outside of www"
      	)
      '
      
    @@ t/t9134-git-svn-ignore-paths.sh: test_expect_success 'SVN-side change in and out
      		svn_cmd commit -m "SVN-side change in and out of ignored www" &&
      		svn_cmd up &&
     -		svn_cmd log -v | fgrep "SVN-side change in and out of ignored www"
    -+		svn_cmd log -v | grep -F "SVN-side change in and out of ignored www"
    ++		svn_cmd log -v | grep "SVN-side change in and out of ignored www"
      	)
      '
      
    @@ t/t9140-git-svn-reset.sh: test_expect_success 'fetch fails on modified hidden fi
      	  test_must_fail git svn fetch 2> ../errors &&
      	  git svn find-rev refs/remotes/git-svn > ../expect2 ) &&
     -	fgrep "not found in commit" errors &&
    -+	grep -F "not found in commit" errors &&
    ++	grep "not found in commit" errors &&
      	test_cmp expect expect2
      '
      
    @@ t/t9140-git-svn-reset.sh: test_expect_success 'refetch succeeds not ignoring any
      	  git svn fetch &&
      	  git svn rebase &&
     -	  fgrep "mod hidden" hid/hid.txt
    -+	  grep -F "mod hidden" hid/hid.txt
    ++	  grep "mod hidden" hid/hid.txt
      	)
      '
      
    @@ t/t9147-git-svn-include-paths.sh: test_expect_success 'init+fetch an SVN reposit
      	(
      	    cd g &&
     -	    git config --get svn-remote.svn.include-paths | fgrep "qqq"
    -+	    git config --get svn-remote.svn.include-paths | grep -F "qqq"
    ++	    git config --get svn-remote.svn.include-paths | grep qqq
      	)
      '
      
    @@ t/t9147-git-svn-include-paths.sh: test_expect_success 'SVN-side change outside o
      		svn_cmd commit -m "SVN-side change outside of www" &&
      		svn_cmd up &&
     -		svn_cmd log -v | fgrep "SVN-side change outside of www"
    -+		svn_cmd log -v | grep -F "SVN-side change outside of www"
    ++		svn_cmd log -v | grep "SVN-side change outside of www"
      	)
      '
      
    @@ t/t9147-git-svn-include-paths.sh: test_expect_success 'SVN-side change inside of
      		svn_cmd commit -m "SVN-side change inside of www/test_www.txt" &&
      		svn_cmd up &&
     -		svn_cmd log -v | fgrep "SVN-side change inside of www/test_www.txt"
    -+		svn_cmd log -v | grep -F "SVN-side change inside of www/test_www.txt"
    ++		svn_cmd log -v | grep "SVN-side change inside of www/test_www.txt"
      	)
      '
      
    @@ t/t9147-git-svn-include-paths.sh: test_expect_success 'SVN-side change in and ou
      		svn_cmd commit -m "SVN-side change in and out of ignored www" &&
      		svn_cmd up &&
     -		svn_cmd log -v | fgrep "SVN-side change in and out of ignored www"
    -+		svn_cmd log -v | grep -F "SVN-side change in and out of ignored www"
    ++		svn_cmd log -v | grep "SVN-side change in and out of ignored www"
      	)
      '
Signature · 1 line
2.38.0.rc0