(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'apply to deeper directory without getting fooled with symlink'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'\n'> <'\n'> <'\tmkdir -p arch/i386/boot arch/x86_64 &&\n'> 
          <'\ttest_write_lines 1 2 3 4 5 >arch/i386/boot/Makefile &&\n'> <'\ttest_ln_s_add ../i386/boot arch/x86_64/boot &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m initial &&\n'> <'\tgit branch test &&\n'> <'\n'> <'\trm arch/x86_64/boot &&\n'> <'\tmkdir arch/x86_64/boot &&\n'> 
          <'\ttest_write_lines 2 3 4 5 6 >arch/x86_64/boot/Makefile &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -a -m second &&\n'> <'\n'> 
          <'\tgit format-patch --binary -1 --stdout >test.patch\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(apply)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout test &&\n'> <'\tgit diff --exit-code test &&\n'> 
          <'\tgit diff --exit-code --cached test &&\n'> <'\tgit apply --index test.patch\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'check result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit diff --exit-code master &&\n'> 
          <'\tgit diff --exit-code --cached master &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m replay &&\n'> <'\tT1=$(git rev-parse "master^{tree}") &&\n'> 
          <'\tT2=$(git rev-parse "HEAD^{tree}") &&\n'> <'\ttest "z$T1" = "z$T2"\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'do not read from beyond symbolic link'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tmkdir -p arch/x86_64/dir &&\n'> 
          <'\t>arch/x86_64/dir/file &&\n'> <'\tgit add arch/x86_64/dir/file &&\n'> <'\techo line >arch/x86_64/dir/file &&\n'> 
          <'\tgit diff >patch &&\n'> <'\tgit reset --hard &&\n'> <'\n'> <'\tmkdir arch/i386/dir &&\n'> <'\t>arch/i386/dir/file &&\n'> 
          <'\tln -s ../i386/dir arch/x86_64/dir &&\n'> <'\n'> <'\ttest_must_fail git apply patch &&\n'> <'\ttest_must_fail git apply --cached patch &&\n'> 
          <'\ttest_must_fail git apply --index patch\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'do not follow symbolic link (setup)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf arch/i386/dir arch/x86_64/dir &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tln -s ../i386/dir arch/x86_64/dir &&\n'> <'\tgit add arch/x86_64/dir &&\n'> <'\tgit diff HEAD >add_symlink.patch &&\n'> 
          <'\tgit reset --hard &&\n'> <'\n'> <'\tmkdir arch/x86_64/dir &&\n'> <'\t>arch/x86_64/dir/file &&\n'> 
          <'\tgit add arch/x86_64/dir/file &&\n'> <'\tgit diff HEAD >add_file.patch &&\n'> <'\tgit diff -R HEAD >del_file.patch &&\n'> 
          <'\tgit reset --hard &&\n'> <'\trm -fr arch/x86_64/dir &&\n'> <'\n'> <'\tcat add_symlink.patch add_file.patch >patch &&\n'> 
          <'\tcat add_symlink.patch del_file.patch >tricky_del &&\n'> <'\n'> <'\tmkdir arch/i386/dir\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'do not follow symbolic link (same input)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\t# same input creates a confusing symbolic link\n'> 
          <'\ttest_must_fail git apply patch 2>error-wt &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-wt &&\n'> 
          <'\ttest_path_is_missing arch/x86_64/dir &&\n'> <'\ttest_path_is_missing arch/i386/dir/file &&\n'> <'\n'> 
          <'\ttest_must_fail git apply --index patch 2>error-ix &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-ix &&\n'> 
          <'\ttest_path_is_missing arch/x86_64/dir &&\n'> <'\ttest_path_is_missing arch/i386/dir/file &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch arch/x86_64/dir &&\n'> <'\ttest_must_fail git ls-files --error-unmatch arch/i386/dir &&\n'> <'\n'> 
          <'\ttest_must_fail git apply --cached patch 2>error-ct &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-ct &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch arch/x86_64/dir &&\n'> <'\ttest_must_fail git ls-files --error-unmatch arch/i386/dir &&\n'> <'\n'> 
          <'\t>arch/i386/dir/file &&\n'> <'\tgit add arch/i386/dir/file &&\n'> <'\n'> <'\ttest_must_fail git apply tricky_del &&\n'> 
          <'\ttest_path_is_file arch/i386/dir/file &&\n'> <'\n'> <'\ttest_must_fail git apply --index tricky_del &&\n'> 
          <'\ttest_path_is_file arch/i386/dir/file &&\n'> <'\ttest_must_fail git ls-files --error-unmatch arch/x86_64/dir &&\n'> 
          <'\tgit ls-files --error-unmatch arch/i386/dir &&\n'> <'\n'> <'\ttest_must_fail git apply --cached tricky_del &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch arch/x86_64/dir &&\n'> <'\tgit ls-files --error-unmatch arch/i386/dir\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'do not follow symbolic link (existing)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\t# existing symbolic link\n'> <'\tgit reset --hard &&\n'> 
          <'\tln -s ../i386/dir arch/x86_64/dir &&\n'> <'\tgit add arch/x86_64/dir &&\n'> <'\n'> 
          <'\ttest_must_fail git apply add_file.patch 2>error-wt-add &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-wt-add &&\n'> 
          <'\ttest_path_is_missing arch/i386/dir/file &&\n'> <'\n'> <'\tmkdir arch/i386/dir &&\n'> <'\t>arch/i386/dir/file &&\n'> 
          <'\ttest_must_fail git apply del_file.patch 2>error-wt-del &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-wt-del &&\n'> 
          <'\ttest_path_is_file arch/i386/dir/file &&\n'> <'\trm arch/i386/dir/file &&\n'> <'\n'> 
          <'\ttest_must_fail git apply --index add_file.patch 2>error-ix-add &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-ix-add &&\n'> 
          <'\ttest_path_is_missing arch/i386/dir/file &&\n'> <'\ttest_must_fail git ls-files --error-unmatch arch/i386/dir &&\n'> <'\n'> 
          <'\ttest_must_fail git apply --cached add_file.patch 2>error-ct-file &&\n'> <'\ttest_i18ngrep "beyond a symbolic link" error-ct-file &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch arch/i386/dir\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)