git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 0/4] allow "grep -E", remove {e,f}grep usage
@ 2022-09-21 13:02 Đoàn Trần Công Danh
  2022-09-21 13:02 ` [PATCH v2 1/4] CodingGuidelines: allow grep -E Đoàn Trần Công Danh
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Đoàn Trần Công Danh @ 2022-09-21 13:02 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, SZEDER Gábor,
	Phillip Wood, Junio C Hamano

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 <congdanhqx@gmail.com>
     
    @@ 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"
      	)
      '
      
-- 
2.38.0.rc0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-21 18:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 13:02 [PATCH v2 0/4] allow "grep -E", remove {e,f}grep usage Đoàn Trần Công Danh
2022-09-21 13:02 ` [PATCH v2 1/4] CodingGuidelines: allow grep -E Đoàn Trần Công Danh
2022-09-21 13:02 ` [PATCH v2 2/4] t: remove \{m,n\} from BRE grep usage Đoàn Trần Công Danh
2022-09-21 18:06   ` Junio C Hamano
2022-09-21 13:02 ` [PATCH v2 3/4] t: convert egrep usage to "grep -E" Đoàn Trần Công Danh
2022-09-21 13:02 ` [PATCH v2 4/4] t: convert fgrep usage to "grep -F" Đoàn Trần Công Danh

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).