(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'git p4 rename'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./lib-git-p4.sh)})
    (C {(test_expect_success)} {(SQ <'start p4d'>)} {(SQ <'\n'> <'\tstart_p4d\n'>)})
    (C {(test_expect_success)} {(SQ <'p4 help unknown returns 1'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\t(\n'> <'\t\t\tp4 help client >errs 2>&1\n'> 
          <'\t\t\techo $? >retval\n'> <'\t\t)\n'> <'\t\techo 0 >expected &&\n'> <'\t\ttest_cmp expected retval &&\n'> <'\t\trm retval &&\n'> 
          <'\t\t(\n'> <'\t\t\tp4 help nosuchcommand >errs 2>&1\n'> <'\t\t\techo $? >retval\n'> <'\t\t)\n'> 
          <'\t\techo 1 >expected &&\n'> <'\t\ttest_cmp expected retval &&\n'> <'\t\trm retval\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'create files'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&\n'> <'\t\tcat >file1 <<-EOF &&\n'> <'\t\tA large block of text\n'> <'\t\tin file1 that will generate\n'> 
          <'\t\tenough context so that rename\n'> <'\t\tand copy detection will find\n'> <'\t\tsomething interesting to do.\n'> <'\t\tEOF\n'> 
          <'\t\tcat >file2 <<-EOF &&\n'> <'\t\t/*\n'> <'\t\t * This blob looks a bit\n'> <'\t\t * different.\n'> <'\t\t */\n'> 
          <'\t\tint main(int argc, char **argv)\n'> <'\t\t{\n'> <'\t\t\tchar text[200];\n'> <'\n'> <'\t\t\tstrcpy(text, "copy/rename this");\n'> 
          <'\t\t\tprintf("text is %s\\n", text);\n'> <'\t\t\treturn 0;\n'> <'\t\t}\n'> <'\t\tEOF\n'> <'\t\tp4 add file1 file2 &&\n'> 
          <'\t\tp4 submit -d "add files"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'detect renames'>)} 
      {
        (SQ <'\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\n'> 
          <'\t\tgit mv file1 file4 &&\n'> <'\t\tgit commit -a -m "Rename file1 to file4" &&\n'> <'\t\tgit diff-tree -r -M HEAD &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file4 >filelog &&\n'> <'\t\t! grep " from //depot" filelog &&\n'> <'\n'> 
          <'\t\tgit mv file4 file5 &&\n'> <'\t\tgit commit -a -m "Rename file4 to file5" &&\n'> <'\t\tgit diff-tree -r -M HEAD &&\n'> 
          <'\t\tgit config git-p4.detectRenames true &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file5 >filelog &&\n'> 
          <'\t\tgrep " from //depot/file4" filelog &&\n'> <'\n'> <'\t\tgit mv file5 file6 &&\n'> <'\t\techo update >>file6 &&\n'> <'\t\tgit add file6 &&\n'> 
          <'\t\tgit commit -a -m "Rename file5 to file6 with changes" &&\n'> <'\t\tgit diff-tree -r -M HEAD &&\n'> 
          <
'\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&\n'
          > <'\t\ttest -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&\n'> 
          <'\t\tgit config git-p4.detectRenames $(($level + 2)) &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file6 >filelog &&\n'> 
          <'\t\t! grep " from //depot" filelog &&\n'> <'\n'> <'\t\tgit mv file6 file7 &&\n'> <'\t\techo update >>file7 &&\n'> <'\t\tgit add file7 &&\n'> 
          <'\t\tgit commit -a -m "Rename file6 to file7 with changes" &&\n'> <'\t\tgit diff-tree -r -M HEAD &&\n'> 
          <
'\t\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&\n'
          > <'\t\ttest -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&\n'> 
          <'\t\tgit config git-p4.detectRenames $(($level - 2)) &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file7 >filelog &&\n'> 
          <'\t\tgrep " from //depot/file6" filelog\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'detect copies'>)} 
      {
        (SQ <'\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\n'> 
          <'\t\techo "file8" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> <'\t\tgit p4 submit &&\n'> 
          <'\t\tcp file2 file8 &&\n'> <'\t\tgit add file8 &&\n'> <'\t\tgit commit -a -m "Copy file2 to file8" &&\n'> 
          <'\t\tgit diff-tree -r -C HEAD &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file8 &&\n'> 
          <'\t\tp4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&\n'> <'\n'> <'\t\techo "file9" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\n'> <'\t\tcp file2 file9 &&\n'> <'\t\tgit add file9 &&\n'> 
          <'\t\tgit commit -a -m "Copy file2 to file9" &&\n'> <'\t\tgit diff-tree -r -C HEAD &&\n'> <'\t\tgit config git-p4.detectCopies true &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file9 &&\n'> 
          <'\t\tp4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&\n'> <'\n'> <'\t\techo "file10" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\n'> <'\t\techo "file2" >>file2 &&\n'> <'\t\tcp file2 file10 &&\n'> <'\t\tgit add file2 file10 &&\n'> 
          <'\t\tgit commit -a -m "Modify and copy file2 to file10" &&\n'> <'\t\tgit diff-tree -r -C HEAD &&\n'> 
          <'\t\tsrc=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) &&\n'> <'\t\ttest "$src" = file2 &&\n'> <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file10 &&\n'> 
          <'\t\tp4 filelog //depot/file10 | grep -q "branch from //depot/file2" &&\n'> <'\n'> <'\t\techo "file11" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\n'> <'\t\tcp file2 file11 &&\n'> <'\t\tgit add file11 &&\n'> 
          <'\t\tgit commit -a -m "Copy file2 to file11" &&\n'> <'\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n'> 
          <'\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n'> <'\t\ttest "$src" = file2 &&\n'> <'\t\tgit config git-p4.detectCopiesHarder true &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file11 &&\n'> 
          <'\t\tp4 filelog //depot/file11 | grep -q "branch from //depot/file2" &&\n'> <'\n'> <'\t\techo "file12" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\n'> <'\t\tcp file2 file12 &&\n'> <'\t\techo "some text" >>file12 &&\n'> <'\t\tgit add file12 &&\n'> 
          <'\t\tgit commit -a -m "Copy file2 to file12 with changes" &&\n'> <'\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n'> 
          <
'\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&\n'
          > <'\t\ttest -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&\n'> 
          <'\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n'> <'\t\ttest "$src" = file2 &&\n'> <'\t\tgit config git-p4.detectCopies $(($level + 2)) &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file12 &&\n'> 
          <'\t\tp4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&\n'> <'\n'> <'\t\techo "file13" >>file2 &&\n'> <'\t\tgit commit -a -m "Differentiate file2" &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\n'> <'\t\tcp file2 file13 &&\n'> <'\t\techo "different text" >>file13 &&\n'> 
          <'\t\tgit add file13 &&\n'> <'\t\tgit commit -a -m "Copy file2 to file13 with changes" &&\n'> 
          <'\t\tgit diff-tree -r -C --find-copies-harder HEAD &&\n'> 
          <
'\t\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&\n'
          > <'\t\ttest -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&\n'> 
          <'\t\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n'> <'\t\ttest "$src" = file2 &&\n'> <'\t\tgit config git-p4.detectCopies $(($level - 2)) &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tp4 filelog //depot/file13 &&\n'> 
          <'\t\tp4 filelog //depot/file13 | grep -q "branch from //depot/file2"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_lazy_prereq)} {(P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW)} 
      {
        (SQ <'\n'> <'\tp4 configure show run.move.allow >out &&\n'> <'\tegrep ^run.move.allow: out\n'>)
      }
    )
    (C {(test_expect_success)} {(P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW)} 
      {(SQ <'do not use p4 move when administratively disabled'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "p4 configure set run.move.allow=1" &&\n'> 
          <'\tp4 configure set run.move.allow=0 &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\techo move-disallow-file >move-disallow-file &&\n'> 
          <'\t\tp4 add move-disallow-file &&\n'> <'\t\tp4 submit -d "add move-disallow-file"\n'> <'\t) &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> 
          <'\t\tgit config git-p4.detectRenames true &&\n'> <'\t\tgit mv move-disallow-file move-disallow-file-moved &&\n'> 
          <'\t\tgit commit -m "move move-disallow-file" &&\n'> <'\t\tgit p4 submit\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'kill p4d'>)} {(SQ <'\n'> <'\tkill_p4d\n'>)})
    (C {(test_done)})
  ]
)