(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"patching from inconvenient places">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <"\n"> <"\tcat >patch <<-\\EOF &&\n"> <"\tdiff file.orig file\n"> <"\t--- a/file.orig\n"> <"\t+++ b/file\n"> <"\t@@ -1 +1,2 @@\n"> <"\t 1\n"> <"\t+2\n"> <"\tEOF\n"> <"\tpatch=\"$(pwd)/patch\" &&\n"> <"\n"> <"\techo 1 >preimage &&\n"> <"\tprintf \"%s\\n\" 1 2 >postimage &&\n"> <"\techo 3 >other &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\tgit commit --allow-empty -m basis\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: subdir">)} { (SQ <"\n"> <"\treset_subdir() {\n"> <"\t\tgit reset &&\n"> <"\t\tmkdir -p sub/dir/b &&\n"> <"\t\tmkdir -p objects &&\n"> <"\t\tcp \"$1\" file &&\n"> <"\t\tcp \"$1\" objects/file &&\n"> <"\t\tcp \"$1\" sub/dir/file &&\n"> <"\t\tcp \"$1\" sub/dir/b/file &&\n"> <"\t\tgit add file sub/dir/file sub/dir/b/file objects/file &&\n"> <"\t\tcp \"$2\" file &&\n"> <"\t\tcp \"$2\" sub/dir/file &&\n"> <"\t\tcp \"$2\" sub/dir/b/file &&\n"> <"\t\tcp \"$2\" objects/file &&\n"> <"\t\ttest_might_fail git update-index --refresh -q\n"> <"\t}\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply from subdir of toplevel">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\treset_subdir other preimage &&\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\tgit apply \"$patch\"\n"> <"\t) &&\n"> <"\ttest_cmp expected sub/dir/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply --cached from subdir of toplevel">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\tcp other expected.working &&\n"> <"\treset_subdir preimage other &&\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\tgit apply --cached \"$patch\"\n"> <"\t) &&\n"> <"\tgit show :sub/dir/file >actual &&\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected.working sub/dir/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply --index from subdir of toplevel">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\treset_subdir preimage other &&\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\ttest_must_fail git apply --index \"$patch\"\n"> <"\t) &&\n"> <"\treset_subdir other preimage &&\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\ttest_must_fail git apply --index \"$patch\"\n"> <"\t) &&\n"> <"\treset_subdir preimage preimage &&\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\tgit apply --index \"$patch\"\n"> <"\t) &&\n"> <"\tgit show :sub/dir/file >actual &&\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected sub/dir/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply half-broken patch from subdir of toplevel">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd sub/dir &&\n"> <"\t\ttest_must_fail git apply <<-EOF\n"> <"\t\t--- sub/dir/file\n"> <"\t\t+++ sub/dir/file\n"> <"\t\t@@ -1,0 +1,0 @@\n"> <"\t\t--- file_in_root\n"> <"\t\t+++ file_in_root\n"> <"\t\t@@ -1,0 +1,0 @@\n"> <"\t\tEOF\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply from .git dir">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\tcp preimage .git/file &&\n"> <"\tcp preimage .git/objects/file &&\n"> <"\t(\n"> <"\t\tcd .git &&\n"> <"\t\tgit apply \"$patch\"\n"> <"\t) &&\n"> <"\ttest_cmp expected .git/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply from subdir of .git dir">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\tcp preimage .git/file &&\n"> <"\tcp preimage .git/objects/file &&\n"> <"\t(\n"> <"\t\tcd .git/objects &&\n"> <"\t\tgit apply \"$patch\"\n"> <"\t) &&\n"> <"\ttest_cmp expected .git/objects/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply --cached from .git dir">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\tcp other expected.working &&\n"> <"\tcp other .git/file &&\n"> <"\treset_subdir preimage other &&\n"> <"\t(\n"> <"\t\tcd .git &&\n"> <"\t\tgit apply --cached \"$patch\"\n"> <"\t) &&\n"> <"\tgit show :file >actual &&\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected.working file &&\n"> <"\ttest_cmp expected.working .git/file\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply --cached from subdir of .git dir">)} { (SQ <"\n"> <"\tcp postimage expected &&\n"> <"\tcp preimage expected.subdir &&\n"> <"\tcp other .git/file &&\n"> <"\tcp other .git/objects/file &&\n"> <"\treset_subdir preimage other &&\n"> <"\t(\n"> <"\t\tcd .git/objects &&\n"> <"\t\tgit apply --cached \"$patch\"\n"> <"\t) &&\n"> <"\tgit show :file >actual &&\n"> <"\tgit show :objects/file >actual.subdir &&\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected.subdir actual.subdir\n"> ) } ) (C {(test_done)}) ] )