(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'test bash completion'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./lib-bash.sh'>})
    (command.ShFunction
      name: complete
      body: 
        (BraceGroup
          children: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:GIT_TESTING_COMMAND_COMPLETION)
          op: assign_op.Equal
          rhs: {(SQ <'add checkout check-attr filter-branch ls-files'>)}
          spids: [92]
        )
      ]
    )
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$GIT_BUILD_DIR') <'/contrib/completion/git-completion.bash'>)})
    (command.ShFunction
      name: _get_comp_words_by_ref
      body: 
        (BraceGroup
          children: [
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: 
                (condition.Shell
                  commands: [
                    (command.Sentence
                      child: 
                        (C {<Id.Lit_LBracket '['>} {($ Id.VSub_Pound '$#')} {<-gt>} {<0>} 
                          {<Id.Lit_RBracket ']'>}
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                )
              body: 
                (command.DoGroup
                  children: [
                    (command.Case
                      to_match: {(DQ ($ Id.VSub_Number '$1'))}
                      arms: [
                        (case_arm
                          pat_list: [{<cur>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:cur)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (braced_var_sub
                                        token: <Id.VSub_Name _words>
                                        bracket_op: 
                                          (bracket_op.ArrayIndex
                                            expr: <Id.Lit_ArithVarLike _cword>
                                          )
                                      )
                                    }
                                  spids: [152]
                                )
                              ]
                            )
                          ]
                          spids: [148 149 161 -1]
                        )
                        (case_arm
                          pat_list: [{<prev>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:prev)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (braced_var_sub
                                        token: <Id.VSub_Name _words>
                                        bracket_op: 
                                          (bracket_op.ArrayIndex
                                            expr: 
                                              (arith_expr.Binary
                                                op_id: Id.Arith_Minus
                                                left: <Id.Lit_ArithVarLike _cword>
                                                right: {<Id.Lit_Digits 1>}
                                              )
                                          )
                                      )
                                    }
                                  spids: [168]
                                )
                              ]
                            )
                          ]
                          spids: [164 165 179 -1]
                        )
                        (case_arm
                          pat_list: [{<words>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:words)
                                  op: assign_op.Equal
                                  rhs: 
                                    {
                                      (sh_array_literal
                                        left: <Id.Op_LParen _>
                                        words: [
                                          {
                                            (DQ 
                                              (braced_var_sub
                                                token: <Id.VSub_Name _words>
                                                bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                                              )
                                            )
                                          }
                                        ]
                                      )
                                    }
                                  spids: [186]
                                )
                              ]
                            )
                          ]
                          spids: [182 183 199 -1]
                        )
                        (case_arm
                          pat_list: [{<cword>}]
                          action: [
                            (command.ShAssignment
                              pairs: [
                                (assign_pair
                                  lhs: (sh_lhs_expr.Name name:cword)
                                  op: assign_op.Equal
                                  rhs: {($ Id.VSub_DollarName '$_cword')}
                                  spids: [206]
                                )
                              ]
                            )
                          ]
                          spids: [202 203 210 -1]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: print_comp
      body: 
        (BraceGroup
          children: [
            (C {<local>} 
              {<Id.Lit_VarLike 'IFS='> 
                (single_quoted
                  left: <Id.Left_DollarSingleQuote '$\''>
                  tokens: [<Id.Char_OneChar '\\n'>]
                  multiline: F
                )
              }
            )
            (command.Simple
              words: [
                {<echo>}
                {
                  (DQ 
                    (braced_var_sub
                      token: <Id.VSub_Name COMPREPLY>
                      bracket_op: (bracket_op.WholeArray op_id:Id.Arith_Star)
                    )
                  )
                }
              ]
              redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<out>})]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: run_completion
      body: 
        (BraceGroup
          children: [
            (C {<local>} {<-a>} {<COMPREPLY>} {<_words>})
            (C {<local>} {<_cword>})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:_words)
                  op: assign_op.Equal
                  rhs: {(sh_array_literal left:<Id.Op_LParen _> words:[{($ Id.VSub_Number '$1')}])}
                  spids: [280]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<test>} 
                  {
                    (DQ 
                      (braced_var_sub
                        token: <Id.VSub_Number 1>
                        suffix_op: 
                          (suffix_op.Slice
                            begin: 
                              (arith_expr.Unary
                                op_id: Id.Node_UnaryMinus
                                child: {<Id.Lit_Digits 1>}
                              )
                          )
                      )
                    )
                  } {<Id.Lit_Equals '='>} {(SQ <' '>)}
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: 
                        (sh_lhs_expr.IndexedName
                          name: _words
                          index: 
                            (arith_expr.Binary
                              op_id: Id.Arith_Plus
                              left: 
                                {
                                  (braced_var_sub
                                    token: <Id.VSub_Name _words>
                                    prefix_op: (Id.VSub_Pound)
                                    bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                                  )
                                }
                              right: {<Id.Lit_Digits 1>}
                            )
                        )
                      op: assign_op.Equal
                      rhs: {(SQ )}
                      spids: [308]
                    )
                  ]
                )
              ]
            )
            (command.DParen
              child: 
                (arith_expr.BinaryAssign
                  op_id: Id.Arith_Equal
                  left: <Id.Lit_ArithVarLike _cword>
                  right: 
                    (arith_expr.Binary
                      op_id: Id.Arith_Minus
                      left: 
                        {
                          (braced_var_sub
                            token: <Id.VSub_Name _words>
                            prefix_op: (Id.VSub_Pound)
                            bracket_op: (bracket_op.WholeArray op_id:Id.Lit_At)
                          )
                        }
                      right: {<Id.Lit_Digits 1>}
                    )
                )
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [(C {<__git_wrap__git_main>}) (C {<print_comp>})]
            )
          ]
        )
    )
    (command.ShFunction
      name: test_completion
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.If
                  arms: [
                    (if_arm
                      cond: 
                        (condition.Shell
                          commands: [(C {<test>} {($ Id.VSub_Pound '$#')} {<-gt>} {<1>})]
                        )
                      action: [
                        (command.Simple
                          words: [{<printf>} {(SQ <'%s\\n'>)} {(DQ ($ Id.VSub_Number '$2'))}]
                          redirects: [
                            (redir
                              op: <Id.Redir_Great '>'>
                              loc: (redir_loc.Fd fd:1)
                              arg: {<expected>}
                            )
                          ]
                          do_fork: T
                        )
                      ]
                      spids: [384 395]
                    )
                  ]
                  else_action: [
                    (command.Simple
                      words: [{<sed>} {<-e>} {(SQ <'s/Z$//'>)}]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<expected>}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                )
                (C {<run_completion>} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<test_cmp>} {<expected>} {<out>})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: test_gitcomp
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (C {<local>} {<-a>} {<COMPREPLY>})
                (command.Simple
                  words: [{<sed>} {<-e>} {(SQ <'s/Z$//'>)}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expected>})]
                  do_fork: T
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:cur)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [493]
                    )
                  ]
                )
                (C {<shift>})
                (C {<__gitcomp>} {(DQ ($ Id.VSub_At '$@'))})
                (C {<print_comp>})
                (C {<test_cmp>} {<expected>} {<out>})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: test_gitcomp_nl
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (C {<local>} {<-a>} {<COMPREPLY>})
                (command.Simple
                  words: [{<sed>} {<-e>} {(SQ <'s/Z$//'>)}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expected>})]
                  do_fork: T
                )
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:cur)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [572]
                    )
                  ]
                )
                (C {<shift>})
                (C {<__gitcomp_nl>} {(DQ ($ Id.VSub_At '$@'))})
                (C {<print_comp>})
                (C {<test_cmp>} {<expected>} {<out>})
              ]
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:invalid_variable_name)
          op: assign_op.Equal
          rhs: {(SQ <'${foo.bar}'>)}
          spids: [608]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:actual)
          op: assign_op.Equal
          rhs: {(DQ ($ Id.VSub_DollarName '$TRASH_DIRECTORY') <'/actual'>)}
          spids: [614]
        )
      ]
    )
    (C {<test_expect_success>} {(SQ <'setup for __gitdir tests'>)} 
      {(SQ <'\n'> <'\tmkdir -p subdir/subsubdir &&\n'> <'\tgit init otherrepo\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - from command line (through $__git_dir)'>)} 
      {
        (SQ <'\n'> <'\techo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&\n'> <'\t(\n'> 
          <'\t\t__git_dir="$TRASH_DIRECTORY/otherrepo/.git" &&\n'> <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - repo as argument'>)} 
      {
        (SQ <'\n'> <'\techo "otherrepo/.git" >expected &&\n'> 
          <'\t__gitdir "otherrepo" >"$actual" &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - remote as argument'>)} 
      {
        (SQ <'\n'> <'\techo "remote" >expected &&\n'> <'\t__gitdir "remote" >"$actual" &&\n'> 
          <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - .git directory in cwd'>)} 
      {
        (SQ <'\n'> <'\techo ".git" >expected &&\n'> <'\t__gitdir >"$actual" &&\n'> 
          <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - .git directory in parent'>)} 
      {
        (SQ <'\n'> <'\techo "$(pwd -P)/.git" >expected &&\n'> <'\t(\n'> <'\t\tcd subdir/subsubdir &&\n'> 
          <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - cwd is a .git directory'>)} 
      {
        (SQ <'\n'> <'\techo "." >expected &&\n'> <'\t(\n'> <'\t\tcd .git &&\n'> 
          <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - parent is a .git directory'>)} 
      {
        (SQ <'\n'> <'\techo "$(pwd -P)/.git" >expected &&\n'> <'\t(\n'> <'\t\tcd .git/refs/heads &&\n'> 
          <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - $GIT_DIR set while .git directory in cwd'>)} 
      {
        (SQ <'\n'> <'\techo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&\n'> <'\t(\n'> 
          <'\t\tGIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&\n'> <'\t\texport GIT_DIR &&\n'> <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> 
          <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - $GIT_DIR set while .git directory in parent'>)} 
      {
        (SQ <'\n'> <'\techo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&\n'> <'\t(\n'> 
          <'\t\tGIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&\n'> <'\t\texport GIT_DIR &&\n'> <'\t\tcd subdir &&\n'> <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> 
          <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - non-existing $GIT_DIR'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tGIT_DIR="$TRASH_DIRECTORY/non-existing" &&\n'> 
          <'\t\texport GIT_DIR &&\n'> <'\t\ttest_must_fail __gitdir\n'> <'\t)\n'>
        )
      }
    )
    (command.ShFunction
      name: pwd_P_W
      body: 
        (BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: (condition.Shell commands:[(C {<test_have_prereq>} {<MINGW>})])
                  action: [(C {<pwd>} {<-W>})]
                  spids: [807 814]
                )
              ]
              else_action: [(C {<pwd>} {<-P>})]
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - gitfile in cwd'>)} 
      {
        (SQ <'\n'> <'\techo "$(pwd_P_W)/otherrepo/.git" >expected &&\n'> 
          <'\techo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git &&\n'> <'\ttest_when_finished "rm -f subdir/.git" &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - gitfile in parent'>)} 
      {
        (SQ <'\n'> <'\techo "$(pwd_P_W)/otherrepo/.git" >expected &&\n'> 
          <'\techo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git &&\n'> <'\ttest_when_finished "rm -f subdir/.git" &&\n'> <'\t(\n'> <'\t\tcd subdir/subsubdir &&\n'> 
          <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS>} {(SQ <'__gitdir - resulting path avoids symlinks'>)} 
      {
        (SQ <'\n'> <'\techo "$(pwd -P)/otherrepo/.git" >expected &&\n'> <'\tmkdir otherrepo/dir &&\n'> 
          <'\ttest_when_finished "rm -rf otherrepo/dir" &&\n'> <'\tln -s otherrepo/dir link &&\n'> <'\ttest_when_finished "rm -f link" &&\n'> <'\t(\n'> 
          <'\t\tcd link &&\n'> <'\t\t__gitdir >"$actual"\n'> <'\t) &&\n'> <'\ttest_cmp expected "$actual"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitdir - not a git repository'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir/subsubdir &&\n'> 
          <'\t\tGIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&\n'> <'\t\texport GIT_CEILING_DIRECTORIES &&\n'> <'\t\ttest_must_fail __gitdir\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - trailing space - options'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=\n'> 
          <'\t\t--reset-author" <<-EOF\n'> <'\t--reuse-message=Z\n'> <'\t--reedit-message=Z\n'> <'\t--reset-author Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - trailing space - config keys'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp "br" "branch. branch.autosetupmerge\n'> 
          <'\t\tbranch.autosetuprebase browser." <<-\\EOF\n'> <'\tbranch.Z\n'> <'\tbranch.autosetupmerge Z\n'> <'\tbranch.autosetuprebase Z\n'> <'\tbrowser.Z\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - option parameter'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \\\n'> 
          <'\t\t"" "re" <<-\\EOF\n'> <'\trecursive Z\n'> <'\tresolve Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - prefix'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp "branch.me" "remote merge mergeoptions rebase" \\\n'> 
          <'\t\t"branch.maint." "me" <<-\\EOF\n'> <'\tbranch.maint.merge Z\n'> <'\tbranch.maint.mergeoptions Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - suffix'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp "branch.me" "master maint next pu" "branch." \\\n'> 
          <'\t\t"ma" "." <<-\\EOF\n'> <'\tbranch.master.Z\n'> <'\tbranch.maint.Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp - doesnt fail because of invalid variable name'>)} 
      {(SQ <'\n'> <'\t__gitcomp "$invalid_variable_name"\n'>)}
    )
    (command.Simple
      words: [{<read>} {<-r>} {<-d>} {(DQ )} {<refs>}]
      redirects: [
        (redir
          op: <Id.Redir_DLessDash '<<-'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 1027
              stdin_parts: [<'maint\n'> <'master\n'> <'next\n'> <'pu\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp_nl - trailing space'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp_nl "m" "$refs" <<-EOF\n'> <'\tmaint Z\n'> <'\tmaster Z\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp_nl - prefix'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF\n'> 
          <'\t--fixup=maint Z\n'> <'\t--fixup=master Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp_nl - suffix'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp_nl "branch.ma" "$refs" "branch." "ma" "." <<-\\EOF\n'> 
          <'\tbranch.maint.Z\n'> <'\tbranch.master.Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp_nl - no suffix'>)} 
      {
        (SQ <'\n'> <'\ttest_gitcomp_nl "ma" "$refs" "" "ma" "" <<-\\EOF\n'> <'\tmaintZ\n'> 
          <'\tmasterZ\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'__gitcomp_nl - doesnt fail because of invalid variable name'>)} 
      {(SQ <'\n'> <'\t__gitcomp_nl "$invalid_variable_name"\n'>)}
    )
    (C {<test_expect_success>} 
      {(SQ <'__git_remotes - list remotes from $GIT_DIR/remotes and from config file'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-EOF &&\n'> <'\tremote_from_file_1\n'> <'\tremote_from_file_2\n'> 
          <'\tremote_in_config_1\n'> <'\tremote_in_config_2\n'> <'\tEOF\n'> <'\ttest_when_finished "rm -rf .git/remotes" &&\n'> 
          <'\tmkdir -p .git/remotes &&\n'> <'\t>.git/remotes/remote_from_file_1 &&\n'> <'\t>.git/remotes/remote_from_file_2 &&\n'> 
          <'\ttest_when_finished "git remote remove remote_in_config_1" &&\n'> <'\tgit remote add remote_in_config_1 git://remote_1 &&\n'> 
          <'\ttest_when_finished "git remote remove remote_in_config_2" &&\n'> <'\tgit remote add remote_in_config_2 git://remote_2 &&\n'> <'\t__git_remotes >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <__git_get_config_variables>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-EOF &&\n'> <'\tname-1\n'> <'\tname-2\n'> <'\tEOF\n'> 
          <'\ttest_config interesting.name-1 good &&\n'> <'\ttest_config interesting.name-2 good &&\n'> 
          <'\ttest_config subsection.interesting.name-3 bad &&\n'> <'\t__git_get_config_variables interesting >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <__git_pretty_aliases>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-EOF &&\n'> <'\tauthor\n'> <'\thash\n'> <'\tEOF\n'> 
          <'\ttest_config pretty.author "%an %ae" &&\n'> <'\ttest_config pretty.hash %H &&\n'> <'\t__git_pretty_aliases >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <__git_aliases>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-EOF &&\n'> <'\tci\n'> <'\tco\n'> <'\tEOF\n'> 
          <'\ttest_config alias.ci commit &&\n'> <'\ttest_config alias.co checkout &&\n'> <'\t__git_aliases >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <basic>)} 
      {
        (SQ <'\n'> <'\trun_completion "git " &&\n'> <'\t# built-in\n'> <'\tgrep -q "^add \\$" out &&\n'> 
          <'\t# script\n'> <'\tgrep -q "^filter-branch \\$" out &&\n'> <'\t# plumbing\n'> <'\t! grep -q "^ls-files \\$" out &&\n'> 
          <'\n'> <'\trun_completion "git f" &&\n'> <'\t! grep -q -v "^f" out\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'double dash "git" itself'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git --" <<-\\EOF\n'> <'\t--paginate Z\n'> <'\t--no-pager Z\n'> 
          <'\t--git-dir=\n'> <'\t--bare Z\n'> <'\t--version Z\n'> <'\t--exec-path Z\n'> <'\t--exec-path=\n'> <'\t--html-path Z\n'> 
          <'\t--man-path Z\n'> <'\t--info-path Z\n'> <'\t--work-tree=\n'> <'\t--namespace=\n'> <'\t--no-replace-objects Z\n'> 
          <'\t--help Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'double dash "git checkout"'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git checkout --" <<-\\EOF\n'> <'\t--quiet Z\n'> <'\t--ours Z\n'> 
          <'\t--theirs Z\n'> <'\t--track Z\n'> <'\t--no-track Z\n'> <'\t--merge Z\n'> <'\t--conflict=\n'> <'\t--orphan Z\n'> 
          <'\t--patch Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'general options'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git --ver" "--version " &&\n'> 
          <'\ttest_completion "git --hel" "--help " &&\n'> <'\ttest_completion "git --exe" <<-\\EOF &&\n'> <'\t--exec-path Z\n'> <'\t--exec-path=\n'> <'\tEOF\n'> 
          <'\ttest_completion "git --htm" "--html-path " &&\n'> <'\ttest_completion "git --pag" "--paginate " &&\n'> 
          <'\ttest_completion "git --no-p" "--no-pager " &&\n'> <'\ttest_completion "git --git" "--git-dir=" &&\n'> 
          <'\ttest_completion "git --wor" "--work-tree=" &&\n'> <'\ttest_completion "git --nam" "--namespace=" &&\n'> <'\ttest_completion "git --bar" "--bare " &&\n'> 
          <'\ttest_completion "git --inf" "--info-path " &&\n'> <'\ttest_completion "git --no-r" "--no-replace-objects "\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'general options plus command'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git --version check" "checkout " &&\n'> 
          <'\ttest_completion "git --paginate check" "checkout " &&\n'> <'\ttest_completion "git --git-dir=foo check" "checkout " &&\n'> 
          <'\ttest_completion "git --bare check" "checkout " &&\n'> <'\ttest_completion "git --exec-path=foo check" "checkout " &&\n'> 
          <'\ttest_completion "git --html-path check" "checkout " &&\n'> <'\ttest_completion "git --no-pager check" "checkout " &&\n'> 
          <'\ttest_completion "git --work-tree=foo check" "checkout " &&\n'> <'\ttest_completion "git --namespace=foo check" "checkout " &&\n'> 
          <'\ttest_completion "git --paginate check" "checkout " &&\n'> <'\ttest_completion "git --info-path check" "checkout " &&\n'> 
          <'\ttest_completion "git --no-replace-objects check" "checkout "\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'git --help completion'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git --help ad" "add " &&\n'> 
          <'\ttest_completion "git --help core" "core-tutorial "\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup for ref completion'>)} 
      {
        (SQ <'\n'> <'\techo content >file1 &&\n'> <'\techo more >file2 &&\n'> <'\tgit add . &&\n'> 
          <'\tgit commit -m one &&\n'> <'\tgit branch mybranch &&\n'> <'\tgit tag mytag\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'checkout completes ref names'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git checkout m" <<-\\EOF\n'> <'\tmaster Z\n'> <'\tmybranch Z\n'> 
          <'\tmytag Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'show completes all refs'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git show m" <<-\\EOF\n'> <'\tmaster Z\n'> <'\tmybranch Z\n'> 
          <'\tmytag Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'<ref>: completes paths'>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git show mytag:f" <<-\\EOF\n'> <'\tfile1 Z\n'> <'\tfile2 Z\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'complete tree filename with spaces'>)} 
      {
        (SQ <'\n'> <'\techo content >"name with spaces" &&\n'> <'\tgit add . &&\n'> 
          <'\tgit commit -m spaces &&\n'> <'\ttest_completion "git show HEAD:nam" <<-\\EOF\n'> <'\tname with spaces Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'complete tree filename with metacharacters'>)} 
      {
        (SQ <'\n'> <'\techo content >"name with \\${meta}" &&\n'> <'\tgit add . &&\n'> 
          <'\tgit commit -m meta &&\n'> <'\ttest_completion "git show HEAD:nam" <<-\\EOF\n'> <'\tname with ${meta} Z\n'> 
          <'\tname with spaces Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <send-email>)} 
      {
        (SQ <'\n'> <'\ttest_completion "git send-email --cov" "--cover-letter " &&\n'> 
          <'\ttest_completion "git send-email ma" "master "\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'complete files'>)} 
      {
        (SQ <'\n'> <'\tgit init tmp && cd tmp &&\n'> 
          <'\ttest_when_finished "cd .. && rm -rf tmp" &&\n'> <'\n'> <'\techo "expected" > .gitignore &&\n'> <'\techo "out" >> .gitignore &&\n'> <'\n'> 
          <'\tgit add .gitignore &&\n'> <'\ttest_completion "git commit " ".gitignore" &&\n'> <'\n'> <'\tgit commit -m ignore &&\n'> <'\n'> 
          <'\ttouch new &&\n'> <'\ttest_completion "git add " "new" &&\n'> <'\n'> <'\tgit add new &&\n'> 
          <'\tgit commit -a -m new &&\n'> <'\ttest_completion "git add " "" &&\n'> <'\n'> <'\tgit mv new modified &&\n'> 
          <'\techo modify > modified &&\n'> <'\ttest_completion "git add " "modified" &&\n'> <'\n'> <'\ttouch untracked &&\n'> <'\n'> 
          <'\t: TODO .gitignore should not be here &&\n'> <'\ttest_completion "git rm " <<-\\EOF &&\n'> <'\t.gitignore\n'> <'\tmodified\n'> <'\tEOF\n'> <'\n'> 
          <'\ttest_completion "git clean " "untracked" &&\n'> <'\n'> <'\t: TODO .gitignore should not be here &&\n'> <'\ttest_completion "git mv " <<-\\EOF &&\n'> 
          <'\t.gitignore\n'> <'\tmodified\n'> <'\tEOF\n'> <'\n'> <'\tmkdir dir &&\n'> <'\ttouch dir/file-in-dir &&\n'> 
          <'\tgit add dir/file-in-dir &&\n'> <'\tgit commit -m dir &&\n'> <'\n'> <'\tmkdir untracked-dir &&\n'> <'\n'> 
          <'\t: TODO .gitignore should not be here &&\n'> <'\ttest_completion "git mv modified " <<-\\EOF &&\n'> <'\t.gitignore\n'> <'\tdir\n'> <'\tmodified\n'> 
          <'\tuntracked\n'> <'\tuntracked-dir\n'> <'\tEOF\n'> <'\n'> <'\ttest_completion "git commit " "modified" &&\n'> <'\n'> 
          <'\t: TODO .gitignore should not be here &&\n'> <'\ttest_completion "git ls-files " <<-\\EOF &&\n'> <'\t.gitignore\n'> <'\tdir\n'> <'\tmodified\n'> 
          <'\tEOF\n'> <'\n'> <'\ttouch momified &&\n'> <'\ttest_completion "git add mom" "momified"\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(DQ <'completion uses <cmd> completion for alias: !sh -c \'git <cmd> ...\''>)} 
      {(SQ <'\n'> <'\ttest_config alias.co "!sh -c '>) (DQ <'\''>) (SQ <'git checkout ...'>) (DQ <'\''>) 
        (SQ <'" &&\n'> <'\ttest_completion "git co m" <<-\\EOF\n'> <'\tmaster Z\n'> <'\tmybranch Z\n'> 
          <'\tmytag Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'completion uses <cmd> completion for alias: !f () { VAR=val git <cmd> ... }'>)} 
      {
        (SQ <'\n'> <'\ttest_config alias.co "!f () { VAR=val git checkout ... ; } f" &&\n'> 
          <'\ttest_completion "git co m" <<-\\EOF\n'> <'\tmaster Z\n'> <'\tmybranch Z\n'> <'\tmytag Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'completion used <cmd> completion for alias: !f() { : git <cmd> ; ... }'>)} 
      {
        (SQ <'\n'> <'\ttest_config alias.co "!f() { : git checkout ; if ... } f" &&\n'> 
          <'\ttest_completion "git co m" <<-\\EOF\n'> <'\tmaster Z\n'> <'\tmybranch Z\n'> <'\tmytag Z\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'complete with tilde expansion'>)} 
      {
        (SQ <'\n'> <'\tgit init tmp && cd tmp &&\n'> 
          <'\ttest_when_finished "cd .. && rm -rf tmp" &&\n'> <'\n'> <'\ttouch ~/tmp/file &&\n'> <'\n'> <'\ttest_completion "git add ~/tmp/" "~/tmp/file"\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)