(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"Test the post-rewrite hook.">)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <setup>)} 
      {
        (SQ <"\n"> <"\ttest_commit A foo A &&\n"> <"\ttest_commit B foo B &&\n"> 
          <"\ttest_commit C foo C &&\n"> <"\ttest_commit D foo D &&\n"> <"\tgit checkout A^0 &&\n"> <"\ttest_commit E bar E &&\n"> 
          <"\ttest_commit F foo F &&\n"> <"\tgit checkout master\n">
        )
      }
    )
    (C {(mkdir)} {(.git/hooks)})
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(.git/hooks/post-rewrite)} spids:[49])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ("#!/bin/sh\n") ("echo ") (EscapedLiteralPart token:<Lit_EscapedChar "\\$">) ("@ > ") 
                (Right_DoubleQuote "\"") ($ VSub_Name "$TRASH_DIRECTORY") (Right_DoubleQuote "\"") ("/post-rewrite.args\n") ("cat > ") 
                (Right_DoubleQuote "\"") ($ VSub_Name "$TRASH_DIRECTORY") (Right_DoubleQuote "\"") ("/post-rewrite.data\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [52]
        )
      ]
    )
    (C {(chmod)} {(u) (Lit_Other "+") (x)} {(.git/hooks/post-rewrite)})
    (FuncDef
      name: clear_hook_input
      body: 
        (BraceGroup
          children: [(C {(rm)} {(-f)} {(post-rewrite.args)} {(post-rewrite.data)})]
          spids: [82]
        )
      spids: [77 81]
    )
    (FuncDef
      name: verify_hook_input
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(test_cmp)} {(expected.args)} 
                  {(DQ ($ VSub_Name "$TRASH_DIRECTORY")) (/post-rewrite.args)}
                )
                (C {(test_cmp)} {(expected.data)} 
                  {(DQ ($ VSub_Name "$TRASH_DIRECTORY")) (/post-rewrite.data)}
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [101]
        )
      spids: [96 100]
    )
    (C {(test_expect_success)} {(SQ <"git commit --amend">)} 
      {
        (SQ <"\n"> <"\tclear_hook_input &&\n"> <"\techo \"D new message\" > newmsg &&\n"> 
          <"\toldsha=$(git rev-parse HEAD^0) &&\n"> <"\tgit commit -Fnewmsg --amend &&\n"> <"\techo amend > expected.args &&\n"> 
          <"\techo $oldsha $(git rev-parse HEAD^0) > expected.data &&\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git commit --amend --no-post-rewrite">)} 
      {
        (SQ <"\n"> <"\tclear_hook_input &&\n"> <"\techo \"D new message again\" > newmsg &&\n"> 
          <"\tgit commit --no-post-rewrite -Fnewmsg --amend &&\n"> <"\ttest ! -f post-rewrite.args &&\n"> <"\ttest ! -f post-rewrite.data\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_must_fail git rebase --onto A B &&\n"> <"\techo C > foo &&\n"> <"\tgit add foo &&\n"> <"\tgit rebase --continue &&\n"> 
          <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse C) $(git rev-parse HEAD^)\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase --skip">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_must_fail git rebase --onto A B &&\n"> <"\ttest_must_fail git rebase --skip &&\n"> <"\techo D > foo &&\n"> <"\tgit add foo &&\n"> 
          <"\tgit rebase --continue &&\n"> <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase --skip the last one">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard F &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_must_fail git rebase --onto D A &&\n"> <"\tgit rebase --skip &&\n"> <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> 
          <"\t$(git rev-parse E) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -m">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_must_fail git rebase -m --onto A B &&\n"> <"\techo C > foo &&\n"> <"\tgit add foo &&\n"> <"\tgit rebase --continue &&\n"> 
          <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse C) $(git rev-parse HEAD^)\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -m --skip">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_must_fail git rebase --onto A B &&\n"> <"\ttest_must_fail git rebase --skip &&\n"> <"\techo D > foo &&\n"> <"\tgit add foo &&\n"> 
          <"\tgit rebase --continue &&\n"> <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-rebase.sh)})
    (C {(set_fake_editor)})
    (FuncDef
      name: test_fail_interactive_rebase
      body: 
        (BraceGroup
          children: [
            (Subshell
              child: 
                (AndOr
                  children: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:FAKE_LINES)
                          op: Equal
                          rhs: {(DQ ($ VSub_Number "$1"))}
                          spids: [302]
                        )
                      ]
                      spids: [302]
                    )
                    (AndOr
                      children: [
                        (C {(shift)})
                        (AndOr
                          children: [
                            (C {(export)} {(FAKE_LINES)})
                            (C {(test_must_fail)} {(git)} {(rebase)} {(-i)} {(DQ ($ VSub_At "$@"))})
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              spids: [299 335]
            )
          ]
          spids: [296]
        )
      spids: [291 295]
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (unchanged)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_fail_interactive_rebase \"1 2\" --onto A B &&\n"> <"\techo C > foo &&\n"> <"\tgit add foo &&\n"> <"\tgit rebase --continue &&\n"> 
          <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse C) $(git rev-parse HEAD^)\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (skip)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_fail_interactive_rebase \"2\" --onto A B &&\n"> <"\techo D > foo &&\n"> <"\tgit add foo &&\n"> <"\tgit rebase --continue &&\n"> 
          <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> 
          <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (squash)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\ttest_fail_interactive_rebase \"1 squash 2\" --onto A B &&\n"> <"\techo C > foo &&\n"> <"\tgit add foo &&\n"> <"\tgit rebase --continue &&\n"> 
          <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse C) $(git rev-parse HEAD)\n"> 
          <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (fixup without conflict)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\tFAKE_LINES=\"1 fixup 2\" git rebase -i B &&\n"> <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> 
          <"\t$(git rev-parse C) $(git rev-parse HEAD)\n"> <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (double edit)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\tFAKE_LINES=\"edit 1 edit 2\" git rebase -i B &&\n"> <"\tgit rebase --continue &&\n"> <"\techo something > foo &&\n"> <"\tgit add foo &&\n"> 
          <"\tgit rebase --continue &&\n"> <"\techo rebase >expected.args &&\n"> <"\tcat >expected.data <<-EOF &&\n"> 
          <"\t$(git rev-parse C) $(git rev-parse HEAD^)\n"> <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git rebase -i (exec)">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard D &&\n"> <"\tclear_hook_input &&\n"> 
          <"\tFAKE_LINES=\"edit 1 exec_false 2\" git rebase -i B &&\n"> <"\techo something >bar &&\n"> <"\tgit add bar &&\n"> <"\t# Fails because of exec false\n"> 
          <"\ttest_must_fail git rebase --continue &&\n"> <"\tgit rebase --continue &&\n"> <"\techo rebase >expected.args &&\n"> 
          <"\tcat >expected.data <<-EOF &&\n"> <"\t$(git rev-parse C) $(git rev-parse HEAD^)\n"> <"\t$(git rev-parse D) $(git rev-parse HEAD)\n"> 
          <"\tEOF\n"> <"\tverify_hook_input\n">
        )
      }
    )
    (C {(test_done)})
  ]
)