Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-25 22:22:00 +0300
committerJunio C Hamano <gitster@pobox.com>2019-12-25 22:22:01 +0300
commit45b96a6fa1ce2009f82d2ea1698b49fda0c11169 (patch)
treeaf4794f1aeb7ebe2ad500bec4f66205d82cbd245 /t
parentccc292e8620ecea28044166ac1189ccf6edfc6c7 (diff)
parent2e4083198d1508206488af4c82093ceb6cf20f4e (diff)
Merge branch 'js/add-p-in-c'
The effort to move "git-add--interactive" to C continues. * js/add-p-in-c: built-in add -p: show helpful hint when nothing can be staged built-in add -p: only show the applicable parts of the help text built-in add -p: implement the 'q' ("quit") command built-in add -p: implement the '/' ("search regex") command built-in add -p: implement the 'g' ("goto") command built-in add -p: implement hunk editing strbuf: add a helper function to call the editor "on an strbuf" built-in add -p: coalesce hunks after splitting them built-in add -p: implement the hunk splitting feature built-in add -p: show different prompts for mode changes and deletions built-in app -p: allow selecting a mode change as a "hunk" built-in add -p: handle deleted empty files built-in add -p: support multi-file diffs built-in add -p: offer a helpful error message when hunk navigation failed built-in add -p: color the prompt and the help text built-in add -p: adjust hunk headers as needed built-in add -p: show colored hunks by default built-in add -i: wire up the new C code for the `patch` command built-in add -i: start implementing the `patch` functionality in C
Diffstat (limited to 't')
-rwxr-xr-xt/t3701-add-interactive.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 5db6432e33..12ee321707 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -413,6 +413,36 @@ test_expect_success 'split hunk setup' '
test_write_lines 10 15 20 21 22 23 24 30 40 50 60 >test
'
+test_expect_success 'goto hunk' '
+ test_when_finished "git reset" &&
+ tr _ " " >expect <<-EOF &&
+ (2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? + 1: -1,2 +1,3 +15
+ _ 2: -2,4 +3,8 +21
+ go to which hunk? @@ -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 g 1 | git add -p >actual &&
+ tail -n 7 <actual >actual.trimmed &&
+ 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:
#
@@ -442,6 +472,18 @@ test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
! grep "^+31" actual
'
+test_expect_success 'split hunk with incomplete line at end' '
+ git reset --hard &&
+ printf "missing LF" >>test &&
+ git add test &&
+ test_write_lines before 10 20 30 40 50 60 70 >test &&
+ git grep --cached missing &&
+ test_write_lines s n y q | git add -p &&
+ test_must_fail git grep --cached missing &&
+ git grep before &&
+ test_must_fail git grep --cached before
+'
+
test_expect_failure 'edit, adding lines to the first hunk' '
test_write_lines 10 11 20 30 40 50 51 60 >test &&
git reset &&