t: remove \{m,n\} from BRE grep usage

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. 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Đoàn Trần Công Danh committed Sep 21, 2022 at 20:02 UTC a764c37bad6b4da2b248c30af1c251110fe1e031
5 files changed +8 -8
t/t3200-branch.sh
+2 -2
@@ -201,8 +201,8 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
201
202 test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '
203 msg="Branch: renamed refs/heads/baz to refs/heads/bam" &&
204 - grep " 0\{40\}.*$msg$" .git/logs/HEAD &&
205 - grep "^0\{40\}.*$msg$" .git/logs/HEAD
204 + grep " $ZERO_OID.*$msg$" .git/logs/HEAD &&
205 + grep "^$ZERO_OID.*$msg$" .git/logs/HEAD
206 '
207
208 test_expect_success 'git branch -M should leave orphaned HEAD alone' '
t/t3305-notes-fanout.sh
+1 -1
@@ -9,7 +9,7 @@ path_has_fanout() {
9 path=$1 &&
10 fanout=$2 &&
11 after_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&
12 - echo $path | grep -q "^\([0-9a-f]\{2\}/\)\{$fanout\}[0-9a-f]\{$after_last_slash\}$"
12 + echo $path | grep -q -E "^([0-9a-f]{2}/){$fanout}[0-9a-f]{$after_last_slash}$"
13 }
14
15 touched_one_note_with_fanout() {
t/t3404-rebase-interactive.sh
+3 -3
@@ -1244,9 +1244,9 @@ test_expect_success 'short commit ID collide' '
1244 test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
1245 grep "^pick $colliding_id " \
1246 .git/rebase-merge/git-rebase-todo.tmp &&
1247 - grep "^pick [0-9a-f]\{$hexsz\}" \
1247 + grep -E "^pick [0-9a-f]{$hexsz}" \
1248 .git/rebase-merge/git-rebase-todo &&
1249 - grep "^pick [0-9a-f]\{$hexsz\}" \
1249 + grep -E "^pick [0-9a-f]{$hexsz}" \
1250 .git/rebase-merge/git-rebase-todo.backup &&
1251 git rebase --continue
1252 ) &&
@@ -1261,7 +1261,7 @@ test_expect_success 'respect core.abbrev' '
1261 set_cat_todo_editor &&
1262 test_must_fail git rebase -i HEAD~4 >todo-list
1263 ) &&
1264 - test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1264 + test 4 = $(grep -c -E "pick [0-9a-f]{12,}" todo-list)
1265 '
1266
1267 test_expect_success 'todo count' '
t/t5550-http-fetch-dumb.sh
+1 -1
@@ -234,7 +234,7 @@ test_expect_success 'http-fetch --packfile' '
234 --index-pack-arg=--keep \
235 "$HTTPD_URL"/dumb/repo_pack.git/$p >out &&
236
237 - grep "^keep.[0-9a-f]\{16,\}$" out &&
237 + grep -E "^keep.[0-9a-f]{16,}$" out &&
238 cut -c6- out >packhash &&
239
240 # Ensure that the expected files are generated
t/t5702-protocol-v2.sh
+1 -1
@@ -1001,7 +1001,7 @@ test_expect_success 'part of packfile response provided as URI' '
1001 do
1002 git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
1003 {
1004 - grep "^[0-9a-f]\{16,\} " out || :
1004 + grep -E "^[0-9a-f]{16,} " out || :
1005 } >out.objectlist &&
1006 if test_line_count = 1 out.objectlist
1007 then