summary refs log tree commit diff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-26 14:09:31 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-26 14:09:31 -0700
commit54e6ce5960689026f1ea97db493dc8cd0a7f8e1e (patch)
tree504f97bb1425d2f9ff1603be45130487a6355c44 /git-add--interactive.perl
parente25a76721ccc6049ec720e86707ec368574e8a71 (diff)
parentd85d7ecb80ebc93f7380b4196c303756ee051668 (diff)
Merge branch 'jk/add-p-commentchar-fix'
"git add -p" were updated in 2.12 timeframe to cope with custom
core.commentchar but the implementation was buggy and a
metacharacter like $ and * did not work.

* jk/add-p-commentchar-fix:
  add--interactive: quote commentChar regex
  add--interactive: handle EOF in prompt_yesno
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl3
1 files changed, 2 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 79d675b5b0..0e8543c865 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1081,7 +1081,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;
 
@@ -1136,6 +1136,7 @@ sub prompt_yesno {
 	while (1) {
 		print colored $prompt_color, $prompt;
 		my $line = prompt_single_character;
+		return undef unless defined $line;
 		return 0 if $line =~ /^n/i;
 		return 1 if $line =~ /^y/i;
 	}