Skip to content

Commit fd2fb4a

Browse files
avargitster
authored andcommitted
add -p: fix 2.17.0-rc* regression due to moved code
Fix a regression in 88f6ffc ("add -p: only bind search key if there's more than one hunk", 2018-02-13) which is present in 2.17.0-rc*, but not 2.16.0. In Perl, regex variables like $1 always refer to the last regex match. When the aforementioned change added a new regex match between the old match and the corresponding code that was expecting $1, the $1 variable would always be undef, since the newly inserted regex match doesn't have any captures. As a result the "/" feature to search for a string in a hunk by regex completely broke, on git.git: $ perl -pi -e 's/Git/Tig/g' README.md $ ./git --exec-path=$PWD add -p [..] Stage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? s Split into 4 hunks. [...] Stage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? /Many Use of uninitialized value $1 in string eq at /home/avar/g/git/git-add--interactive line 1568, <STDIN> line 1. search for regex? Many I.e. the initial "/regex" command wouldn't work, and would always emit a warning and ask again for a regex, now it works as intended again. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4bdd6e7 commit fd2fb4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-add--interactive.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ sub patch_update_file {
14921492
error_msg __("No other hunks to search\n");
14931493
next;
14941494
}
1495-
if ($1 eq "") {
1495+
if ($regex eq "") {
14961496
print colored $prompt_color, __("search for regex? ");
14971497
$regex = <STDIN>;
14981498
if (defined $regex) {

0 commit comments

Comments
 (0)