Skip to content

Commit a764c37

Browse files
sgngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e09272 commit a764c37

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

t/t3200-branch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou
201201

202202
test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '
203203
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
206206
'
207207

208208
test_expect_success 'git branch -M should leave orphaned HEAD alone' '

t/t3305-notes-fanout.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ path_has_fanout() {
99
path=$1 &&
1010
fanout=$2 &&
1111
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}$"
1313
}
1414

1515
touched_one_note_with_fanout() {

t/t3404-rebase-interactive.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,9 @@ test_expect_success 'short commit ID collide' '
12441244
test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
12451245
grep "^pick $colliding_id " \
12461246
.git/rebase-merge/git-rebase-todo.tmp &&
1247-
grep "^pick [0-9a-f]\{$hexsz\}" \
1247+
grep -E "^pick [0-9a-f]{$hexsz}" \
12481248
.git/rebase-merge/git-rebase-todo &&
1249-
grep "^pick [0-9a-f]\{$hexsz\}" \
1249+
grep -E "^pick [0-9a-f]{$hexsz}" \
12501250
.git/rebase-merge/git-rebase-todo.backup &&
12511251
git rebase --continue
12521252
) &&
@@ -1261,7 +1261,7 @@ test_expect_success 'respect core.abbrev' '
12611261
set_cat_todo_editor &&
12621262
test_must_fail git rebase -i HEAD~4 >todo-list
12631263
) &&
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)
12651265
'
12661266

12671267
test_expect_success 'todo count' '

t/t5550-http-fetch-dumb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test_expect_success 'http-fetch --packfile' '
234234
--index-pack-arg=--keep \
235235
"$HTTPD_URL"/dumb/repo_pack.git/$p >out &&
236236
237-
grep "^keep.[0-9a-f]\{16,\}$" out &&
237+
grep -E "^keep.[0-9a-f]{16,}$" out &&
238238
cut -c6- out >packhash &&
239239
240240
# Ensure that the expected files are generated

t/t5702-protocol-v2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ test_expect_success 'part of packfile response provided as URI' '
10011001
do
10021002
git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
10031003
{
1004-
grep "^[0-9a-f]\{16,\} " out || :
1004+
grep -E "^[0-9a-f]{16,} " out || :
10051005
} >out.objectlist &&
10061006
if test_line_count = 1 out.objectlist
10071007
then

0 commit comments

Comments
 (0)