(command.CommandList
  children: [
    (command.ShAssignment
      left: <Id.Lit_VarLike 'test_description='>
      pairs: [
        (AssignPair
          left: <Id.Lit_VarLike 'test_description='>
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'test_description='> name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'concurrent git svn dcommit'>)}
        )
      ]
      redirects: []
    )
    (command.Simple
      blame_tok: <.>
      more_env: []
      words: [{<.>} {<'./lib-git-svn.sh'>}]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'setup svn repository'>)}
        {
          (SQ <'\n'> <'\tsvn_cmd checkout "$svnrepo" work.svn &&\n'> <'\t(\n'> <'\t\tcd work.svn &&\n'> 
            <'\t\techo >file && echo > auto_updated_file\n'> <'\t\tsvn_cmd add file auto_updated_file &&\n'> <'\t\tsvn_cmd commit -m "initial commit"\n'> 
            <'\t) &&\n'> <'\tsvn_cmd checkout "$svnrepo" work-auto-commits.svn\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.ShAssignment
      left: <Id.Lit_VarLike 'N='>
      pairs: [
        (AssignPair
          left: <Id.Lit_VarLike 'N='>
          lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'N='> name:N)
          op: assign_op.Equal
          rhs: {<0>}
        )
      ]
      redirects: []
    )
    (command.ShFunction
      name_tok: <next_N>
      name: next_N
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.ShAssignment
              left: <Id.Lit_VarLike 'N='>
              pairs: [
                (AssignPair
                  left: <Id.Lit_VarLike 'N='>
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'N='> name:N)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (word_part.ArithSub
                        left: <Id.Left_DollarDParen '$(('>
                        anode: 
                          (arith_expr.Binary
                            op_id: Id.Arith_Plus
                            left: {($ Id.VSub_DollarName N)}
                            right: {<Id.Lit_Digits 1>}
                          )
                        right: <Id.Right_DollarDParen _>
                      )
                    }
                )
              ]
              redirects: []
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name_tok: <setup_hook>
      name: setup_hook
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.ShAssignment
              left: <Id.Lit_VarLike 'hook_type='>
              pairs: [
                (AssignPair
                  left: <Id.Lit_VarLike 'hook_type='>
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'hook_type='> name:hook_type)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number 1))}
                )
              ]
              redirects: []
            )
            (command.ShAssignment
              left: <Id.Lit_VarLike 'skip_revs='>
              pairs: [
                (AssignPair
                  left: <Id.Lit_VarLike 'skip_revs='>
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'skip_revs='> name:skip_revs)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number 2))}
                )
              ]
              redirects: []
            )
            (command.AndOr
              children: [
                (command.Simple
                  blame_tok: <Id.Lit_LBracket '['>
                  more_env: []
                  words: [
                    {<Id.Lit_LBracket '['>}
                    {(DQ ($ Id.VSub_DollarName hook_type))}
                    {<Id.Lit_Equals '='>}
                    {(DQ <pre-commit>)}
                    {<Id.Lit_RBracket ']'>}
                  ]
                  redirects: []
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <Id.Lit_LBracket '['>
                  more_env: []
                  words: [
                    {<Id.Lit_LBracket '['>}
                    {(DQ ($ Id.VSub_DollarName hook_type))}
                    {<Id.Lit_Equals '='>}
                    {(DQ <post-commit>)}
                    {<Id.Lit_RBracket ']'>}
                  ]
                  redirects: []
                  do_fork: T
                )
                (BraceGroup
                  left: <Id.Lit_LBrace '{'>
                  children: [
                    (command.Sentence
                      child: 
                        (command.Simple
                          blame_tok: <echo>
                          more_env: []
                          words: [
                            {<echo>}
                            {
                              (DQ <'ERROR: invalid argument ('> ($ Id.VSub_DollarName hook_type) <')'>)
                            }
                            {(DQ <'passed to setup_hook'>)}
                          ]
                          redirects: [
                            (Redir
                              op: <Id.Redir_GreatAnd '>&'>
                              loc: (redir_loc.Fd fd:1)
                              arg: {<2>}
                            )
                          ]
                          do_fork: T
                        )
                      terminator: <Id.Op_Semi _>
                    )
                    (command.Sentence
                      child: 
                        (command.ControlFlow
                          keyword: <Id.ControlFlow_Return return>
                          arg_word: {<1>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  redirects: []
                  right: <Id.Lit_RBrace '}'>
                )
              ]
              ops: [<Id.Op_DPipe _> <Id.Op_DPipe _>]
            )
            (command.Simple
              blame_tok: <echo>
              more_env: []
              words: [{<echo>} {(DQ <'cnt='> ($ Id.VSub_DollarName skip_revs))}]
              redirects: [
                (Redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {(DQ ($ Id.VSub_DollarName hook_type) <-counter>)}
                )
              ]
              do_fork: T
            )
            (command.Simple
              blame_tok: <rm>
              more_env: []
              words: [
                {<rm>}
                {<-f>}
                {(DQ ($ Id.VSub_DollarName rawsvnrepo) <'/hooks/'>) <Id.Lit_Star '*'> <-commit>}
              ]
              redirects: []
              do_fork: T
            )
            (command.ShAssignment
              left: <Id.Lit_VarLike 'hook='>
              pairs: [
                (AssignPair
                  left: <Id.Lit_VarLike 'hook='>
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'hook='> name:hook)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ ($ Id.VSub_DollarName rawsvnrepo) <'/hooks/'> 
                        ($ Id.VSub_DollarName hook_type)
                      )
                    }
                )
              ]
              redirects: []
            )
            (command.Simple
              blame_tok: <cat>
              more_env: []
              words: [{<cat>}]
              redirects: [
                (Redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {(DQ ($ Id.VSub_DollarName hook))}
                )
                (Redir
                  op: <Id.Redir_DLessDash '<<-'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {(SQ <EOF1>)}
                      here_end_tok: <Id.Undefined_Tok ''>
                      stdin_parts: [
                        <'#!/bin/sh\n'>
                        <'set -e\n'>
                        <'cd "$1/.."  # "$1" is repository location\n'>
                        <'exec >> svn-hook.log 2>&1\n'>
                        <'hook="$(basename "$0")"\n'>
                        <'echo "*** Executing $hook $@"\n'>
                        <'set -x\n'>
                        <'. ./$hook-counter\n'>
                        <'cnt="$(($cnt - 1))"\n'>
                        <'echo "cnt=$cnt" > ./$hook-counter\n'>
                        <'[ "$cnt" = "0" ] || exit 0\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
            (command.If
              if_kw: <Id.KW_If if>
              arms: [
                (IfArm
                  keyword: <Id.KW_If if>
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (command.Simple
                              blame_tok: <Id.Lit_LBracket '['>
                              more_env: []
                              words: [
                                {<Id.Lit_LBracket '['>}
                                {(DQ ($ Id.VSub_DollarName hook_type))}
                                {<Id.Lit_Equals '='>}
                                {(DQ <pre-commit>)}
                                {<Id.Lit_RBracket ']'>}
                              ]
                              redirects: []
                              do_fork: T
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  then_kw: <Id.KW_Then then>
                  action: [
                    (command.Simple
                      blame_tok: <echo>
                      more_env: []
                      words: [{<echo>} {(DQ <'echo \'commit disallowed\' >&2; exit 1'>)}]
                      redirects: [
                        (Redir
                          op: <Id.Redir_DGreat '>>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {(DQ ($ Id.VSub_DollarName hook))}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                  spids: [251 268]
                )
              ]
              else_kw: <Id.KW_Else else>
              else_action: [
                (command.Simple
                  blame_tok: <echo>
                  more_env: []
                  words: [
                    {<echo>}
                    {
                      (DQ <'PATH='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'> ch:'"') 
                        ($ Id.VSub_DollarName PATH) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'> ch:'"') <'; export PATH'>
                      )
                    }
                  ]
                  redirects: [
                    (Redir
                      op: <Id.Redir_DGreat '>>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ ($ Id.VSub_DollarName hook))}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <echo>
                  more_env: []
                  words: [
                    {<echo>}
                    {
                      (DQ <'svnconf='> 
                        (word_part.EscapedLiteral
                          token: <Id.Lit_EscapedChar '\\"'>
                          ch: '"'
                        ) ($ Id.VSub_DollarName svnconf) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'> ch:'"')
                      )
                    }
                  ]
                  redirects: [
                    (Redir
                      op: <Id.Redir_DGreat '>>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ ($ Id.VSub_DollarName hook))}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <cat>
                  more_env: []
                  words: [{<cat>}]
                  redirects: [
                    (Redir
                      op: <Id.Redir_DGreat '>>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ ($ Id.VSub_DollarName hook))}
                    )
                    (Redir
                      op: <Id.Redir_DLessDash '<<-'>
                      loc: (redir_loc.Fd fd:0)
                      arg: 
                        (redir_param.HereDoc
                          here_begin: {(SQ <EOF2>)}
                          here_end_tok: <Id.Undefined_Tok ''>
                          stdin_parts: [
                            <'cd work-auto-commits.svn\n'>
                            <'svn up --config-dir "$svnconf"\n'>
                            <'echo "$$" >> auto_updated_file\n'>
                            <'svn commit --config-dir "$svnconf" \\\n'>
                            <'-m "auto-committing concurrent change"\n'>
                            <'exit 0\n'>
                          ]
                        )
                    )
                  ]
                  do_fork: T
                )
              ]
              fi_kw: <Id.KW_Fi fi>
              redirects: []
            )
            (command.Simple
              blame_tok: <chmod>
              more_env: []
              words: [{<chmod>} {<755>} {(DQ ($ Id.VSub_DollarName hook))}]
              redirects: []
              do_fork: T
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.ShFunction
      name_tok: <check_contents>
      name: check_contents
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.ShAssignment
              left: <Id.Lit_VarLike 'gitdir='>
              pairs: [
                (AssignPair
                  left: <Id.Lit_VarLike 'gitdir='>
                  lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'gitdir='> name:gitdir)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number 1))}
                )
              ]
              redirects: []
            )
            (command.AndOr
              children: [
                (command.Subshell
                  left: <Id.Op_LParen _>
                  child: 
                    (command.AndOr
                      children: [
                        (command.Simple
                          blame_tok: <cd>
                          more_env: []
                          words: [{<cd>} {<'../work.svn'>}]
                          redirects: []
                          do_fork: T
                        )
                        (command.Simple
                          blame_tok: <svn_cmd>
                          more_env: []
                          words: [{<svn_cmd>} {<up>}]
                          redirects: []
                          do_fork: T
                        )
                      ]
                      ops: [<Id.Op_DAmp _>]
                    )
                  right: <Id.Right_Subshell _>
                  redirects: []
                )
                (command.Simple
                  blame_tok: <test_cmp>
                  more_env: []
                  words: [{<test_cmp>} {<file>} {<'../work.svn/file'>}]
                  redirects: []
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <test_cmp>
                  more_env: []
                  words: [{<test_cmp>} {<auto_updated_file>} {<'../work.svn/auto_updated_file'>}]
                  redirects: []
                  do_fork: T
                )
              ]
              ops: [<Id.Op_DAmp _> <Id.Op_DAmp _>]
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'check if post-commit hook creates a concurrent commit'>)}
        {
          (SQ <'\n'> <'\tsetup_hook post-commit 1 &&\n'> <'\t(\n'> <'\t\tcd work.svn &&\n'> 
            <'\t\tcp auto_updated_file au_file_saved &&\n'> <'\t\techo 1 >> file &&\n'> <'\t\tsvn_cmd commit -m "changing file" &&\n'> <'\t\tsvn_cmd up &&\n'> 
            <'\t\ttest_must_fail test_cmp auto_updated_file au_file_saved\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'check if pre-commit hook fails'>)}
        {
          (SQ <'\n'> <'\tsetup_hook pre-commit 2 &&\n'> <'\t(\n'> <'\t\tcd work.svn &&\n'> 
            <'\t\techo 2 >> file &&\n'> <'\t\tsvn_cmd commit -m "changing file once again" &&\n'> <'\t\techo 3 >> file &&\n'> 
            <'\t\ttest_must_fail svn_cmd commit -m "this commit should fail" &&\n'> <'\t\tsvn_cmd revert file\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'dcommit error handling'>)}
        {
          (SQ <'\n'> <'\tsetup_hook pre-commit 2 &&\n'> 
            <'\tnext_N && git svn clone "$svnrepo" work$N.git &&\n'> <'\t(\n'> <'\t\tcd work$N.git &&\n'> <'\t\techo 1 >> file && git commit -am "commit change $N.1" &&\n'> 
            <'\t\techo 2 >> file && git commit -am "commit change $N.2" &&\n'> <'\t\techo 3 >> file && git commit -am "commit change $N.3" &&\n'> 
            <'\t\t# should fail to dcommit 2nd and 3rd change\n'> <'\t\t# but still should leave the repository in reasonable state\n'> 
            <'\t\ttest_must_fail git svn dcommit &&\n'> <'\t\tgit update-index --refresh &&\n'> <'\t\tgit show HEAD~2   | grep -q git-svn-id &&\n'> 
            <'\t\t! git show HEAD~1 | grep -q git-svn-id &&\n'> <'\t\t! git show HEAD   | grep -q git-svn-id\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'dcommit concurrent change in non-changed file'>)}
        {
          (SQ <'\n'> <'\tsetup_hook post-commit 2 &&\n'> 
            <'\tnext_N && git svn clone "$svnrepo" work$N.git &&\n'> <'\t(\n'> <'\t\tcd work$N.git &&\n'> <'\t\techo 1 >> file && git commit -am "commit change $N.1" &&\n'> 
            <'\t\techo 2 >> file && git commit -am "commit change $N.2" &&\n'> <'\t\techo 3 >> file && git commit -am "commit change $N.3" &&\n'> 
            <'\t\t# should rebase and leave the repository in reasonable state\n'> <'\t\tgit svn dcommit &&\n'> <'\t\tgit update-index --refresh &&\n'> <'\t\tcheck_contents &&\n'> 
            <'\t\tgit show HEAD~3 | grep -q git-svn-id &&\n'> <'\t\tgit show HEAD~2 | grep -q git-svn-id &&\n'> 
            <'\t\tgit show HEAD~1 | grep -q auto-committing &&\n'> <'\t\tgit show HEAD   | grep -q git-svn-id\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.ShFunction
      name_tok: <delete_first_line>
      name: delete_first_line
      body: 
        (BraceGroup
          left: <Id.Lit_LBrace '{'>
          children: [
            (command.AndOr
              children: [
                (command.ShAssignment
                  left: <Id.Lit_VarLike 'file='>
                  pairs: [
                    (AssignPair
                      left: <Id.Lit_VarLike 'file='>
                      lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'file='> name:file)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number 1))}
                    )
                  ]
                  redirects: []
                )
                (command.Simple
                  blame_tok: <sed>
                  more_env: []
                  words: [{<sed>} {<1d>}]
                  redirects: [
                    (Redir
                      op: <Id.Redir_Less '<'>
                      loc: (redir_loc.Fd fd:0)
                      arg: {(DQ ($ Id.VSub_DollarName file))}
                    )
                    (Redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ (${ Id.VSub_Name file) <.tmp>)}
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <rm>
                  more_env: []
                  words: [{<rm>} {(DQ ($ Id.VSub_DollarName file))}]
                  redirects: []
                  do_fork: T
                )
                (command.Simple
                  blame_tok: <mv>
                  more_env: []
                  words: [{<mv>} {(DQ (${ Id.VSub_Name file) <.tmp>)} {(DQ ($ Id.VSub_DollarName file))}]
                  redirects: []
                  do_fork: T
                )
              ]
              ops: [<Id.Op_DAmp _> <Id.Op_DAmp _> <Id.Op_DAmp _>]
            )
          ]
          redirects: []
          right: <Id.Lit_RBrace '}'>
        )
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'dcommit concurrent non-conflicting change'>)}
        {
          (SQ <'\n'> <'\tsetup_hook post-commit 2 &&\n'> 
            <'\tnext_N && git svn clone "$svnrepo" work$N.git &&\n'> <'\t(\n'> <'\t\tcd work$N.git &&\n'> <'\t\tcat file >> auto_updated_file &&\n'> 
            <'\t\t\tgit commit -am "commit change $N.1" &&\n'> <'\t\tdelete_first_line auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.2" &&\n'> 
            <'\t\tdelete_first_line auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.3" &&\n'> 
            <'\t\t# should rebase and leave the repository in reasonable state\n'> <'\t\tgit svn dcommit &&\n'> <'\t\tgit update-index --refresh &&\n'> <'\t\tcheck_contents &&\n'> 
            <'\t\tgit show HEAD~3 | grep -q git-svn-id &&\n'> <'\t\tgit show HEAD~2 | grep -q git-svn-id &&\n'> 
            <'\t\tgit show HEAD~1 | grep -q auto-committing &&\n'> <'\t\tgit show HEAD   | grep -q git-svn-id\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'dcommit --no-rebase concurrent non-conflicting change'>)}
        {
          (SQ <'\n'> <'\tsetup_hook post-commit 2 &&\n'> 
            <'\tnext_N && git svn clone "$svnrepo" work$N.git &&\n'> <'\t(\n'> <'\t\tcd work$N.git &&\n'> <'\t\tcat file >> auto_updated_file &&\n'> 
            <'\t\t\tgit commit -am "commit change $N.1" &&\n'> <'\t\tdelete_first_line auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.2" &&\n'> 
            <'\t\tdelete_first_line auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.3" &&\n'> <'\t\t# should fail as rebase is needed\n'> 
            <'\t\ttest_must_fail git svn dcommit --no-rebase &&\n'> <'\t\t# but should leave HEAD unchanged\n'> <'\t\tgit update-index --refresh &&\n'> 
            <'\t\t! git show HEAD~2 | grep -q git-svn-id &&\n'> <'\t\t! git show HEAD~1 | grep -q git-svn-id &&\n'> <'\t\t! git show HEAD   | grep -q git-svn-id\n'> 
            <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_expect_success>
      more_env: []
      words: [
        {<test_expect_success>}
        {(SQ <'dcommit fails on concurrent conflicting change'>)}
        {
          (SQ <'\n'> <'\tsetup_hook post-commit 1 &&\n'> 
            <'\tnext_N && git svn clone "$svnrepo" work$N.git &&\n'> <'\t(\n'> <'\t\tcd work$N.git &&\n'> <'\t\techo a >> file &&\n'> 
            <'\t\t\tgit commit -am "commit change $N.1" &&\n'> <'\t\techo b >> auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.2" &&\n'> 
            <'\t\techo c >> auto_updated_file &&\n'> <'\t\t\tgit commit -am "commit change $N.3" &&\n'> 
            <'\t\ttest_must_fail git svn dcommit && # rebase should fail\n'> <'\t\ttest_must_fail git update-index --refresh\n'> <'\t)\n'>
          )
        }
      ]
      redirects: []
      do_fork: T
    )
    (command.Simple
      blame_tok: <test_done>
      more_env: []
      words: [{<test_done>}]
      redirects: []
      do_fork: T
    )
  ]
)