(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'Test wacky input to git config'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: setup
      body: 
        (BraceGroup
          children: [
            (Subshell
              child: 
                (AndOr
                  children: [
                    (C {(printf)} {(DQ ('[section]') (Lit_Other '\\') (n))})
                    (C {(printf)} {(DQ ('  key = foo'))})
                  ]
                  op_id: Op_DAmp
                )
              redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(.git/config)} spids:[43])]
              spids: [24 41]
            )
          ]
          spids: [21]
        )
      spids: [17 20]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_Number '$2'))}]
              redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(expected)} spids:[68])]
            )
            (SimpleCommand
              words: [{(git)} {(config)} {(--get)} {(DQ ($ VSub_Number '$1'))}]
              redirects: [
                (Redir op_id:Redir_Great fd:16777215 arg_word:{(actual)} spids:[82])
                (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[85])
              ]
            )
            (C {(test_cmp)} {(actual)} {(expected)})
          ]
          spids: [59]
        )
      spids: [55 58]
    )
    (FuncDef
      name: check_regex
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(echo)} {(DQ ($ VSub_Number '$3'))}]
              redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(expected)} spids:[117])]
            )
            (SimpleCommand
              words: [{(git)} {(config)} {(--get)} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))}]
              redirects: [
                (Redir op_id:Redir_Great fd:16777215 arg_word:{(actual)} spids:[135])
                (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[138])
              ]
            )
            (C {(test_cmp)} {(actual)} {(expected)})
          ]
          spids: [108]
        )
      spids: [104 107]
    )
    (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'>
        )
      }
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:SECTION)
          op: Equal
          rhs: 
            {
              (DQ (test.q) (EscapedLiteralPart token:<Lit_EscapedChar '\\"'>) (s) 
                (EscapedLiteralPart token:<Lit_EscapedChar '\\\\'>) ("sq'sp e.key")
              )
            }
          spids: [195]
        )
      ]
      spids: [195]
    )
    (C {(test_expect_success)} {(SQ <'make sure git config escapes section names properly'>)} 
      {(SQ <'\n'> <'\tgit config "$SECTION" bar &&\n'> <'\tcheck "$SECTION" bar\n'>)}
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:LONG_VALUE)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(printf)} {(DQ ('x%01021dx a'))} {(7)})])
                left_token: <Left_CommandSub '$('>
                spids: [218 226]
              )
            }
          spids: [217]
        )
      ]
      spids: [217]
    )
    (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'>
        )
      }
    )
    (FuncDef
      name: setup_many
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(setup)})
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(echo)}]
                      redirects: [
                        (Redir
                          op_id: Redir_DGreat
                          fd: 16777215
                          arg_word: {(.git/config)}
                          spids: [264]
                        )
                      ]
                    )
                    (AndOr
                      children: [
                        (SimpleCommand
                          words: [{(cat)}]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: 16777215
                              arg_word: {(5to1)}
                              spids: [284]
                            )
                            (HereDoc
                              op_id: Redir_DLessDash
                              fd: 16777215
                              body: 
                                {('  key = foo\n') ('  key = foo\n') ('  key = foo\n') 
                                  ('  key = foo\n') ('  key = foo\n')
                                }
                              do_expansion: False
                              here_end: EOF
                              was_filled: True
                              spids: [287]
                            )
                          ]
                        )
                        (AndOr
                          children: [
                            (SimpleCommand
                              words: [{(cat)} {(5to1)} {(5to1)} {(5to1)} {(5to1)} {(5to1)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: 16777215
                                  arg_word: {(5to2)}
                                  spids: [306]
                                )
                              ]
                            )
                            (AndOr
                              children: [
                                (SimpleCommand
                                  words: [{(cat)} {(5to2)} {(5to2)} {(5to2)} {(5to2)} {(5to2)}]
                                  redirects: [
                                    (Redir
                                      op_id: Redir_Great
                                      fd: 16777215
                                      arg_word: {(5to3)}
                                      spids: [327]
                                    )
                                  ]
                                )
                                (AndOr
                                  children: [
                                    (SimpleCommand
                                      words: [{(cat)} {(5to3)} {(5to3)} {(5to3)} {(5to3)} {(5to3)}]
                                      redirects: [
                                        (Redir
                                          op_id: Redir_Great
                                          fd: 16777215
                                          arg_word: {(5to4)}
                                          spids: [348]
                                        )
                                      ]
                                    )
                                    (SimpleCommand
                                      words: [{(cat)} {(5to4)} {(5to4)} {(5to4)} {(5to4)} {(5to4)}]
                                      redirects: [
                                        (Redir
                                          op_id: Redir_DGreat
                                          fd: 16777215
                                          arg_word: {(.git/config)}
                                          spids: [369]
                                        )
                                      ]
                                    )
                                  ]
                                  op_id: Op_DAmp
                                )
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [246]
        )
      spids: [242 245]
    )
    (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)})
  ]
)