Merge branch 'tq/git-ssh-command'
[gitweb.git] / t / t4111-apply-subdir.sh
index 60c223750f64dc9c1148eea9dc4bad19dec5f3da..1618a6dbc7c718677cf669b5f6fc96f2682992fb 100755 (executable)
@@ -36,7 +36,8 @@ test_expect_success 'setup: subdir' '
                cp "$2" file &&
                cp "$2" sub/dir/file &&
                cp "$2" sub/dir/b/file &&
-               cp "$2" objects/file
+               cp "$2" objects/file &&
+               test_might_fail git update-index --refresh -q
        }
 '
 
@@ -85,10 +86,24 @@ test_expect_success 'apply --index from subdir of toplevel' '
        test_cmp expected sub/dir/file
 '
 
+test_expect_success 'apply half-broken patch from subdir of toplevel' '
+       (
+               cd sub/dir &&
+               test_must_fail git apply <<-EOF
+               --- sub/dir/file
+               +++ sub/dir/file
+               @@ -1,0 +1,0 @@
+               --- file_in_root
+               +++ file_in_root
+               @@ -1,0 +1,0 @@
+               EOF
+       )
+'
+
 test_expect_success 'apply from .git dir' '
        cp postimage expected &&
        cp preimage .git/file &&
-       cp preimage .git/objects/file
+       cp preimage .git/objects/file &&
        (
                cd .git &&
                git apply "$patch"
@@ -96,10 +111,10 @@ test_expect_success 'apply from .git dir' '
        test_cmp expected .git/file
 '
 
-test_expect_failure 'apply from subdir of .git dir' '
+test_expect_success 'apply from subdir of .git dir' '
        cp postimage expected &&
        cp preimage .git/file &&
-       cp preimage .git/objects/file
+       cp preimage .git/objects/file &&
        (
                cd .git/objects &&
                git apply "$patch"