(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"Test export of commits to CVS">)}
          spids: [12]
        )
      ]
      spids: [12]
    )
    (C {(.)} {(./test-lib.sh)})
    (If
      arms: [
        (if_arm
          cond: [
            (Sentence
              child: (Pipeline children:[(C {(test_have_prereq)} {(PERL)})] negated:True)
              terminator: <Op_Semi ";">
            )
          ]
          action: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:skip_all)
                  op: Equal
                  rhs: {(SQ <"skipping git cvsexportcommit tests, perl not available">)}
                  spids: [35]
                )
              ]
              spids: [35]
            )
            (C {(test_done)})
          ]
          spids: [-1 32]
        )
      ]
      spids: [-1 43]
    )
    (SimpleCommand
      words: [{(cvs)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[48])
        (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[51])
      ]
    )
    (If
      arms: [
        (if_arm
          cond: [(C {(test)} {($ VSub_QMark "$?")} {(-ne)} {(1)})]
          action: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:skip_all)
                  op: Equal
                  rhs: {(SQ <"skipping git cvsexportcommit tests, cvs not found">)}
                  spids: [67]
                )
              ]
              spids: [67]
            )
            (C {(test_done)})
          ]
          spids: [-1 64]
        )
      ]
      spids: [-1 75]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:CVSROOT)
          op: Equal
          rhs: {($ VSub_Name "$PWD") (/tmpcvsroot)}
          spids: [78]
        )
      ]
      spids: [78]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:CVSWORK)
          op: Equal
          rhs: {($ VSub_Name "$PWD") (/cvswork)}
          spids: [82]
        )
      ]
      spids: [82]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:GIT_DIR)
          op: Equal
          rhs: {($ VSub_Name "$PWD") (/.git)}
          spids: [86]
        )
      ]
      spids: [86]
    )
    (C {(export)} {(CVSROOT)} {(CVSWORK)} {(GIT_DIR)})
    (C {(rm)} {(-rf)} {(DQ ($ VSub_Name "$CVSROOT"))} {(DQ ($ VSub_Name "$CVSWORK"))})
    (AndOr
      children: [
        (C {(cvs)} {(init)})
        (AndOr
          children: [
            (C {(test)} {(-d)} {(DQ ($ VSub_Name "$CVSROOT"))})
            (AndOr
              children: [
                (C {(cvs)} {(-Q)} {(co)} {(-d)} {(DQ ($ VSub_Name "$CVSWORK"))} {(.)})
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(echo)}]
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(empty)} spids:[146])]
                    )
                    (AndOr
                      children: [
                        (C {(git)} {(add)} {(empty)})
                        (AndOr
                          children: [
                            (SimpleCommand
                              words: [{(git)} {(commit)} {(-q)} {(-a)} {(-m)} {(DQ (Initial))}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: 2
                                  arg_word: {(/dev/null)}
                                  spids: [173]
                                )
                              ]
                            )
                            (C {(exit)} {(1)})
                          ]
                          op_id: Op_DPipe
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          op_id: Op_DAmp
        )
      ]
      op_id: Op_DAmp
    )
    (FuncDef
      name: check_entries
      body: 
        (BraceGroup
          children: [
            (Pipeline
              children: [
                (C {(sed)} {(-ne)} {(SQ <"/^\\//p">)} {(DQ ($ VSub_Number "$1") (/CVS/Entries))})
                (C {(sort)})
                (SimpleCommand
                  words: [{(cut)} {(-d/)} {(-f2) (Lit_Comma ",") (3) (Lit_Comma ",") (5)}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[224])]
                )
              ]
              negated: False
            )
            (If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-z)} {(DQ ($ VSub_Number "$2"))})]
                  action: [
                    (SimpleCommand
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expected)} spids:[242])]
                    )
                  ]
                  spids: [-1 239]
                )
              ]
              else_action: [
                (Pipeline
                  children: [
                    (C {(printf)} {(SQ <"%s\\n">)} {(DQ ($ VSub_Number "$2"))})
                    (SimpleCommand
                      words: [{(tr)} {(SQ <"|">)} {(SQ <"\\012">)}]
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expected)} spids:[271])]
                    )
                  ]
                  negated: False
                )
              ]
              spids: [246 275]
            )
            (C {(test_cmp)} {(expected)} {(actual)})
          ]
          spids: [188]
        )
      spids: [183 187]
    )
    (C {(test_expect_success)} {(SQ <"New file">)} 
      {
        (SQ <"mkdir A B C D E F &&\n"> <"     echo hello1 >A/newfile1.txt &&\n"> 
          <"     echo hello2 >B/newfile2.txt &&\n"> <"     cp \"$TEST_DIRECTORY\"/test-binary-1.png C/newfile3.png &&\n"> 
          <"     cp \"$TEST_DIRECTORY\"/test-binary-1.png D/newfile4.png &&\n"> <"     git add A/newfile1.txt &&\n"> <"     git add B/newfile2.txt &&\n"> 
          <"     git add C/newfile3.png &&\n"> <"     git add D/newfile4.png &&\n"> <"     git commit -a -m \"Test: New file\" &&\n"> 
          <"     id=$(git rev-list --max-count=1 HEAD) &&\n"> <"     (cd \"$CVSWORK\" &&\n"> <"     git cvsexportcommit -c $id &&\n"> 
          <"     check_entries A \"newfile1.txt/1.1/\" &&\n"> <"     check_entries B \"newfile2.txt/1.1/\" &&\n"> 
          <"     check_entries C \"newfile3.png/1.1/-kb\" &&\n"> <"     check_entries D \"newfile4.png/1.1/-kb\" &&\n"> 
          <"     test_cmp A/newfile1.txt ../A/newfile1.txt &&\n"> <"     test_cmp B/newfile2.txt ../B/newfile2.txt &&\n"> 
          <"     test_cmp C/newfile3.png ../C/newfile3.png &&\n"> <"     test_cmp D/newfile4.png ../D/newfile4.png\n"> <"     )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"Remove two files, add two and update two">)} 
      {
        (SQ <"echo Hello1 >>A/newfile1.txt &&\n"> <"     rm -f B/newfile2.txt &&\n"> 
          <"     rm -f C/newfile3.png &&\n"> <"     echo Hello5  >E/newfile5.txt &&\n"> 
          <"     cp \"$TEST_DIRECTORY\"/test-binary-2.png D/newfile4.png &&\n"> <"     cp \"$TEST_DIRECTORY\"/test-binary-1.png F/newfile6.png &&\n"> 
          <"     git add E/newfile5.txt &&\n"> <"     git add F/newfile6.png &&\n"> <"     git commit -a -m \"Test: Remove, add and update\" &&\n"> 
          <"     id=$(git rev-list --max-count=1 HEAD) &&\n"> <"     (cd \"$CVSWORK\" &&\n"> <"     git cvsexportcommit -c $id &&\n"> 
          <"     check_entries A \"newfile1.txt/1.2/\" &&\n"> <"     check_entries B \"\" &&\n"> <"     check_entries C \"\" &&\n"> 
          <"     check_entries D \"newfile4.png/1.2/-kb\" &&\n"> <"     check_entries E \"newfile5.txt/1.1/\" &&\n"> 
          <"     check_entries F \"newfile6.png/1.1/-kb\" &&\n"> <"     test_cmp A/newfile1.txt ../A/newfile1.txt &&\n"> 
          <"     test_cmp D/newfile4.png ../D/newfile4.png &&\n"> <"     test_cmp E/newfile5.txt ../E/newfile5.txt &&\n"> 
          <"     test_cmp F/newfile6.png ../F/newfile6.png\n"> <"     )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"Fail to change binary more than one generation old">)} 
      {
        (SQ <"cat F/newfile6.png >>D/newfile4.png &&\n"> 
          <"     git commit -a -m \"generatiion 1\" &&\n"> <"     cat F/newfile6.png >>D/newfile4.png &&\n"> <"     git commit -a -m \"generation 2\" &&\n"> 
          <"     id=$(git rev-list --max-count=1 HEAD) &&\n"> <"     (cd \"$CVSWORK\" &&\n"> <"     test_must_fail git cvsexportcommit -c $id\n"> <"     )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"Remove only binary files">)} 
      {
        (SQ <"git reset --hard HEAD^^ &&\n"> <"     rm -f D/newfile4.png &&\n"> 
          <"     git commit -a -m \"test: remove only a binary file\" &&\n"> <"     id=$(git rev-list --max-count=1 HEAD) &&\n"> <"     (cd \"$CVSWORK\" &&\n"> 
          <"     git cvsexportcommit -c $id &&\n"> <"     check_entries A \"newfile1.txt/1.2/\" &&\n"> <"     check_entries B \"\" &&\n"> 
          <"     check_entries C \"\" &&\n"> <"     check_entries D \"\" &&\n"> <"     check_entries E \"newfile5.txt/1.1/\" &&\n"> 
          <"     check_entries F \"newfile6.png/1.1/-kb\" &&\n"> <"     test_cmp A/newfile1.txt ../A/newfile1.txt &&\n"> 
          <"     test_cmp E/newfile5.txt ../E/newfile5.txt &&\n"> <"     test_cmp F/newfile6.png ../F/newfile6.png\n"> <"     )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"Remove only a text file">)} 
      {
        (SQ <"rm -f A/newfile1.txt &&\n"> 
          <"     git commit -a -m \"test: remove only a binary file\" &&\n"> <"     id=$(git rev-list --max-count=1 HEAD) &&\n"> <"     (cd \"$CVSWORK\" &&\n"> 
          <"     git cvsexportcommit -c $id &&\n"> <"     check_entries A \"\" &&\n"> <"     check_entries B \"\" &&\n"> 
          <"     check_entries C \"\" &&\n"> <"     check_entries D \"\" &&\n"> <"     check_entries E \"newfile5.txt/1.1/\" &&\n"> 
          <"     check_entries F \"newfile6.png/1.1/-kb\" &&\n"> <"     test_cmp E/newfile5.txt ../E/newfile5.txt &&\n"> 
          <"     test_cmp F/newfile6.png ../F/newfile6.png\n"> <"     )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"New file with spaces in file name">)} 
      {
        (SQ <"mkdir \"G g\" &&\n"> <"      echo ok then >\"G g/with spaces.txt\" &&\n"> 
          <"      git add \"G g/with spaces.txt\" && \\\n"> <"      cp \"$TEST_DIRECTORY\"/test-binary-1.png \"G g/with spaces.png\" && \\\n"> 
          <"      git add \"G g/with spaces.png\" &&\n"> <"      git commit -a -m \"With spaces\" &&\n"> <"      id=$(git rev-list --max-count=1 HEAD) &&\n"> 
          <"      (cd \"$CVSWORK\" &&\n"> <"      git cvsexportcommit -c $id &&\n"> 
          <"      check_entries \"G g\" \"with spaces.png/1.1/-kb|with spaces.txt/1.1/\"\n"> <"      )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"Update file with spaces in file name">)} 
      {
        (SQ <"echo Ok then >>\"G g/with spaces.txt\" &&\n"> 
          <"      cat \"$TEST_DIRECTORY\"/test-binary-1.png >>\"G g/with spaces.png\" && \\\n"> <"      git add \"G g/with spaces.png\" &&\n"> <"      git commit -a -m \"Update with spaces\" &&\n"> 
          <"      id=$(git rev-list --max-count=1 HEAD) &&\n"> <"      (cd \"$CVSWORK\" &&\n"> <"      git cvsexportcommit -c $id\n"> 
          <"      check_entries \"G g\" \"with spaces.png/1.2/-kb|with spaces.txt/1.2/\"\n"> <"      )">
        )
      }
    )
    (If
      arms: [
        (if_arm
          cond: [
            (AndOr
              children: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:p)
                      op: Equal
                      rhs: 
                        {
                          (DQ 
                            (
"\u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6"
                            )
                          )
                        }
                      spids: [543]
                    )
                  ]
                  spids: [543]
                )
                (AndOr
                  children: [
                    (C {(mkdir)} {(-p)} {(DQ (tst/) ($ VSub_Name "$p"))})
                    (AndOr
                      children: [
                        (SimpleCommand
                          words: [{(date)}]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(DQ (tst/) ($ VSub_Name "$p") (/day))}
                              spids: [565]
                            )
                          ]
                        )
                        (AndOr
                          children: [
                            (Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (LhsName name:found)
                                  op: Equal
                                  rhs: 
                                    {
                                      (CommandSubPart
                                        command_list: 
                                          (CommandList
                                            children: [(C {(find)} {(tst)} {(-type)} {(f)} {(-print)})]
                                          )
                                        left_token: <Left_CommandSub "$(">
                                        spids: [576 586]
                                      )
                                    }
                                  spids: [575]
                                )
                              ]
                              spids: [575]
                            )
                            (AndOr
                              children: [
                                (C {(test)} {(DQ (z) ($ VSub_Name "$found"))} {(Lit_Other "=")} 
                                  {(DQ (ztst/) ($ VSub_Name "$p") (/day))}
                                )
                                (C {(rm)} {(-fr)} {(tst)})
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          action: [
            (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"File with non-ascii file name">)} 
              {
                (SQ 
                  <
"mkdir -p \u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6 &&\n"
                  > 
                  <
"      echo Foo >\u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6/g\u00e5rdets\u00e5g\u00e5rdet.txt &&\n"
                  > 
                  <
"      git add \u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6/g\u00e5rdets\u00e5g\u00e5rdet.txt &&\n"
                  > 
                  <
"      cp \"$TEST_DIRECTORY\"/test-binary-1.png \u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6/g\u00e5rdets\u00e5g\u00e5rdet.png &&\n"
                  > 
                  <
"      git add \u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6/g\u00e5rdets\u00e5g\u00e5rdet.png &&\n"
                  > <"      git commit -a -m \"G\u00e5r det s\u00e5 g\u00e5r det\" && \\\n"> 
                  <"      id=$(git rev-list --max-count=1 HEAD) &&\n"> <"      (cd \"$CVSWORK\" &&\n"> <"      git cvsexportcommit -v -c $id &&\n"> 
                  <"      check_entries \\\n"> 
                  <
"      \"\u00c5/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/\u00e5/\u00e4/\u00f6\" \\\n"
                  > <"      \"g\u00e5rdets\u00e5g\u00e5rdet.png/1.1/-kb|g\u00e5rdets\u00e5g\u00e5rdet.txt/1.1/\"\n"> 
                  <"      )">
                )
              }
            )
          ]
          spids: [-1 615]
        )
      ]
      spids: [-1 651]
    )
    (C {(rm)} {(-fr)} {(tst)})
    (C {(test_expect_success)} {(SQ <"Mismatching patch should fail">)} 
      {
        (SQ <"date >>\"E/newfile5.txt\" &&\n"> <"      git add \"E/newfile5.txt\" &&\n"> 
          <"      git commit -a -m \"Update one\" &&\n"> <"      date >>\"E/newfile5.txt\" &&\n"> <"      git add \"E/newfile5.txt\" &&\n"> 
          <"      git commit -a -m \"Update two\" &&\n"> <"      id=$(git rev-list --max-count=1 HEAD) &&\n"> <"      (cd \"$CVSWORK\" &&\n"> 
          <"      test_must_fail git cvsexportcommit -c $id\n"> <"      )">
        )
      }
    )
    (C {(test_expect_success)} {(FILEMODE)} {(SQ <"Retain execute bit">)} 
      {
        (SQ <"mkdir G &&\n"> <"      echo executeon >G/on &&\n"> <"      chmod +x G/on &&\n"> 
          <"      echo executeoff >G/off &&\n"> <"      git add G/on &&\n"> <"      git add G/off &&\n"> 
          <"      git commit -a -m \"Execute test\" &&\n"> <"      (cd \"$CVSWORK\" &&\n"> <"      git cvsexportcommit -c HEAD\n"> <"      test -x G/on &&\n"> 
          <"      ! test -x G/off\n"> <"      )">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"-w option should work with relative GIT_DIR">)} 
      {
        (SQ <"\n"> <"      mkdir W &&\n"> <"      echo foobar >W/file1.txt &&\n"> 
          <"      echo bazzle >W/file2.txt &&\n"> <"      git add W/file1.txt &&\n"> <"      git add W/file2.txt &&\n"> 
          <"      git commit -m \"More updates\" &&\n"> <"      id=$(git rev-list --max-count=1 HEAD) &&\n"> <"      (cd \"$GIT_DIR\" &&\n"> 
          <"      GIT_DIR=. git cvsexportcommit -w \"$CVSWORK\" -c $id &&\n"> <"      check_entries \"$CVSWORK/W\" \"file1.txt/1.1/|file2.txt/1.1/\" &&\n"> 
          <"      test_cmp \"$CVSWORK/W/file1.txt\" ../W/file1.txt &&\n"> <"      test_cmp \"$CVSWORK/W/file2.txt\" ../W/file2.txt\n"> <"      )\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"check files before directories">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo Notes > release-notes &&\n"> <"\tgit add release-notes &&\n"> 
          <"\tgit commit -m \"Add release notes\" release-notes &&\n"> <"\tid=$(git rev-parse HEAD) &&\n"> <"\tgit cvsexportcommit -w \"$CVSWORK\" -c $id &&\n"> <"\n"> 
          <"\techo new > DS &&\n"> <"\techo new > E/DS &&\n"> <"\techo modified > release-notes &&\n"> 
          <"\tgit add DS E/DS release-notes &&\n"> <"\tgit commit -m \"Add two files with the same basename\" &&\n"> <"\tid=$(git rev-parse HEAD) &&\n"> 
          <"\tgit cvsexportcommit -w \"$CVSWORK\" -c $id &&\n"> <"\tcheck_entries \"$CVSWORK/E\" \"DS/1.1/|newfile5.txt/1.1/\" &&\n"> 
          <"\tcheck_entries \"$CVSWORK\" \"DS/1.1/|release-notes/1.2/\" &&\n"> <"\ttest_cmp \"$CVSWORK/DS\" DS &&\n"> <"\ttest_cmp \"$CVSWORK/E/DS\" E/DS &&\n"> 
          <"\ttest_cmp \"$CVSWORK/release-notes\" release-notes\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"re-commit a removed filename which remains in CVS attic">)} 
      {
        (SQ <"\n"> <"\n"> <"    (cd \"$CVSWORK\" &&\n"> <"     echo >attic_gremlin &&\n"> 
          <"     cvs -Q add attic_gremlin &&\n"> <"     cvs -Q ci -m \"added attic_gremlin\" &&\n"> <"     rm attic_gremlin &&\n"> 
          <"     cvs -Q rm attic_gremlin &&\n"> <"     cvs -Q ci -m \"removed attic_gremlin\") &&\n"> <"\n"> <"    echo > attic_gremlin &&\n"> 
          <"    git add attic_gremlin &&\n"> <"    git commit -m \"Added attic_gremlin\" &&\n"> 
          <"\tgit cvsexportcommit -w \"$CVSWORK\" -c HEAD &&\n"> <"    (cd \"$CVSWORK\"; cvs -Q update -d) &&\n"> <"    test -f \"$CVSWORK/attic_gremlin\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"commit a file with leading spaces in the name">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo space > \" space\" &&\n"> <"\tgit add \" space\" &&\n"> 
          <"\tgit commit -m \"Add a file with a leading space\" &&\n"> <"\tid=$(git rev-parse HEAD) &&\n"> <"\tgit cvsexportcommit -w \"$CVSWORK\" -c $id &&\n"> 
          <
"\tcheck_entries \"$CVSWORK\" \" space/1.1/|DS/1.1/|attic_gremlin/1.3/|release-notes/1.2/\" &&\n"
          > <"\ttest_cmp \"$CVSWORK/ space\" \" space\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"use the same checkout for Git and CVS">)} 
      {
        (SQ <"\n"> <"\n"> <"\t(mkdir shared &&\n"> <"\t cd shared &&\n"> <"\t sane_unset GIT_DIR &&\n"> 
          <"\t cvs co . &&\n"> <"\t git init &&\n"> <"\t git add \" space\" &&\n"> <"\t git commit -m \"fake initial commit\" &&\n"> 
          <"\t echo Hello >> \" space\" &&\n"> <"\t git commit -m \"Another change\" \" space\" &&\n"> 
          <"\t git cvsexportcommit -W -p -u -c HEAD &&\n"> <"\t grep Hello \" space\" &&\n"> <"\t git diff-files)\n"> <"\n">
        )
      }
    )
    (C {(test_done)})
  ]
)