(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ (Token id:Id.Lit_Chars val:'Test the post-checkout hook.' span_id:15))}
          spids: [13]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:28) 
          (Token id:Id.Lit_Chars val:'\techo Data for commit0. >a &&\n' span_id:29) (Token id:Id.Lit_Chars val:'\techo Data for commit0. >b &&\n' span_id:30) 
          (Token id:Id.Lit_Chars val:'\tgit update-index --add a &&\n' span_id:31) (Token id:Id.Lit_Chars val:'\tgit update-index --add b &&\n' span_id:32) 
          (Token id:Id.Lit_Chars val:'\ttree0=$(git write-tree) &&\n' span_id:33) (Token id:Id.Lit_Chars val:'\tcommit0=$(echo setup | git commit-tree $tree0) &&\n' span_id:34) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/heads/master $commit0 &&\n'
            span_id: 35
          ) (Token id:Id.Lit_Chars val:'\tgit clone ./. clone1 &&\n' span_id:36) 
          (Token id:Id.Lit_Chars val:'\tgit clone ./. clone2 &&\n' span_id:37) (Token id:Id.Lit_Chars val:'\tGIT_DIR=clone2/.git git branch new2 &&\n' span_id:38) 
          (Token id:Id.Lit_Chars val:'\techo Data for commit1. >clone2/b &&\n' span_id:39) (Token id:Id.Lit_Chars val:'\tGIT_DIR=clone2/.git git add clone2/b &&\n' span_id:40) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone2/.git git commit -m new2\n'
            span_id: 41
          )
        )
      }
    )
    (command.ForEach
      iter_name: clone
      iter_words: [{(1)} {(2)}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_Great val:'>' span_id:61)
                  fd: -1
                  arg_word: {(clone) (${ Id.VSub_Name clone) (/.git/hooks/post-checkout)}
                )
                (redir.HereDoc
                  op: (Token id:Id.Redir_DLess val:'<<' span_id:68)
                  fd: -1
                  here_begin: {(SQ (Token id:Id.Lit_Chars val:EOF span_id:70))}
                  here_end_span_id: 75
                  stdin_parts: [('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')]
                )
              ]
            )
            (C {(chmod)} {(u) (Id.Lit_Other '+') (x)} 
              {(clone) (${ Id.VSub_Name clone) (/.git/hooks/post-checkout)}
            )
          ]
        )
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'post-checkout runs as expected ' span_id:95))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:99) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone1/.git git checkout master &&\n'
            span_id: 100
          ) (Token id:Id.Lit_Chars val:'\ttest -e clone1/.git/post-checkout.args\n' span_id:101)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'post-checkout receives the right arguments with HEAD unchanged '
            span_id: 108
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:112) 
          (Token
            id: Id.Lit_Chars
            val: '\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'
            span_id: 113
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'
            span_id: 114
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'
            span_id: 115
          ) (Token id:Id.Lit_Chars val:'\ttest $old = $new && test $flag = 1\n' span_id:116)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'post-checkout runs as expected ' span_id:123))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:127) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone1/.git git checkout master &&\n'
            span_id: 128
          ) (Token id:Id.Lit_Chars val:'\ttest -e clone1/.git/post-checkout.args\n' span_id:129)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'post-checkout args are correct with git checkout -b '
            span_id: 136
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:140) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone1/.git git checkout -b new1 &&\n'
            span_id: 141
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'
            span_id: 142
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'
            span_id: 143
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'
            span_id: 144
          ) (Token id:Id.Lit_Chars val:'\ttest $old = $new && test $flag = 1\n' span_id:145)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'post-checkout receives the right args with HEAD changed '
            span_id: 152
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:156) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone2/.git git checkout new2 &&\n'
            span_id: 157
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'
            span_id: 158
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'
            span_id: 159
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'
            span_id: 160
          ) (Token id:Id.Lit_Chars val:'\ttest $old != $new && test $flag = 1\n' span_id:161)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'post-checkout receives the right args when not switching branches '
            span_id: 168
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:172) 
          (Token
            id: Id.Lit_Chars
            val: '\tGIT_DIR=clone2/.git git checkout master b &&\n'
            span_id: 173
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'
            span_id: 174
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'
            span_id: 175
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'
            span_id: 176
          ) (Token id:Id.Lit_Chars val:'\ttest $old = $new && test $flag = 0\n' span_id:177)
        )
      }
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: 
                (C {(test)} 
                  {
                    (DQ 
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:186)
                        command_list: 
                          (command.CommandList
                            children: [(C {(git)} {(config)} {(--bool)} {(core.filemode)})]
                          )
                      )
                    )
                  } {(Id.Lit_Equals '=')} {(true)}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:200)
            )
          ]
          action: [
            (C {(mkdir)} {(-p)} {(templates/hooks)})
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_Great val:'>' span_id:212)
                  fd: -1
                  arg_word: {(templates/hooks/post-checkout)}
                )
                (redir.HereDoc
                  op: (Token id:Id.Redir_DLess val:'<<' span_id:215)
                  fd: -1
                  here_begin: {(SQ (Token id:Id.Lit_Chars val:EOF span_id:217))}
                  here_end_span_id: 222
                  stdin_parts: [('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')]
                )
              ]
            )
            (C {(chmod)} {(Id.Lit_Other '+') (x)} {(templates/hooks/post-checkout)})
            (C {(test_expect_success)} 
              {
                (SQ 
                  (Token
                    id: Id.Lit_Chars
                    val: 'post-checkout hook is triggered by clone'
                    span_id: 234
                  )
                )
              } 
              {
                (SQ (Token id:Id.Lit_Chars val:'\n' span_id:238) 
                  (Token
                    id: Id.Lit_Chars
                    val: '\tgit clone --template=templates . clone3 &&\n'
                    span_id: 239
                  ) (Token id:Id.Lit_Chars val:'\ttest -f clone3/.git/post-checkout.args\n' span_id:240)
                )
              }
            )
          ]
          spids: [181 202]
        )
      ]
    )
    (C {(test_done)})
  ]
)