(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:prec) op:Equal rhs:{(4)})]
    )
    (command.ShFunction
      name: read_state
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:onto_name)
                      op: Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [
                                  (C {(cat)} {(DQ ($ VSub_DollarName '$state_dir')) (/onto_name)})
                                ]
                              )
                          )
                        }
                    )
                  ]
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:end)
                      op: Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [(C {(cat)} {(DQ ($ VSub_DollarName '$state_dir')) (/end)})]
                              )
                          )
                        }
                    )
                  ]
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:msgnum)
                      op: Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [
                                  (C {(cat)} {(DQ ($ VSub_DollarName '$state_dir')) (/msgnum)})
                                ]
                              )
                          )
                        }
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: continue_merge
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DPipe]
              children: [
                (C {(test)} {(-d)} {(DQ ($ VSub_DollarName '$state_dir'))})
                (C {(die)} {(DQ ($ VSub_DollarName '$state_dir') (' directory does not exist'))})
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:unmerged)
                  op: Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(git)} {(ls-files)} {(-u)})]
                          )
                      )
                    }
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$unmerged'))})]
                  action: [
                    (C {(echo)} {(DQ ('You still have unmerged paths in your index'))})
                    (C {(echo)} {(DQ ('did you forget to use git add?'))})
                    (C {(die)} {(DQ ($ VSub_DollarName '$resolvemsg'))})
                  ]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cmt)
                  op: Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(cat)} {(DQ ($ VSub_DollarName '$state_dir') (/current))})]
                          )
                      )
                    }
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Pipeline
                      children: [
                        (C {(git)} {(diff-index)} {(--quiet)} {(--ignore-submodules)} {(HEAD)} {(--)})
                      ]
                      negated: T
                    )
                  ]
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.Pipeline
                              children: [
                                (C {(git)} {(commit)} 
                                  {
                                    (braced_var_sub
                                      token: <VSub_Name gpg_sign_opt>
                                      suffix_op: 
                                        (suffix_op.Unary
                                          op_id: VTest_ColonPlus
                                          arg_word: {(DQ ($ VSub_DollarName '$gpg_sign_opt'))}
                                        )
                                    )
                                  } {(--no-verify)} {(-C)} {(DQ ($ VSub_DollarName '$cmt'))}
                                )
                              ]
                              negated: T
                            )
                          ]
                          action: [
                            (C {(echo)} 
                              {
                                (DQ ('Commit failed, please do not call ') 
                                  (word_part.EscapedLiteral
                                    token: <Lit_EscapedChar '\\"'>
                                  ) ('git commit') (word_part.EscapedLiteral token:<Lit_EscapedChar '\\"'>)
                                )
                              }
                            )
                            (C {(echo)} {(DQ ('directly, but instead do one of the following: '))})
                            (C {(die)} {(DQ ($ VSub_DollarName '$resolvemsg'))})
                          ]
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$GIT_QUIET'))})]
                          action: [
                            (C {(printf)} {(DQ ('Committed: %0') (${ VSub_Name prec) ('d '))} 
                              {($ VSub_DollarName '$msgnum')}
                            )
                          ]
                        )
                      ]
                    )
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ ($ VSub_DollarName '$cmt') (' ') 
                            (command_sub
                              left_token: <Left_DollarParen '$('>
                              command_list: 
                                (command.CommandList
                                  children: [(C {(git)} {(rev-parse)} {(HEAD) (Lit_Other '^') (0)})]
                                )
                            )
                          )
                        }
                      ]
                      redirects: [
                        (redir.Redir
                          op: <Redir_DGreat '>>'>
                          fd: 16777215
                          arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/rewritten))}
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (command.If
                  arms: [
                    (if_arm
                      cond: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$GIT_QUIET'))})]
                      action: [
                        (C {(printf)} {(DQ ('Already applied: %0') (${ VSub_Name prec) ('d '))} 
                          {($ VSub_DollarName '$msgnum')}
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$GIT_QUIET'))})
                (command.Simple
                  words: [
                    {(git)}
                    {(log)}
                    {(--format) (Lit_Equals '=') (Lit_Other '%') (s)}
                    {(-1)}
                    {(DQ ($ VSub_DollarName '$cmt'))}
                  ]
                  more_env: [(env_pair name:GIT_PAGER val:{(SQ )})]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:msgnum)
                  op: Equal
                  rhs: 
                    {
                      (word_part.ArithSub
                        anode: 
                          (arith_expr.Binary
                            op_id: Arith_Plus
                            left: (arith_expr.ArithWord w:{($ VSub_DollarName '$msgnum')})
                            right: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                          )
                      )
                    }
                )
              ]
            )
            (command.Simple
              words: [{(echo)} {(DQ ($ VSub_DollarName '$msgnum'))}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/msgnum))}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: call_merge
      body: 
        (command.BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:msgnum)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.Simple
              words: [{(echo)} {(DQ ($ VSub_DollarName '$msgnum'))}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/msgnum))}
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cmt)
                  op: Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: <Left_DollarParen '$('>
                          command_list: 
                            (command.CommandList
                              children: [
                                (C {(cat)} 
                                  {
                                    (DQ ($ VSub_DollarName '$state_dir') (/cmt.) 
                                      ($ VSub_DollarName '$msgnum')
                                    )
                                  }
                                )
                              ]
                            )
                        )
                      )
                    }
                )
              ]
            )
            (command.Simple
              words: [{(echo)} {(DQ ($ VSub_DollarName '$cmt'))}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/current))}
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:hd)
                  op: Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD)})]
                          )
                      )
                    }
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:cmt_name)
                  op: Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.AndOr
                                ops: [Op_DPipe]
                                children: [
                                  (command.Simple
                                    words: [{(git)} {(symbolic-ref)} {(HEAD)}]
                                    redirects: [
                                      (redir.Redir
                                        op: <Redir_Great '2>'>
                                        fd: 2
                                        arg_word: {(/dev/null)}
                                      )
                                    ]
                                  )
                                  (C {(echo)} {(HEAD)})
                                ]
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (C {(eval)} 
              {(GITHEAD_) ($ VSub_DollarName '$cmt') (Lit_Equals '=') 
                (SQ <'"${cmt_name##refs/heads/}~$(($end - $msgnum))"'>)
              }
            )
            (C {(eval)} {(GITHEAD_) ($ VSub_DollarName '$hd') (Lit_Equals '=') (SQ <'$onto_name'>)})
            (C {(export)} {(GITHEAD_) ($ VSub_DollarName '$cmt')} {(GITHEAD_) ($ VSub_DollarName '$hd')})
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GIT_QUIET'))})]
                  action: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:GIT_MERGE_VERBOSITY)
                              op: Equal
                              rhs: {(1)}
                            )
                          ]
                        )
                        (C {(export)} {(GIT_MERGE_VERBOSITY)})
                      ]
                    )
                  ]
                )
              ]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$strategy'))})
                (command.ShAssignment
                  pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:strategy) op:Equal rhs:{(recursive)})]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:base)
                  op: Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [
                              (C {(git)} {(rev-parse)} {(--verify)} {(--quiet)} 
                                {($ VSub_DollarName '$cmt') (Lit_Other '^')}
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (C {(eval)} {(SQ <'git-merge-$strategy'>)} {($ VSub_DollarName '$strategy_opts')} 
              {($ VSub_DollarName '$base')} {(SQ <' -- "$hd" "$cmt"'>)}
            )
            (command.ShAssignment
              pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:rv) op:Equal rhs:{($ VSub_QMark '$?')})]
            )
            (command.Case
              to_match: {(DQ ($ VSub_DollarName '$rv'))}
              arms: [
                (case_arm
                  pat_list: [{(0)}]
                  action: [
                    (C {(unset)} {(GITHEAD_) ($ VSub_DollarName '$cmt')} 
                      {(GITHEAD_) ($ VSub_DollarName '$hd')}
                    )
                    (command.ControlFlow token:<ControlFlow_Return return>)
                  ]
                )
                (case_arm
                  pat_list: [{(1)}]
                  action: [
                    (C {(git)} {(rerere)} {($ VSub_DollarName '$allow_rerere_autoupdate')})
                    (C {(die)} {(DQ ($ VSub_DollarName '$resolvemsg'))})
                  ]
                )
                (case_arm
                  pat_list: [{(2)}]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {(DQ ('Strategy: ') ($ VSub_DollarName '$strategy') (' failed, try another'))}
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})]
                    )
                    (C {(die)} {(DQ ($ VSub_DollarName '$resolvemsg'))})
                  ]
                )
                (case_arm
                  pat_list: [{(Lit_Star '*')}]
                  action: [
                    (C {(die)} 
                      {(DQ ('Unknown exit code (') ($ VSub_DollarName '$rv') (') from command:'))} 
                      {
                        (DQ (git-merge-) ($ VSub_DollarName '$strategy') (' ') 
                          ($ VSub_DollarName '$cmt') ('^ -- HEAD ') ($ VSub_DollarName '$cmt')
                        )
                      }
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: finish_rb_merge
      body: 
        (command.BraceGroup
          children: [
            (C {(move_to_original_branch)})
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-s)} {(DQ ($ VSub_DollarName '$state_dir')) (/rewritten)})]
                  action: [
                    (command.Simple
                      words: [{(git)} {(notes)} {(copy)} {(--for-rewrite) (Lit_Equals '=') (rebase)}]
                      redirects: [
                        (redir.Redir
                          op: <Redir_Less '<'>
                          fd: 16777215
                          arg_word: {(DQ ($ VSub_DollarName '$state_dir')) (/rewritten)}
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:hook)
                          op: Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: <Left_DollarParen '$('>
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {(git)} {(rev-parse)} {(--git-path)} {(hooks/post-rewrite)})
                                      ]
                                    )
                                )
                              )
                            }
                        )
                      ]
                    )
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(test)} {(-x)} {(DQ ($ VSub_DollarName '$hook'))})
                        (command.Simple
                          words: [{(DQ ($ VSub_DollarName '$hook'))} {(rebase)}]
                          redirects: [
                            (redir.Redir
                              op: <Redir_Less '<'>
                              fd: 16777215
                              arg_word: {(DQ ($ VSub_DollarName '$state_dir')) (/rewritten)}
                            )
                          ]
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (C {(say)} {(All)} {(done.)})
          ]
        )
    )
    (command.ShFunction
      name: git_rebase__merge
      body: 
        (command.BraceGroup
          children: [
            (command.Case
              to_match: {(DQ ($ VSub_DollarName '$action'))}
              arms: [
                (case_arm
                  pat_list: [{(ControlFlow_Continue continue)}]
                  action: [
                    (C {(read_state)})
                    (C {(continue_merge)})
                    (command.WhileUntil
                      keyword: <KW_While while>
                      cond: [
                        (C {(test)} {(DQ ($ VSub_DollarName '$msgnum'))} {(-le)} 
                          {(DQ ($ VSub_DollarName '$end'))}
                        )
                      ]
                      body: 
                        (command.DoGroup
                          children: [
                            (C {(call_merge)} {(DQ ($ VSub_DollarName '$msgnum'))})
                            (C {(continue_merge)})
                          ]
                        )
                    )
                    (C {(finish_rb_merge)})
                    (command.ControlFlow token:<ControlFlow_Return return>)
                  ]
                )
                (case_arm
                  pat_list: [{(skip)}]
                  action: [
                    (C {(read_state)})
                    (C {(git)} {(rerere)} {(clear)})
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:msgnum)
                          op: Equal
                          rhs: 
                            {
                              (word_part.ArithSub
                                anode: 
                                  (arith_expr.Binary
                                    op_id: Arith_Plus
                                    left: (arith_expr.ArithWord w:{($ VSub_DollarName '$msgnum')})
                                    right: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                                  )
                              )
                            }
                        )
                      ]
                    )
                    (command.WhileUntil
                      keyword: <KW_While while>
                      cond: [
                        (C {(test)} {(DQ ($ VSub_DollarName '$msgnum'))} {(-le)} 
                          {(DQ ($ VSub_DollarName '$end'))}
                        )
                      ]
                      body: 
                        (command.DoGroup
                          children: [
                            (C {(call_merge)} {(DQ ($ VSub_DollarName '$msgnum'))})
                            (C {(continue_merge)})
                          ]
                        )
                    )
                    (C {(finish_rb_merge)})
                    (command.ControlFlow token:<ControlFlow_Return return>)
                  ]
                )
              ]
            )
            (C {(mkdir)} {(-p)} {(DQ ($ VSub_DollarName '$state_dir'))})
            (command.Simple
              words: [{(echo)} {(DQ ($ VSub_DollarName '$onto_name'))}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/onto_name))}
                )
              ]
            )
            (C {(write_basic_state)})
            (command.ShAssignment
              pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:msgnum) op:Equal rhs:{(0)})]
            )
            (command.ForEach
              iter_name: cmt
              iter_words: [
                {
                  (command_sub
                    left_token: <Left_DollarParen '$('>
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(git)} {(rev-list)} {(--reverse)} {(--no-merges)} 
                            {(DQ ($ VSub_DollarName '$revisions'))}
                          )
                        ]
                      )
                  )
                }
              ]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:msgnum)
                          op: Equal
                          rhs: 
                            {
                              (word_part.ArithSub
                                anode: 
                                  (arith_expr.Binary
                                    op_id: Arith_Plus
                                    left: (arith_expr.ArithWord w:{($ VSub_DollarName '$msgnum')})
                                    right: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                                  )
                              )
                            }
                        )
                      ]
                    )
                    (command.Simple
                      words: [{(echo)} {(DQ ($ VSub_DollarName '$cmt'))}]
                      redirects: [
                        (redir.Redir
                          op: <Redir_Great '>'>
                          fd: 16777215
                          arg_word: 
                            {
                              (DQ ($ VSub_DollarName '$state_dir') (/cmt.) 
                                ($ VSub_DollarName '$msgnum')
                              )
                            }
                        )
                      ]
                    )
                  ]
                )
            )
            (command.Simple
              words: [{(echo)} {(1)}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/msgnum))}
                )
              ]
            )
            (command.Simple
              words: [{(echo)} {($ VSub_DollarName '$msgnum')}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_DollarName '$state_dir') (/end))}
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:end)
                  op: Equal
                  rhs: {($ VSub_DollarName '$msgnum')}
                )
              ]
            )
            (command.ShAssignment
              pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:msgnum) op:Equal rhs:{(1)})]
            )
            (command.WhileUntil
              keyword: <KW_While while>
              cond: [
                (C {(test)} {(DQ ($ VSub_DollarName '$msgnum'))} {(-le)} {(DQ ($ VSub_DollarName '$end'))})
              ]
              body: 
                (command.DoGroup
                  children: [
                    (C {(call_merge)} {(DQ ($ VSub_DollarName '$msgnum'))})
                    (C {(continue_merge)})
                  ]
                )
            )
            (C {(finish_rb_merge)})
          ]
        )
    )
    (C {(git_rebase__merge)})
  ]
)