(command.CommandList
  children: [
    (C {(Lit_Other ':')} 
      {
        (word_part.BracedVarSub
          token: <VSub_Name MERGE_TOOLS_DIR>
          suffix_op: 
            (suffix_op.Unary
              op_id: VTest_Equals
              arg_word: 
                {
                  (word_part.CommandSub
                    left_token: <Left_DollarParen '$('>
                    command_list: (command.CommandList children:[(C {(git)} {(--exec-path)})])
                  ) (Lit_Slash /) (mergetools)
                }
            )
        )
      }
    )
    (command.Assignment
      pairs: [(assign_pair lhs:(lhs_expr.LhsName name:IFS) op:Equal rhs:{(SQ <'\n'>)})]
    )
    (command.FuncDef
      name: mode_ok
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm cond:[(C {(diff_mode)})] action:[(C {(can_diff)})])
                (if_arm cond:[(C {(merge_mode)})] action:[(C {(can_merge)})])
              ]
              else_action: [(C {(false)})]
            )
          ]
        )
    )
    (command.FuncDef
      name: is_available
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.Assignment
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:merge_tool_path)
                      op: Equal
                      rhs: 
                        {
                          (word_part.CommandSub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [(C {(translate_merge_tool_path)} {(DQ ($ VSub_Number '$1'))})]
                              )
                          )
                        }
                    )
                  ]
                )
                (command.Simple
                  words: [{(type)} {(DQ ($ VSub_DollarName '$merge_tool_path'))}]
                  redirects: [
                    (redir.Redir
                      op: <Redir_Great '>'>
                      fd: 16777215
                      arg_word: {(/dev/null)}
                    )
                    (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: list_config_tools
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:section)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:line_prefix)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 2>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{})
                      )
                    }
                )
              ]
            )
            (command.Pipeline
              children: [
                (C {(git)} {(config)} {(--get-regexp)} 
                  {($ VSub_DollarName '$section') (SQ <'\\..*\\.cmd'>)}
                )
                (command.WhileUntil
                  keyword: <KW_While while>
                  cond: [(C {(read)} {(-r)} {(key)} {(value)})]
                  body: 
                    (command.DoGroup
                      children: [
                        (command.Assignment
                          pairs: [
                            (assign_pair
                              lhs: (lhs_expr.LhsName name:toolname)
                              op: Equal
                              rhs: 
                                {
                                  (word_part.BracedVarSub
                                    token: <VSub_Name key>
                                    suffix_op: 
                                      (suffix_op.Unary
                                        op_id: VOp1_Pound
                                        arg_word: {($ VSub_DollarName '$section') (.)}
                                      )
                                  )
                                }
                            )
                          ]
                        )
                        (command.Assignment
                          pairs: [
                            (assign_pair
                              lhs: (lhs_expr.LhsName name:toolname)
                              op: Equal
                              rhs: 
                                {
                                  (word_part.BracedVarSub
                                    token: <VSub_Name toolname>
                                    suffix_op: (suffix_op.Unary op_id:VOp1_Percent arg_word:{(.cmd)})
                                  )
                                }
                            )
                          ]
                        )
                        (C {(printf)} {(DQ ('%s%s') (Lit_Other '\\') (n))} 
                          {(DQ ($ VSub_DollarName '$line_prefix'))} {(DQ ($ VSub_DollarName '$toolname'))}
                        )
                      ]
                    )
                )
              ]
              negated: F
            )
          ]
        )
    )
    (command.FuncDef
      name: show_tool_names
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:condition)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 1>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{(true)})
                      )
                    }
                )
                (assign_pair
                  lhs: (lhs_expr.LhsName name:per_line_prefix)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 2>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{})
                      )
                    }
                )
                (assign_pair
                  lhs: (lhs_expr.LhsName name:preamble)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 3>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{})
                      )
                    }
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:not_found_msg)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 4>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{})
                      )
                    }
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:extra_content)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Number 5>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{})
                      )
                    }
                )
              ]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:shown_any) op:Equal rhs:(word.Empty))]
            )
            (command.Pipeline
              children: [
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [(C {(cd)} {(DQ ($ VSub_DollarName '$MERGE_TOOLS_DIR'))}) (C {(ls)})]
                        )
                      ]
                    )
                )
                (command.BraceGroup
                  children: [
                    (command.WhileUntil
                      keyword: <KW_While while>
                      cond: [(C {(read)} {(toolname)})]
                      body: 
                        (command.DoGroup
                          children: [
                            (command.If
                              arms: [
                                (if_arm
                                  cond: [
                                    (command.AndOr
                                      ops: [Op_DAmp]
                                      children: [
                                        (command.Simple
                                          words: [{(setup_tool)} {(DQ ($ VSub_DollarName '$toolname'))}]
                                          redirects: [
                                            (redir.Redir
                                              op: <Redir_Great '2>'>
                                              fd: 2
                                              arg_word: {(/dev/null)}
                                            )
                                          ]
                                        )
                                        (command.Subshell
                                          command_list: 
                                            (command.CommandList
                                              children: [
                                                (C {(eval)} {(DQ ($ VSub_DollarName '$condition'))} 
                                                  {(DQ ($ VSub_DollarName '$toolname'))}
                                                )
                                              ]
                                            )
                                        )
                                      ]
                                    )
                                  ]
                                  action: [
                                    (command.If
                                      arms: [
                                        (if_arm
                                          cond: [
                                            (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$preamble'))})
                                          ]
                                          action: [
                                            (C {(printf)} {(DQ ('%s') (Lit_Other '\\') (n))} 
                                              {(DQ ($ VSub_DollarName '$preamble'))}
                                            )
                                            (command.Assignment
                                              pairs: [
                                                (assign_pair
                                                  lhs: (lhs_expr.LhsName name:preamble)
                                                  op: Equal
                                                  rhs: (word.Empty)
                                                )
                                              ]
                                            )
                                          ]
                                        )
                                      ]
                                    )
                                    (command.Assignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (lhs_expr.LhsName name:shown_any)
                                          op: Equal
                                          rhs: {(yes)}
                                        )
                                      ]
                                    )
                                    (C {(printf)} {(DQ ('%s%s') (Lit_Other '\\') (n))} 
                                      {(DQ ($ VSub_DollarName '$per_line_prefix'))} {(DQ ($ VSub_DollarName '$toolname'))}
                                    )
                                  ]
                                )
                              ]
                            )
                          ]
                        )
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$extra_content'))})]
                          action: [
                            (command.If
                              arms: [
                                (if_arm
                                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$preamble'))})]
                                  action: [
                                    (C {(printf)} {(DQ ('%s'))} {(DQ ($ VSub_DollarName '$preamble'))})
                                    (command.Assignment
                                      pairs: [
                                        (assign_pair
                                          lhs: (lhs_expr.LhsName name:preamble)
                                          op: Equal
                                          rhs: (word.Empty)
                                        )
                                      ]
                                    )
                                  ]
                                )
                              ]
                            )
                            (command.Assignment
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:shown_any)
                                  op: Equal
                                  rhs: {(yes)}
                                )
                              ]
                            )
                            (C {(printf)} {(DQ (Lit_Other '\\') ('n%s') (Lit_Other '\\') (n))} 
                              {(DQ ($ VSub_DollarName '$extra_content'))}
                            )
                          ]
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.AndOr
                              ops: [Op_DAmp]
                              children: [
                                (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$preamble'))})
                                (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$not_found_msg'))})
                              ]
                            )
                          ]
                          action: [
                            (C {(printf)} {(DQ ('%s') (Lit_Other '\\') (n))} 
                              {(DQ ($ VSub_DollarName '$not_found_msg'))}
                            )
                          ]
                        )
                      ]
                    )
                    (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$shown_any'))})
                  ]
                )
              ]
              negated: F
            )
          ]
        )
    )
    (command.FuncDef
      name: diff_mode
      body: 
        (command.BraceGroup
          children: [(C {(test)} {(DQ ($ VSub_DollarName '$TOOL_MODE'))} {(Lit_Other '=')} {(diff)})]
        )
    )
    (command.FuncDef
      name: merge_mode
      body: 
        (command.BraceGroup
          children: [(C {(test)} {(DQ ($ VSub_DollarName '$TOOL_MODE'))} {(Lit_Other '=')} {(merge)})]
        )
    )
    (command.FuncDef
      name: translate_merge_tool_path
      body: (command.BraceGroup children:[(C {(echo)} {(DQ ($ VSub_Number '$1'))})])
    )
    (command.FuncDef
      name: check_unchanged
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (C {(test)} {(DQ ($ VSub_DollarName '$MERGED'))} {(-nt)} 
                      {(DQ ($ VSub_DollarName '$BACKUP'))}
                    )
                  ]
                  action: [(command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                )
              ]
              else_action: [
                (command.WhileUntil
                  keyword: <KW_While while>
                  cond: [(C {(true)})]
                  body: 
                    (command.DoGroup
                      children: [
                        (C {(echo)} {(DQ ($ VSub_DollarName '$MERGED') (' seems unchanged.'))})
                        (C {(printf)} {(DQ ('Was the merge successful [y/n]? '))})
                        (command.AndOr
                          ops: [Op_DPipe]
                          children: [
                            (C {(read)} {(answer)})
                            (command.ControlFlow
                              token: <ControlFlow_Return return>
                              arg_word: {(1)}
                            )
                          ]
                        )
                        (command.Case
                          to_match: {(DQ ($ VSub_DollarName '$answer'))}
                          arms: [
                            (case_arm
                              pat_list: [{(y) (Lit_Star '*')} {(Y) (Lit_Star '*')}]
                              action: [
                                (command.ControlFlow
                                  token: <ControlFlow_Return return>
                                  arg_word: {(0)}
                                )
                              ]
                            )
                            (case_arm
                              pat_list: [{(n) (Lit_Star '*')} {(N) (Lit_Star '*')}]
                              action: [
                                (command.ControlFlow
                                  token: <ControlFlow_Return return>
                                  arg_word: {(1)}
                                )
                              ]
                            )
                          ]
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: valid_tool
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(setup_tool)} {(DQ ($ VSub_Number '$1'))})
                (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:cmd)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(get_merge_tool_cmd)} {(DQ ($ VSub_Number '$1'))})]
                          )
                      )
                    }
                )
              ]
            )
            (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$cmd'))})
          ]
        )
    )
    (command.FuncDef
      name: setup_user_tool
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:merge_tool_cmd)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(get_merge_tool_cmd)} {(DQ ($ VSub_DollarName '$tool'))})]
                          )
                      )
                    }
                )
              ]
            )
            (command.AndOr
              ops: [Op_DPipe]
              children: [
                (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$merge_tool_cmd'))})
                (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
              ]
            )
            (command.FuncDef
              name: diff_cmd
              body: 
                (command.BraceGroup
                  children: [
                    (command.Subshell
                      command_list: 
                        (command.CommandList
                          children: [(C {(eval)} {($ VSub_DollarName '$merge_tool_cmd')})]
                        )
                    )
                  ]
                )
            )
            (command.FuncDef
              name: merge_cmd
              body: 
                (command.BraceGroup
                  children: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:trust_exit_code)
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSub
                                left_token: <Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.AndOr
                                        ops: [Op_DPipe]
                                        children: [
                                          (C {(git)} {(config)} {(--bool)} 
                                            {(DQ (mergetool.) ($ VSub_Number '$1') (.trustExitCode))}
                                          )
                                          (C {(echo)} {(false)})
                                        ]
                                      )
                                    ]
                                  )
                              )
                            }
                        )
                      ]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (C {(test)} {(DQ ($ VSub_DollarName '$trust_exit_code'))} {(Lit_Other '=')} 
                              {(DQ (false))}
                            )
                          ]
                          action: [
                            (C {(touch)} {(DQ ($ VSub_DollarName '$BACKUP'))})
                            (command.Subshell
                              command_list: 
                                (command.CommandList
                                  children: [(C {(eval)} {($ VSub_DollarName '$merge_tool_cmd')})]
                                )
                            )
                            (C {(check_unchanged)})
                          ]
                        )
                      ]
                      else_action: [
                        (command.Subshell
                          command_list: 
                            (command.CommandList
                              children: [(C {(eval)} {($ VSub_DollarName '$merge_tool_cmd')})]
                            )
                        )
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.FuncDef
      name: setup_tool
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:tool)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.FuncDef
              name: can_merge
              body: 
                (command.BraceGroup
                  children: [(command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                )
            )
            (command.FuncDef
              name: can_diff
              body: 
                (command.BraceGroup
                  children: [(command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})]
                )
            )
            (command.FuncDef
              name: diff_cmd
              body: 
                (command.BraceGroup
                  children: [(command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})]
                )
            )
            (command.FuncDef
              name: merge_cmd
              body: 
                (command.BraceGroup
                  children: [(command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})]
                )
            )
            (command.FuncDef
              name: translate_merge_tool_path
              body: (command.BraceGroup children:[(C {(echo)} {(DQ ($ VSub_Number '$1'))})])
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Pipeline
                      children: [
                        (C {(test)} {(-f)} 
                          {
                            (DQ ($ VSub_DollarName '$MERGE_TOOLS_DIR') (/) ($ VSub_DollarName '$tool'))
                          }
                        )
                      ]
                      negated: T
                    )
                  ]
                  action: [
                    (C {(setup_user_tool)})
                    (command.ControlFlow
                      token: <ControlFlow_Return return>
                      arg_word: {($ VSub_QMark '$?')}
                    )
                  ]
                )
              ]
            )
            (C {(.)} {(DQ ($ VSub_DollarName '$MERGE_TOOLS_DIR') (/) ($ VSub_DollarName '$tool'))})
            (C {(setup_user_tool)})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(merge_mode)})
                        (command.Pipeline
                          children: [(C {(can_merge)})]
                          negated: T
                        )
                      ]
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ ("error: '") ($ VSub_DollarName '$tool') 
                            ("' can not be used to resolve merges")
                          )
                        }
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Return return>
                      arg_word: {(1)}
                    )
                  ]
                )
                (if_arm
                  cond: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(diff_mode)})
                        (command.Pipeline
                          children: [(C {(can_diff)})]
                          negated: T
                        )
                      ]
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ ("error: '") ($ VSub_DollarName '$tool') 
                            ("' can only be used to resolve merges")
                          )
                        }
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Return return>
                      arg_word: {(1)}
                    )
                  ]
                )
              ]
            )
            (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})
          ]
        )
    )
    (command.FuncDef
      name: get_merge_tool_cmd
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:merge_tool)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(diff_mode)})]
                  action: [
                    (command.AndOr
                      ops: [Op_DPipe]
                      children: [
                        (C {(git)} {(config)} {(DQ (difftool.) ($ VSub_DollarName '$merge_tool') (.cmd))})
                        (C {(git)} {(config)} 
                          {(DQ (mergetool.) ($ VSub_DollarName '$merge_tool') (.cmd))}
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (C {(git)} {(config)} {(DQ (mergetool.) ($ VSub_DollarName '$merge_tool') (.cmd))})
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: run_merge_tool
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:GIT_PREFIX)
                  op: Equal
                  rhs: 
                    {
                      (word_part.BracedVarSub
                        token: <VSub_Name GIT_PREFIX>
                        suffix_op: (suffix_op.Unary op_id:VTest_ColonHyphen arg_word:{(.)})
                      )
                    }
                )
              ]
            )
            (C {(export)} {(GIT_PREFIX)})
            (command.AndOr
              ops: [Op_DPipe]
              children: [
                (command.Assignment
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:merge_tool_path)
                      op: Equal
                      rhs: 
                        {
                          (word_part.CommandSub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [(C {(get_merge_tool_path)} {(DQ ($ VSub_Number '$1'))})]
                              )
                          )
                        }
                    )
                  ]
                )
                (command.ControlFlow token:<ControlFlow_Exit exit>)
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:base_present)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$2'))}
                )
              ]
            )
            (command.AndOr
              ops: [Op_DPipe]
              children: [
                (C {(setup_tool)} {(DQ ($ VSub_Number '$1'))})
                (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(merge_mode)})]
                  action: [(C {(run_merge_cmd)} {(DQ ($ VSub_Number '$1'))})]
                )
              ]
              else_action: [(C {(run_diff_cmd)} {(DQ ($ VSub_Number '$1'))})]
            )
          ]
        )
    )
    (command.FuncDef
      name: run_diff_cmd
      body: (command.BraceGroup children:[(C {(diff_cmd)} {(DQ ($ VSub_Number '$1'))})])
    )
    (command.FuncDef
      name: run_merge_cmd
      body: (command.BraceGroup children:[(C {(merge_cmd)} {(DQ ($ VSub_Number '$1'))})])
    )
    (command.FuncDef
      name: list_merge_tool_candidates
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(merge_mode)})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:tools)
                          op: Equal
                          rhs: {(DQ (tortoisemerge))}
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (command.Assignment
                  pairs: [(assign_pair lhs:(lhs_expr.LhsName name:tools) op:Equal rhs:{(DQ (kompare))})]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$DISPLAY'))})]
                  action: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$GNOME_DESKTOP_SESSION_ID'))})
                          ]
                          action: [
                            (command.Assignment
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:tools)
                                  op: Equal
                                  rhs: 
                                    {
                                      (DQ ('meld opendiff kdiff3 tkdiff xxdiff ') 
                                        ($ VSub_DollarName '$tools')
                                      )
                                    }
                                )
                              ]
                            )
                          ]
                        )
                      ]
                      else_action: [
                        (command.Assignment
                          pairs: [
                            (assign_pair
                              lhs: (lhs_expr.LhsName name:tools)
                              op: Equal
                              rhs: 
                                {
                                  (DQ ('opendiff kdiff3 tkdiff xxdiff meld ') 
                                    ($ VSub_DollarName '$tools')
                                  )
                                }
                            )
                          ]
                        )
                      ]
                    )
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:tools)
                          op: Equal
                          rhs: 
                            {
                              (DQ ($ VSub_DollarName '$tools') (' gvimdiff diffuse diffmerge ecmerge'))
                            }
                        )
                      ]
                    )
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:tools)
                          op: Equal
                          rhs: {(DQ ($ VSub_DollarName '$tools') (' p4merge araxis bc codecompare'))}
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (command.Case
              to_match: 
                {
                  (DQ 
                    (word_part.BracedVarSub
                      token: <VSub_Name VISUAL>
                      suffix_op: 
                        (suffix_op.Unary
                          op_id: VTest_ColonHyphen
                          arg_word: {($ VSub_DollarName '$EDITOR')}
                        )
                    )
                  )
                }
              arms: [
                (case_arm
                  pat_list: [{(Lit_Star '*') (vim) (Lit_Star '*')}]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:tools)
                          op: Equal
                          rhs: {(DQ ($ VSub_DollarName '$tools') (' vimdiff emerge'))}
                        )
                      ]
                    )
                  ]
                )
                (case_arm
                  pat_list: [{(Lit_Star '*')}]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:tools)
                          op: Equal
                          rhs: {(DQ ($ VSub_DollarName '$tools') (' emerge vimdiff'))}
                        )
                      ]
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: show_tool_help
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:tool_opt)
                  op: Equal
                  rhs: {(DQ ("'git ") (${ VSub_Name TOOL_MODE) ("tool --tool=<tool>'"))}
                )
              ]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:tab) op:Equal rhs:{(SQ <'\t'>)})]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:LF) op:Equal rhs:{(SQ <'\n'>)})]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:any_shown) op:Equal rhs:{(no)})]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:cmd_name)
                  op: Equal
                  rhs: {(${ VSub_Name TOOL_MODE) (tool)}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:config_tools)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [
                              (command.Pipeline
                                children: [
                                  (command.BraceGroup
                                    children: [
                                      (command.AndOr
                                        ops: [Op_DAmp]
                                        children: [
                                          (C {(diff_mode)})
                                          (C {(list_config_tools)} {(difftool)} 
                                            {
                                              (DQ ($ VSub_DollarName '$tab') 
                                                ($ VSub_DollarName '$tab')
                                              )
                                            }
                                          )
                                        ]
                                      )
                                      (C {(list_config_tools)} {(mergetool)} 
                                        {(DQ ($ VSub_DollarName '$tab') ($ VSub_DollarName '$tab'))}
                                      )
                                    ]
                                  )
                                  (C {(sort)})
                                ]
                                negated: F
                              )
                            ]
                          )
                      )
                    }
                )
              ]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:extra_content) op:Equal rhs:(word.Empty))]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$config_tools'))})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:extra_content)
                          op: Equal
                          rhs: 
                            {
                              (DQ (${ VSub_Name tab) ('user-defined:') (${ VSub_Name LF) 
                                ($ VSub_DollarName '$config_tools')
                              )
                            }
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(show_tool_names)} {(SQ <'mode_ok && is_available'>)} 
                  {(DQ ($ VSub_DollarName '$tab') ($ VSub_DollarName '$tab'))} {(DQ ($ VSub_DollarName '$tool_opt') (' may be set to one of the following:'))} 
                  {
                    (DQ ("No suitable tool for 'git ") ($ VSub_DollarName '$cmd_name') 
                      (" --tool=<tool>' found.")
                    )
                  } {(DQ ($ VSub_DollarName '$extra_content'))}
                )
                (command.Assignment
                  pairs: [(assign_pair lhs:(lhs_expr.LhsName name:any_shown) op:Equal rhs:{(yes)})]
                )
              ]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(show_tool_names)} {(SQ <'mode_ok && ! is_available'>)} 
                  {(DQ ($ VSub_DollarName '$tab') ($ VSub_DollarName '$tab'))} {(DQ (${ VSub_Name LF) ('The following tools are valid, but not currently available:'))}
                )
                (command.Assignment
                  pairs: [(assign_pair lhs:(lhs_expr.LhsName name:any_shown) op:Equal rhs:{(yes)})]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(DQ ($ VSub_DollarName '$any_shown'))} {(Lit_Other '=')} {(yes)})]
                  action: [
                    (C {(echo)})
                    (C {(echo)} {(DQ ('Some of the tools listed above only work in a windowed'))})
                    (C {(echo)} 
                      {(DQ ('environment. If run in a terminal-only session, they will fail.'))}
                    )
                  ]
                )
              ]
            )
            (command.ControlFlow token:<ControlFlow_Exit exit> arg_word:{(0)})
          ]
        )
    )
    (command.FuncDef
      name: guess_merge_tool
      body: 
        (command.BraceGroup
          children: [
            (C {(list_merge_tool_candidates)})
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})
                (redir.HereDoc
                  op: <Redir_DLessDash '<<-'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 1692
                  stdin_parts: [
                    ('\n')
                    ("This message is displayed because '")
                    ($ VSub_DollarName '$TOOL_MODE')
                    (".tool' is not configured.\n")
                    ("See 'git ")
                    (${ VSub_Name TOOL_MODE)
                    ("tool --tool-help' or 'git help config' for more details.\n")
                    ("'git ")
                    (${ VSub_Name TOOL_MODE)
                    ("tool' will now attempt to use one of the following tools:\n")
                    ($ VSub_DollarName '$tools')
                    ('\n')
                  ]
                )
              ]
            )
            (command.Assignment
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:IFS) op:Equal rhs:{(SQ <' '>)})]
            )
            (command.ForEach
              iter_name: tool
              iter_words: [{($ VSub_DollarName '$tools')}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.AndOr
                      ops: [Op_DAmp Op_DAmp]
                      children: [
                        (C {(is_available)} {(DQ ($ VSub_DollarName '$tool'))})
                        (C {(echo)} {(DQ ($ VSub_DollarName '$tool'))})
                        (command.ControlFlow
                          token: <ControlFlow_Return return>
                          arg_word: {(0)}
                        )
                      ]
                    )
                  ]
                )
            )
            (command.Simple
              words: [{(echo)} {(DQ ('No known ') (${ VSub_Name TOOL_MODE) (' tool is available.'))}]
              redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
            )
            (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)})
          ]
        )
    )
    (command.FuncDef
      name: get_configured_merge_tool
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(diff_mode)})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:merge_tool)
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSub
                                left_token: <Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.AndOr
                                        ops: [Op_DPipe]
                                        children: [
                                          (C {(git)} {(config)} {(diff.tool)})
                                          (C {(git)} {(config)} {(merge.tool)})
                                        ]
                                      )
                                    ]
                                  )
                              )
                            }
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (command.Assignment
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:merge_tool)
                      op: Equal
                      rhs: 
                        {
                          (word_part.CommandSub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [(C {(git)} {(config)} {(merge.tool)})]
                              )
                          )
                        }
                    )
                  ]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$merge_tool'))})
                        (command.Pipeline
                          children: [(C {(valid_tool)} {(DQ ($ VSub_DollarName '$merge_tool'))})]
                          negated: T
                        )
                      ]
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ ('git config option ') ($ VSub_DollarName '$TOOL_MODE') 
                            ('.tool set to unknown tool: ') ($ VSub_DollarName '$merge_tool')
                          )
                        }
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.Simple
                      words: [{(echo)} {(DQ ('Resetting to default...'))}]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Return return>
                      arg_word: {(1)}
                    )
                  ]
                )
              ]
            )
            (C {(echo)} {(DQ ($ VSub_DollarName '$merge_tool'))})
          ]
        )
    )
    (command.FuncDef
      name: get_merge_tool_path
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:merge_tool)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Pipeline
                      children: [(C {(valid_tool)} {(DQ ($ VSub_DollarName '$merge_tool'))})]
                      negated: T
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [{(echo)} {(DQ ('Unknown merge tool ') ($ VSub_DollarName '$merge_tool'))}]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(diff_mode)})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:merge_tool_path)
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSub
                                left_token: <Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (command.AndOr
                                        ops: [Op_DPipe]
                                        children: [
                                          (C {(git)} {(config)} 
                                            {(difftool.) (DQ ($ VSub_DollarName '$merge_tool')) 
                                              (.path)
                                            }
                                          )
                                          (C {(git)} {(config)} 
                                            {(mergetool.) (DQ ($ VSub_DollarName '$merge_tool')) 
                                              (.path)
                                            }
                                          )
                                        ]
                                      )
                                    ]
                                  )
                              )
                            }
                        )
                      ]
                    )
                  ]
                )
              ]
              else_action: [
                (command.Assignment
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:merge_tool_path)
                      op: Equal
                      rhs: 
                        {
                          (word_part.CommandSub
                            left_token: <Left_DollarParen '$('>
                            command_list: 
                              (command.CommandList
                                children: [
                                  (C {(git)} {(config)} 
                                    {(mergetool.) (DQ ($ VSub_DollarName '$merge_tool')) (.path)}
                                  )
                                ]
                              )
                          )
                        }
                    )
                  ]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$merge_tool_path'))})]
                  action: [
                    (command.Assignment
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:merge_tool_path)
                          op: Equal
                          rhs: 
                            {
                              (word_part.CommandSub
                                left_token: <Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (C {(translate_merge_tool_path)} 
                                        {(DQ ($ VSub_DollarName '$merge_tool'))}
                                      )
                                    ]
                                  )
                              )
                            }
                        )
                      ]
                    )
                  ]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(test)} {(-z)} 
                          {
                            (DQ 
                              (word_part.CommandSub
                                left_token: <Left_DollarParen '$('>
                                command_list: 
                                  (command.CommandList
                                    children: [
                                      (C {(get_merge_tool_cmd)} {(DQ ($ VSub_DollarName '$merge_tool'))})
                                    ]
                                  )
                              )
                            )
                          }
                        )
                        (command.Pipeline
                          children: [
                            (command.Simple
                              words: [{(type)} {(DQ ($ VSub_DollarName '$merge_tool_path'))}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(/dev/null)}
                                )
                                (redir.Redir
                                  op: <Redir_GreatAnd '2>&'>
                                  fd: 2
                                  arg_word: {(1)}
                                )
                              ]
                            )
                          ]
                          negated: T
                        )
                      ]
                    )
                  ]
                  action: [
                    (command.Simple
                      words: [
                        {(echo)}
                        {
                          (DQ ('The ') ($ VSub_DollarName '$TOOL_MODE') (' tool ') 
                            ($ VSub_DollarName '$merge_tool') (' is not available as')
                          )
                        }
                        {(DQ ("'") ($ VSub_DollarName '$merge_tool_path') ("'"))}
                      ]
                      redirects: [(redir.Redir op:<Redir_GreatAnd '>&'> fd:16777215 arg_word:{(2)})]
                    )
                    (command.ControlFlow
                      token: <ControlFlow_Exit exit>
                      arg_word: {(1)}
                    )
                  ]
                )
              ]
            )
            (C {(echo)} {(DQ ($ VSub_DollarName '$merge_tool_path'))})
          ]
        )
    )
    (command.FuncDef
      name: get_merge_tool
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:merge_tool)
                  op: Equal
                  rhs: 
                    {
                      (word_part.CommandSub
                        left_token: <Left_DollarParen '$('>
                        command_list: 
                          (command.CommandList
                            children: [(C {(get_configured_merge_tool)})]
                          )
                      )
                    }
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$merge_tool'))})]
                  action: [
                    (command.AndOr
                      ops: [Op_DPipe]
                      children: [
                        (command.Assignment
                          pairs: [
                            (assign_pair
                              lhs: (lhs_expr.LhsName name:merge_tool)
                              op: Equal
                              rhs: 
                                {
                                  (word_part.CommandSub
                                    left_token: <Left_DollarParen '$('>
                                    command_list: 
                                      (command.CommandList
                                        children: [(C {(guess_merge_tool)})]
                                      )
                                  )
                                }
                            )
                          ]
                        )
                        (command.ControlFlow token:<ControlFlow_Exit exit>)
                      ]
                    )
                  ]
                )
              ]
            )
            (C {(echo)} {(DQ ($ VSub_DollarName '$merge_tool'))})
          ]
        )
    )
    (command.FuncDef
      name: mergetool_find_win32_cmd
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:executable)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                )
              ]
            )
            (command.Assignment
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:sub_directory)
                  op: Equal
                  rhs: {($ VSub_Number '$2')}
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Simple
                      words: [{(type)} {(-p)} {(DQ ($ VSub_DollarName '$executable'))}]
                      redirects: [
                        (redir.Redir
                          op: <Redir_Great '>'>
                          fd: 16777215
                          arg_word: {(/dev/null)}
                        )
                        (redir.Redir
                          op: <Redir_GreatAnd '2>&'>
                          fd: 2
                          arg_word: {(1)}
                        )
                      ]
                    )
                  ]
                  action: [
                    (C {(printf)} {(SQ <'%s'>)} {(DQ ($ VSub_DollarName '$executable'))})
                    (command.ControlFlow token:<ControlFlow_Return return>)
                  ]
                )
              ]
            )
            (command.ForEach
              iter_name: directory
              iter_words: [
                {
                  (word_part.CommandSub
                    left_token: <Left_DollarParen '$('>
                    command_list: 
                      (command.CommandList
                        children: [
                          (command.Pipeline
                            children: [
                              (C {(env)})
                              (C {(grep)} {(-Ei)} {(SQ <'^PROGRAM(FILES(\\(X86\\))?|W6432)='>)})
                              (C {(cut)} {(-d)} {(SQ <'='>)} {(-f)} {(2-)})
                              (C {(sort)} {(-u)})
                            ]
                            negated: F
                          )
                        ]
                      )
                  )
                }
              ]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (command.If
                      arms: [
                        (if_arm
                          cond: [
                            (command.AndOr
                              ops: [Op_DAmp]
                              children: [
                                (C {(test)} {(-n)} {(DQ ($ VSub_DollarName '$directory'))})
                                (C {(test)} {(-x)} 
                                  {
                                    (DQ ($ VSub_DollarName '$directory') (/) 
                                      ($ VSub_DollarName '$sub_directory') (/) ($ VSub_DollarName '$executable')
                                    )
                                  }
                                )
                              ]
                            )
                          ]
                          action: [
                            (C {(printf)} {(SQ <'%s'>)} 
                              {
                                (DQ ($ VSub_DollarName '$directory') (/) 
                                  ($ VSub_DollarName '$sub_directory') (/) ($ VSub_DollarName '$executable')
                                )
                              }
                            )
                            (command.ControlFlow
                              token: <ControlFlow_Return return>
                            )
                          ]
                        )
                      ]
                    )
                  ]
                )
            )
            (C {(printf)} {(SQ <'%s'>)} {(DQ ($ VSub_DollarName '$executable'))})
          ]
        )
    )
  ]
)