sha1-file.c: mark more strings for translation
[gitweb.git] / t / t3701-add-interactive.sh
index a9a9478a293f97920c6e3fb6d31653d8b37989a6..3e9139dca88e83165fc21e6dce06f3243bd49cd7 100755 (executable)
@@ -175,6 +175,49 @@ test_expect_success 'real edit works' '
        diff_cmp expected output
 '
 
+test_expect_success 'setup file' '
+       test_write_lines a "" b "" c >file &&
+       git add file &&
+       test_write_lines a "" d "" c >file
+'
+
+test_expect_success 'setup patch' '
+       SP=" " &&
+       NULL="" &&
+       cat >patch <<-EOF
+       @@ -1,4 +1,4 @@
+        a
+       $NULL
+       -b
+       +f
+       $SP
+       c
+       EOF
+'
+
+test_expect_success 'setup expected' '
+       cat >expected <<-EOF
+       diff --git a/file b/file
+       index b5dd6c9..f910ae9 100644
+       --- a/file
+       +++ b/file
+       @@ -1,5 +1,5 @@
+        a
+       $SP
+       -f
+       +d
+       $SP
+        c
+       EOF
+'
+
+test_expect_success 'edit can strip spaces from empty context lines' '
+       test_write_lines e n q | git add -p 2>error &&
+       test_must_be_empty error &&
+       git diff >output &&
+       diff_cmp expected output
+'
+
 test_expect_success 'skip files similarly as commit -a' '
        git reset &&
        echo file >.gitignore &&
@@ -397,6 +440,26 @@ test_expect_success TTY 'diffs can be colorized' '
        grep "$(printf "\\033")" output
 '
 
+test_expect_success TTY 'diffFilter filters diff' '
+       git reset --hard &&
+
+       echo content >test &&
+       test_config interactive.diffFilter "sed s/^/foo:/" &&
+       printf y | test_terminal git add -p >output 2>&1 &&
+
+       # avoid depending on the exact coloring or content of the prompts,
+       # and just make sure we saw our diff prefixed
+       grep foo:.*content output
+'
+
+test_expect_success TTY 'detect bogus diffFilter output' '
+       git reset --hard &&
+
+       echo content >test &&
+       test_config interactive.diffFilter "echo too-short" &&
+       printf y | test_must_fail test_terminal git add -p
+'
+
 test_expect_success 'patch-mode via -i prompts for files' '
        git reset --hard &&