X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft3701-add-interactive.sh;h=e95663d8e66d5b94e574a6b956625fccfd341a05;hb=8c4021abfd170278d1a3431e2777bedd0c01fbb1;hp=c8dc1ac24111f2d77d79d4e7bfdad360e5307481;hpb=a6828f536119c3288b0be772e3870f1a464d017d;p=git.git diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index c8dc1ac24..e95663d8e 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -24,7 +24,7 @@ EOF test_expect_success 'diff works (initial)' ' (echo d; echo 1) | git add -i >output && sed -ne "/new file/,/content/p" diff && - diff -u expected diff + test_cmp expected diff ' test_expect_success 'revert works (initial)' ' git add file && @@ -57,7 +57,7 @@ EOF test_expect_success 'diff works (commit)' ' (echo d; echo 1) | git add -i >output && sed -ne "/^index/,/content/p" diff && - diff -u expected diff + test_cmp expected diff ' test_expect_success 'revert works (commit)' ' git add file && @@ -66,4 +66,97 @@ test_expect_success 'revert works (commit)' ' grep "unchanged *+3/-0 file" output ' +cat >expected <fake_editor.sh < diff && + test_cmp expected diff +' + +cat >patch <fake_editor.sh +cat >>fake_editor.sh <<\EOF +mv -f "$1" oldpatch && +mv -f patch "$1" +EOF +chmod a+x fake_editor.sh +test_set_editor "$(pwd)/fake_editor.sh" +test_expect_success 'bad edit rejected' ' + git reset && + (echo e; echo n; echo d) | git add -p >output && + grep "hunk does not apply" output +' + +cat >patch <output && + grep "hunk does not apply" output +' + +cat >patch <expected <output && + test_cmp expected output +' + +if test "$(git config --bool core.filemode)" = false +then + say 'skipping filemode tests (filesystem does not properly support modes)' +else + +test_expect_success 'patch does not affect mode' ' + git reset --hard && + echo content >>file && + chmod +x file && + printf "n\\ny\\n" | git add -p && + git show :file | grep content && + git diff file | grep "new mode" +' + +test_expect_success 'stage mode but not hunk' ' + git reset --hard && + echo content >>file && + chmod +x file && + printf "y\\nn\\n" | git add -p && + git diff --cached file | grep "new mode" && + git diff file | grep "+content" +' + +fi +# end of tests disabled when filemode is not usable + test_done