diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-12-13 08:08:03 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-13 12:37:14 -0800 |
commit | d6cf873340703098f2d7f54be457e4db1b32cf7b (patch) | |
tree | 98b9b8e925113bd30fd7074b0833a91a8f5edb0d /t | |
parent | built-in add -p: implement the 'g' ("goto") command (diff) | |
download | tgif-d6cf873340703098f2d7f54be457e4db1b32cf7b.tar.xz |
built-in add -p: implement the '/' ("search regex") command
This patch implements the hunk searching feature in the C version of
`git add -p`.
A test is added to verify that this behavior matches the one of the Perl
version of `git add -p`.
Note that this involves a change of behavior: the Perl version uses (of
course) the Perl flavor of regular expressions, while this patch uses
the regcomp()/regexec(), i.e. POSIX extended regular expressions. In
practice, this behavior change is unlikely to matter.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t3701-add-interactive.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 57c656a20c..12ee321707 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -429,6 +429,20 @@ test_expect_success 'goto hunk' ' test_cmp expect actual.trimmed ' +test_expect_success 'navigate to hunk via regex' ' + test_when_finished "git reset" && + tr _ " " >expect <<-EOF && + (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? @@ -1,2 +1,3 @@ + _10 + +15 + _20 + (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]?_ + EOF + test_write_lines s y /1,2 | git add -p >actual && + tail -n 5 <actual >actual.trimmed && + test_cmp expect actual.trimmed +' + test_expect_success 'split hunk "add -p (edit)"' ' # Split, say Edit and do nothing. Then: # |