From d85d7ecb80ebc93f7380b4196c303756ee051668 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 21 Jun 2017 15:28:59 -0400 Subject: add--interactive: quote commentChar regex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since c9d961647 (i18n: add--interactive: mark edit_hunk_manually message for translation, 2016-12-14), when the user asks to edit a hunk manually, we respect core.commentChar in generating the edit instructions. However, when we then strip out comment lines, we use a simple regex like: /^$commentChar/ If your chosen comment character is a regex metacharacter, then that will behave in a confusing manner ("$", for instance, would only eliminate blank lines, not actual comment lines). We can fix that by telling perl not to respect metacharacters. Reported-by: Christian Rösch Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-add--interactive.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-add--interactive.perl') diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 7c9532473..395dd5eb4 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1097,7 +1097,7 @@ EOF2 open $fh, '<', $hunkfile or die sprintf(__("failed to open hunk edit file for reading: %s"), $!); - my @newtext = grep { !/^$comment_line_char/ } <$fh>; + my @newtext = grep { !/^\Q$comment_line_char\E/ } <$fh>; close $fh; unlink $hunkfile; -- cgit v1.2.1