(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"commit-msg hook">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <"with no hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"foo\" > file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m \"first\"\n"> <"\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(fake-editor)} spids:[36])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {("#!/bin/sh\n") ("cp FAKE_MSG \"$1\"\n") ("exit 0\n")}
          do_expansion: False
          here_end: EOF
          was_filled: True
          spids: [40]
        )
      ]
    )
    (C {(chmod)} {(Lit_Other "+") (x)} {(fake-editor)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:FAKE_EDITOR)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: (CommandList children:[(C {(pwd)})])
                  left_token: <Left_CommandSub "$(">
                  spids: [61 63]
                ) (/fake-editor)
              )
            }
          spids: [59]
        )
      ]
      spids: [59]
    )
    (C {(export)} {(FAKE_EDITOR)})
    (C {(test_expect_success)} {(SQ <"with no hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more foo\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more foo\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with no hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"bar\" > file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit --no-verify -m \"bar\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with no hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more bar\" > file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more bar\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify\n"> <"\n">
        )
      }
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:HOOKDIR)
          op: Equal
          rhs: 
            {
              (DQ 
                (CommandSubPart
                  command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})])
                  left_token: <Left_CommandSub "$(">
                  spids: [127 133]
                ) (/hooks)
              )
            }
          spids: [125]
        )
      ]
      spids: [125]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:HOOK)
          op: Equal
          rhs: {(DQ ($ VSub_Name "$HOOKDIR") (/commit-msg))}
          spids: [137]
        )
      ]
      spids: [137]
    )
    (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name "$HOOKDIR"))})
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[153])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ("#!/bin/sh\n") ("exit 0\n"))}
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [159]
        )
      ]
    )
    (C {(chmod)} {(Lit_Other "+") (x)} {(DQ ($ VSub_Name "$HOOK"))})
    (C {(test_expect_success)} {(SQ <"with succeeding hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m \"more\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"with succeeding hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more more\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more more\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with succeeding hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"even more\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit --no-verify -m \"even more\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with succeeding hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"even more more\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"even more more\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify\n"> <"\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[245])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ("#!/bin/sh\n") ("exit 1\n"))}
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [251]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"with failing hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"another\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\ttest_must_fail git commit -m \"another\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"with failing hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more another\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more another\" > FAKE_MSG &&\n"> <"\t! (GIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit)\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with failing hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"stuff\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit --no-verify -m \"stuff\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--no-verify with failing hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more stuff\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more stuff\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify\n"> <"\n">
        )
      }
    )
    (C {(chmod)} {(-x)} {(DQ ($ VSub_Name "$HOOK"))})
    (C {(test_expect_success)} {(POSIXPERM)} {(SQ <"with non-executable hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"content\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m \"content\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(POSIXPERM)} {(SQ <"with non-executable hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"content again\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"content again\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit -m \"content again\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(POSIXPERM)} {(SQ <"--no-verify with non-executable hook">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more content\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit --no-verify -m \"more content\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(POSIXPERM)} {(SQ <"--no-verify with non-executable hook (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"even more content\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"even more content\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify\n"> <"\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[410])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {("#!/bin/sh\n") ("echo \"new message\" > \"$1\"\n") ("exit 0\n")}
          do_expansion: False
          here_end: EOF
          was_filled: True
          spids: [416]
        )
      ]
    )
    (C {(chmod)} {(Lit_Other "+") (x)} {(DQ ($ VSub_Name "$HOOK"))})
    (FuncDef
      name: commit_msg_is
      body: 
        (BraceGroup
          children: [
            (C {(test)} 
              {
                (DQ 
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [
                          (C {(git)} {(log)} 
                            {(--pretty) (Lit_Other "=") (format) (Lit_Other ":") (Lit_Other "%") (s) 
                              (Lit_Other "%") (b)
                            } {(-1)}
                          )
                        ]
                      )
                    left_token: <Left_CommandSub "$(">
                    spids: [442 457]
                  )
                )
              } {(Lit_Other "=")} {(DQ ($ VSub_Number "$1"))}
            )
          ]
          spids: [436]
        )
      spids: [431 435]
    )
    (C {(test_expect_success)} {(SQ <"hook edits commit message">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"additional\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m \"additional\" &&\n"> <"\tcommit_msg_is \"new message\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"hook edits commit message (editor)">)} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"additional content\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"additional content\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit &&\n"> <"\tcommit_msg_is \"new message\"\n"> 
          <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(DQ ("hook doesn't edit commit message"))} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"plus\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit --no-verify -m \"plus\" &&\n"> <"\tcommit_msg_is \"plus\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(DQ ("hook doesn't edit commit message (editor)"))} 
      {
        (SQ <"\n"> <"\n"> <"\techo \"more plus\" >> file &&\n"> <"\tgit add file &&\n"> 
          <"\techo \"more plus\" > FAKE_MSG &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify &&\n"> 
          <"\tcommit_msg_is \"more plus\"\n"> <"\n">
        )
      }
    )
    (C {(test_done)})
  ]
)