]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t3701-add-interactive.sh
Makefile: add missing dependency on http.h
[git.git] / t / t3701-add-interactive.sh
index fd2a55a5c23247c010a02513af73a93641cfb067..7ad8465f8f89656bf0ce57feb45e12bc9cea5d65 100755 (executable)
@@ -4,7 +4,7 @@ test_description='add -i basic tests'
 . ./test-lib.sh
 
 if ! test_have_prereq PERL; then
-       say 'skipping git add -i tests, perl not available'
+       skip_all='skipping git add -i tests, perl not available'
        test_done
 fi
 
@@ -138,9 +138,23 @@ test_expect_success 'real edit works' '
        test_cmp expected output
 '
 
+test_expect_success 'skip files similarly as commit -a' '
+       git reset &&
+       echo file >.gitignore &&
+       echo changed >file &&
+       echo y | git add -p file &&
+       git diff >output &&
+       git reset &&
+       git commit -am commit &&
+       git diff >expected &&
+       test_cmp expected output &&
+       git reset --hard HEAD^
+'
+rm -f .gitignore
+
 if test "$(git config --bool core.filemode)" = false
 then
-       say 'skipping filemode tests (filesystem does not properly support modes)'
+       say 'skipping filemode tests (filesystem does not properly support modes)'
 else
        test_set_prereq FILEMODE
 fi
@@ -163,6 +177,17 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
        git diff          file | grep "+content"
 '
 
+
+test_expect_success FILEMODE 'stage mode and hunk' '
+       git reset --hard &&
+       echo content >>file &&
+       chmod +x file &&
+       printf "y\\ny\\n" | git add -p &&
+       git diff --cached file | grep "new mode" &&
+       git diff --cached file | grep "+content" &&
+       test -z "$(git diff file)"
+'
+
 # end of tests disabled when filemode is not usable
 
 test_expect_success 'setup again' '
@@ -203,4 +228,41 @@ test_expect_success 'add first line works' '
        test_cmp expected diff
 '
 
+cat >expected <<EOF
+diff --git a/non-empty b/non-empty
+deleted file mode 100644
+index d95f3ad..0000000
+--- a/non-empty
++++ /dev/null
+@@ -1 +0,0 @@
+-content
+EOF
+test_expect_success 'deleting a non-empty file' '
+       git reset --hard &&
+       echo content >non-empty &&
+       git add non-empty &&
+       git commit -m non-empty &&
+       rm non-empty &&
+       echo y | git add -p non-empty &&
+       git diff --cached >diff &&
+       test_cmp expected diff
+'
+
+cat >expected <<EOF
+diff --git a/empty b/empty
+deleted file mode 100644
+index e69de29..0000000
+EOF
+
+test_expect_success 'deleting an empty file' '
+       git reset --hard &&
+       > empty &&
+       git add empty &&
+       git commit -m empty &&
+       rm empty &&
+       echo y | git add -p empty &&
+       git diff --cached >diff &&
+       test_cmp expected diff
+'
+
 test_done