Skip to content

Fix perl error "unescaped left brace in regex" for paranoid update hook #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: maint
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/hooks/update-paranoid
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ $op = 'U' if ($op eq 'R'

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Johannes Schindelin wrote (reply to this):

Hi Dominic,

On Wed, 11 Sep 2019, Dominic Winkler via GitGitGadget wrote:

> From: Dominic Winkler <[email protected]>
>
> A literal "{" should now be escaped in a pattern starting from perl
> versions >=3D v5.26. In perl v5.22, using a literal { in a regular
> expression was deprecated, and will emit a warning if it isn't escaped: =
\{.
> In v5.26, this won't just warn, it'll cause a syntax error.
>
> (see https://metacpan.org/pod/release/RJBS/perl-5.22.0/pod/perldelta.pod=
)
>
> Signed-off-by: Dominic Winkler <[email protected]>

Thank you for addressing my concern so promptly. I am far from a Perl
expert, so take this with a train of salt: the patch now looks good to
me!

Ciao,
Johannes

> ---
>  contrib/hooks/update-paranoid | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/hooks/update-paranoid b/contrib/hooks/update-parano=
id
> index d18b317b2f..fc0a242a4e 100755
> --- a/contrib/hooks/update-paranoid
> +++ b/contrib/hooks/update-paranoid
> @@ -302,13 +302,13 @@ $op =3D 'U' if ($op eq 'R'
>
>  RULE:
>  	foreach (@$rules) {
> -		while (/\${user\.([a-z][a-zA-Z0-9]+)}/) {
> +		while (/\$\{user\.([a-z][a-zA-Z0-9]+)}/) {
>  			my $k =3D lc $1;
>  			my $v =3D $data{"user.$k"};
>  			next RULE unless defined $v;
>  			next RULE if @$v !=3D 1;
>  			next RULE unless defined $v->[0];
> -			s/\${user\.$k}/$v->[0]/g;
> +			s/\$\{user\.$k}/$v->[0]/g;
>  		}
>
>  		if (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)\s+diff\s+([^\s]+)$/)=
 {
> --
> gitgitgadget
>

RULE:
foreach (@$rules) {
while (/\${user\.([a-z][a-zA-Z0-9]+)}/) {
while (/\$\{user\.([a-z][a-zA-Z0-9]+)}/) {
my $k = lc $1;
my $v = $data{"user.$k"};
next RULE unless defined $v;
next RULE if @$v != 1;
next RULE unless defined $v->[0];
s/\${user\.$k}/$v->[0]/g;
s/\$\{user\.$k}/$v->[0]/g;
}

if (/^([AMD ]+)\s+of\s+([^\s]+)\s+for\s+([^\s]+)\s+diff\s+([^\s]+)$/) {
Expand Down