(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'Test wacky input to git config'>)}
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.FuncDef
      name: setup
      body: 
        (command.BraceGroup
          children: [
            (command.Subshell
              command_list: 
                (command.CommandList
                  children: [
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(printf)} {(DQ ('[section]') (Lit_Other '\\') (n))})
                        (C {(printf)} {(DQ ('  key = foo'))})
                      ]
                    )
                  ]
                )
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(.git/config)})]
            )
          ]
        )
    )
    (command.FuncDef
      name: check
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_Number '$2'))}]
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)})]
            )
            (command.SimpleCommand
              words: [{(git)} {(config)} {(--get)} {(DQ ($ VSub_Number '$1'))}]
              redirects: [
                (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})
                (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})
              ]
            )
            (C {(test_cmp)} {(actual)} {(expected)})
          ]
        )
    )
    (command.FuncDef
      name: check_regex
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_Number '$3'))}]
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)})]
            )
            (command.SimpleCommand
              words: [{(git)} {(config)} {(--get)} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))}]
              redirects: [
                (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})
                (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})
              ]
            )
            (C {(test_cmp)} {(actual)} {(expected)})
          ]
        )
    )
    (C {(test_expect_success)} {(SQ <'modify same key'>)} 
      {
        (SQ <'\n'> <'\tsetup &&\n'> <'\tgit config section.key bar &&\n'> <'\tcheck section.key bar\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'add key in same section'>)} 
      {
        (SQ <'\n'> <'\tsetup &&\n'> <'\tgit config section.other bar &&\n'> 
          <'\tcheck section.key foo &&\n'> <'\tcheck section.other bar\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'add key in different section'>)} 
      {
        (SQ <'\n'> <'\tsetup &&\n'> <'\tgit config section2.key bar &&\n'> 
          <'\tcheck section.key foo &&\n'> <'\tcheck section2.key bar\n'>
        )
      }
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:SECTION)
          op: Equal
          rhs: 
            {
              (DQ (test.q) (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (s) 
                (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) ("sq'sp e.key")
              )
            }
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'make sure git config escapes section names properly'>)} 
      {(SQ <'\n'> <'\tgit config "$SECTION" bar &&\n'> <'\tcheck "$SECTION" bar\n'>)}
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:LONG_VALUE)
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [(C {(printf)} {(DQ ('x%01021dx a'))} {(7)})]
                  )
                left_token: <Left_CommandSub '$('>
              )
            }
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'do not crash on special long config line'>)} 
      {
        (SQ <'\n'> <'\tsetup &&\n'> <'\tgit config section.key "$LONG_VALUE" &&\n'> 
          <'\tcheck section.key "$LONG_VALUE"\n'>
        )
      }
    )
    (command.FuncDef
      name: setup_many
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (C {(setup)})
                (command.SimpleCommand
                  words: [{(echo)}]
                  redirects: [(redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(.git/config)})]
                )
                (command.SimpleCommand
                  words: [{(cat)}]
                  redirects: [
                    (redir.Redir
                      op: <Redir_Great '>'>
                      fd: 16777215
                      arg_word: {(5to1)}
                    )
                    (redir.HereDoc
                      op: <Redir_DLessDash '<<-'>
                      fd: 16777215
                      here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)}
                      here_end_span_id: 298
                      stdin_parts: [
                        ('  key = foo\n')
                        ('  key = foo\n')
                        ('  key = foo\n')
                        ('  key = foo\n')
                        ('  key = foo\n')
                      ]
                    )
                  ]
                )
                (command.SimpleCommand
                  words: [{(cat)} {(5to1)} {(5to1)} {(5to1)} {(5to1)} {(5to1)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(5to2)})]
                )
                (command.SimpleCommand
                  words: [{(cat)} {(5to2)} {(5to2)} {(5to2)} {(5to2)} {(5to2)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(5to3)})]
                )
                (command.SimpleCommand
                  words: [{(cat)} {(5to3)} {(5to3)} {(5to3)} {(5to3)} {(5to3)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(5to4)})]
                )
                (command.SimpleCommand
                  words: [{(cat)} {(5to4)} {(5to4)} {(5to4)} {(5to4)} {(5to4)}]
                  redirects: [(redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(.git/config)})]
                )
              ]
            )
          ]
        )
    )
    (C {(test_expect_success)} {(SQ <'get many entries'>)} 
      {
        (SQ <'\n'> <'\tsetup_many &&\n'> <'\tgit config --get-all section.key >actual &&\n'> 
          <'\ttest_line_count = 3126 actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'get many entries by regex'>)} 
      {
        (SQ <'\n'> <'\tsetup_many &&\n'> <'\tgit config --get-regexp "sec.*ke." >actual &&\n'> 
          <'\ttest_line_count = 3126 actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'add and replace one of many entries'>)} 
      {
        (SQ <'\n'> <'\tsetup_many &&\n'> <'\tgit config --add section.key bar &&\n'> 
          <'\tcheck_regex section.key "b.*r" bar &&\n'> <'\tgit config section.key beer "b.*r" &&\n'> <'\tcheck_regex section.key "b.*r" beer\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'replace many entries'>)} 
      {
        (SQ <'\n'> <'\tsetup_many &&\n'> <'\tgit config --replace-all section.key bar &&\n'> 
          <'\tcheck section.key bar\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unset many entries'>)} 
      {
        (SQ <'\n'> <'\tsetup_many &&\n'> <'\tgit config --unset-all section.key &&\n'> 
          <'\ttest_must_fail git config section.key\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'--add appends new value after existing empty value'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\n'> <'\n'> <'\tfool\n'> <'\troll\n'> <'\tEOF\n'> 
          <'\tcp .git/config .git/config.old &&\n'> <'\ttest_when_finished "mv .git/config.old .git/config" &&\n'> <'\tcat >.git/config <<-\\EOF &&\n'> 
          <'\t[foo]\n'> <'\t\tbaz\n'> <'\t\tbaz =\n'> <'\t\tbaz = fool\n'> <'\tEOF\n'> <'\tgit config --add foo.baz roll &&\n'> 
          <'\tgit config --get-all foo.baz >output &&\n'> <'\ttest_cmp expect output\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)