diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-26 14:09:31 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-26 14:09:31 -0700 |
commit | 54e6ce5960689026f1ea97db493dc8cd0a7f8e1e (patch) | |
tree | 504f97bb1425d2f9ff1603be45130487a6355c44 | |
parent | e25a76721ccc6049ec720e86707ec368574e8a71 (diff) | |
parent | d85d7ecb80ebc93f7380b4196c303756ee051668 (diff) | |
download | git-54e6ce5960689026f1ea97db493dc8cd0a7f8e1e.tar.gz |
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
-rwxr-xr-x | git-add--interactive.perl | 3 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 8 |
2 files changed, 10 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; } diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 2ecb43a616..2f3e7cea64 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -477,4 +477,12 @@ test_expect_success 'add -p does not expand argument lists' ' ! grep not-changed trace.out ' +test_expect_success 'hunk-editing handles custom comment char' ' + git reset --hard && + echo change >>file && + test_config core.commentChar "\$" && + echo e | GIT_EDITOR=true git add -p && + git diff --exit-code +' + test_done |