Skip to content

Commit d1b72cb

Browse files
OneDeuxTriSeiGogitster
authored andcommitted
t2400: rewrite regex to avoid unintentional PCRE
Replace all cases of `\s` with ` ` as it is not part of POSIX BRE or ERE and therefore not all versions of grep handle it. For the same reason all cases of `\S` are replaced with `[^ ]`. It is not an exact replacement but it is close enough for this use case. Also, do not write `\+` in BRE and expect it to mean 1 or more; it is a GNU extension that may not work everywhere. Remove `.*` from the end of a pattern that is not right-anchored. Signed-off-by: Jacob Abel <[email protected]> Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e42d4b commit d1b72cb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

t/t2400-worktree-add.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ test_wt_add_orphan_hint () {
417417
grep "hint: If you meant to create a worktree containing a new orphan branch" actual &&
418418
if [ $use_branch -eq 1 ]
419419
then
420-
grep -E "^hint:\s+git worktree add --orphan -b \S+ \S+\s*$" actual
420+
grep -E "^hint: +git worktree add --orphan -b [^ ]+ [^ ]+$" actual
421421
else
422-
grep -E "^hint:\s+git worktree add --orphan \S+\s*$" actual
422+
grep -E "^hint: +git worktree add --orphan [^ ]+$" actual
423423
fi
424424
425425
'
@@ -709,8 +709,8 @@ test_dwim_orphan () {
709709
local info_text="No possible source branch, inferring '--orphan'" &&
710710
local fetch_error_text="fatal: No local or remote refs exist despite at least one remote" &&
711711
local orphan_hint="hint: If you meant to create a worktree containing a new orphan branch" &&
712-
local invalid_ref_regex="^fatal: invalid reference:\s\+.*" &&
713-
local bad_combo_regex="^fatal: '[a-z-]\+' and '[a-z-]\+' cannot be used together" &&
712+
local invalid_ref_regex="^fatal: invalid reference: " &&
713+
local bad_combo_regex="^fatal: '[-a-z]*' and '[-a-z]*' cannot be used together" &&
714714

715715
local git_ns="repo" &&
716716
local dashc_args="-C $git_ns" &&
@@ -998,8 +998,8 @@ test_dwim_orphan () {
998998
headpath=$(git $dashc_args rev-parse --path-format=absolute --git-path HEAD) &&
999999
headcontents=$(cat "$headpath") &&
10001000
grep "HEAD points to an invalid (or orphaned) reference" actual &&
1001-
grep "HEAD path:\s*.$headpath." actual &&
1002-
grep "HEAD contents:\s*.$headcontents." actual &&
1001+
grep "HEAD path: .$headpath." actual &&
1002+
grep "HEAD contents: .$headcontents." actual &&
10031003
grep "$orphan_hint" actual &&
10041004
! grep "$info_text" actual
10051005
fi &&

0 commit comments

Comments
 (0)