Skip to content

Commit 4d06001

Browse files
committed
Merge branch 'ja/worktree-orphan-fix'
Fix tests with unportable regex patterns. * ja/worktree-orphan-fix: t2400: rewrite regex to avoid unintentional PCRE builtin/worktree.c: convert tab in advice to space t2400: drop no-op `--sq` from rev-parse call
2 parents 3365e26 + d1b72cb commit 4d06001

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

builtin/worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"(branch with no commits) for this repository, you can do so\n" \
5454
"using the --orphan flag:\n" \
5555
"\n" \
56-
" git worktree add --orphan -b %s %s\n")
56+
" git worktree add --orphan -b %s %s\n")
5757

5858
#define WORKTREE_ADD_ORPHAN_NO_DASH_B_HINT_TEXT \
5959
_("If you meant to create a worktree containing a new orphan branch\n" \
6060
"(branch with no commits) for this repository, you can do so\n" \
6161
"using the --orphan flag:\n" \
6262
"\n" \
63-
" git worktree add --orphan %s\n")
63+
" git worktree add --orphan %s\n")
6464

6565
static const char * const git_worktree_usage[] = {
6666
BUILTIN_WORKTREE_ADD_USAGE,

t/t2400-worktree-add.sh

Lines changed: 7 additions & 7 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" &&
@@ -995,11 +995,11 @@ test_dwim_orphan () {
995995
grep "$invalid_ref_regex" actual &&
996996
! grep "$orphan_hint" actual
997997
else
998-
headpath=$(git $dashc_args rev-parse --sq --path-format=absolute --git-path HEAD) &&
998+
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)