(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'Test the post-checkout hook.'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\techo Data for commit0. >a &&\n'> <'\techo Data for commit0. >b &&\n'> 
          <'\tgit update-index --add a &&\n'> <'\tgit update-index --add b &&\n'> <'\ttree0=$(git write-tree) &&\n'> 
          <'\tcommit0=$(echo setup | git commit-tree $tree0) &&\n'> <'\tgit update-ref refs/heads/master $commit0 &&\n'> <'\tgit clone ./. clone1 &&\n'> 
          <'\tgit clone ./. clone2 &&\n'> <'\tGIT_DIR=clone2/.git git branch new2 &&\n'> <'\techo Data for commit1. >clone2/b &&\n'> 
          <'\tGIT_DIR=clone2/.git git add clone2/b &&\n'> <'\tGIT_DIR=clone2/.git git commit -m new2\n'>
        )
      }
    )
    (command.ForEach
      iter_name: clone
      iter_words: [{<1>} {<2>}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {<clone> (${ Id.VSub_Name clone) <'/.git/hooks/post-checkout'>}
                )
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {(SQ <EOF>)}
                      here_end_span_id: 75
                      stdin_parts: [<'#!/bin/sh\n'> <'echo $@ > $GIT_DIR/post-checkout.args\n'>]
                    )
                )
              ]
              do_fork: T
            )
            (C {<chmod>} {<u> <Id.Lit_Other '+'> <x>} 
              {<clone> (${ Id.VSub_Name clone) <'/.git/hooks/post-checkout'>}
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'post-checkout runs as expected '>)} 
      {
        (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout master &&\n'> 
          <'\ttest -e clone1/.git/post-checkout.args\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'post-checkout receives the right arguments with HEAD unchanged '>)} 
      {
        (SQ <'\n'> <'\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'> 
          <'\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'> <'\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'> 
          <'\ttest $old = $new && test $flag = 1\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'post-checkout runs as expected '>)} 
      {
        (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout master &&\n'> 
          <'\ttest -e clone1/.git/post-checkout.args\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'post-checkout args are correct with git checkout -b '>)} 
      {
        (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout -b new1 &&\n'> 
          <'\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'> 
          <'\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'> <'\ttest $old = $new && test $flag = 1\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'post-checkout receives the right args with HEAD changed '>)} 
      {
        (SQ <'\n'> <'\tGIT_DIR=clone2/.git git checkout new2 &&\n'> 
          <'\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'> 
          <'\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'> <'\ttest $old != $new && test $flag = 1\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'post-checkout receives the right args when not switching branches '>)} 
      {
        (SQ <'\n'> <'\tGIT_DIR=clone2/.git git checkout master b &&\n'> 
          <'\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'> 
          <'\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'> <'\ttest $old = $new && test $flag = 0\n'>
        )
      }
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (C {<test>} 
                      {
                        (DQ 
                          (command_sub
                            left_token: <Id.Left_DollarParen '$('>
                            child: (C {<git>} {<config>} {<--bool>} {<core.filemode>})
                          )
                        )
                      } {<Id.Lit_Equals '='>} {<true>}
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<mkdir>} {<-p>} {<'templates/hooks'>})
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_Great '>'>
                  loc: (redir_loc.Fd fd:1)
                  arg: {<'templates/hooks/post-checkout'>}
                )
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {(SQ <EOF>)}
                      here_end_span_id: 222
                      stdin_parts: [<'#!/bin/sh\n'> <'echo $@ > $GIT_DIR/post-checkout.args\n'>]
                    )
                )
              ]
              do_fork: T
            )
            (C {<chmod>} {<Id.Lit_Other '+'> <x>} {<'templates/hooks/post-checkout'>})
            (C {<test_expect_success>} {(SQ <'post-checkout hook is triggered by clone'>)} 
              {
                (SQ <'\n'> <'\tgit clone --template=templates . clone3 &&\n'> 
                  <'\ttest -f clone3/.git/post-checkout.args\n'>
                )
              }
            )
          ]
          spids: [181 202]
        )
      ]
    )
    (C {<test_done>})
  ]
)