(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[12])
          op: Equal
          rhs: 
            {
              (DQ ('Tests of cwd/prefix/worktree/gitdir setup in all cases\n') ('\n') 
                ('A few rules for repo setup:\n') ('\n') ("1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to\n") ('   GIT_DIR.\n') ('\n') 
                ('2. .git file is relative to parent directory. .git file is basically\n') ('   symlink in disguise. The directory where .git file points to will\n') 
                ('   become new git_dir.\n') ('\n') ('3. core.worktree is relative to git_dir.\n') ('\n') 
                ("4. GIT_WORK_TREE is relative to user's cwd. --work-tree is\n") ('   equivalent to GIT_WORK_TREE.\n') ('\n') 
                ('5. GIT_WORK_TREE/core.worktree was originally meant to work only if\n') ("   GIT_DIR is set, but earlier git didn't enforce it, and some scripts\n") 
                ('   depend on the implementation that happened to first discover .git by\n') ('   going up from the users ') ($ VSub_Name '$cwd') (' and then using the specified working tree\n') 
                ('   that may or may not have any relation to where .git was found in.  This\n') ('   historical behaviour must be kept.\n') ('\n') 
                ('6. Effective GIT_WORK_TREE overrides core.worktree and core.bare\n') ('\n') ('7. Effective core.worktree conflicts with core.bare\n') ('\n') 
                ('8. If GIT_DIR is set but neither worktree nor bare setting is given,\n') ('   original cwd becomes worktree.\n') ('\n') 
                ('9. If .git discovery is done inside a repo, the repo becomes a bare\n') ('   repo. .git discovery is performed if GIT_DIR is not set.\n') ('\n') 
                ('10. If no worktree is available, cwd remains unchanged, prefix is\n') ('    NULL.\n') ('\n') ("11. When user's cwd is outside worktree, cwd remains unchanged,\n") 
                ('    prefix is NULL.\n')
              )
            }
          spids: [12]
        )
      ]
      spids: [12]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:here spids:[61])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: (command.CommandList children:[(C {(pwd)})])
                left_token: <Left_CommandSub '$('>
                spids: [62 64]
              )
            }
          spids: [61]
        )
      ]
      spids: [61]
    )
    (command.FuncDef
      name: test_repo
      body: 
        (command.BraceGroup
          children: [
            (command.Subshell
              child: 
                (command.AndOr
                  ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
                  children: [
                    (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Number '$2'))})]
                          action: [
                            (command.AndOr
                              ops: [Op_DAmp]
                              children: [
                                (command.Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (lhs_expr.LhsName name:GIT_DIR spids:[101])
                                      op: Equal
                                      rhs: {(DQ ($ VSub_Number '$2'))}
                                      spids: [101]
                                    )
                                  ]
                                  spids: [101]
                                )
                                (C {(export)} {(GIT_DIR)})
                              ]
                            )
                          ]
                          spids: [16777215 98]
                        )
                      ]
                      spids: [16777215 114]
                    )
                    (command.If
                      arms: [
                        (if_arm
                          cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Number '$3'))})]
                          action: [
                            (command.AndOr
                              ops: [Op_DAmp]
                              children: [
                                (command.Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (lhs_expr.LhsName name:GIT_WORK_TREE spids:[133])
                                      op: Equal
                                      rhs: {(DQ ($ VSub_Number '$3'))}
                                      spids: [133]
                                    )
                                  ]
                                  spids: [133]
                                )
                                (C {(export)} {(GIT_WORK_TREE)})
                              ]
                            )
                          ]
                          spids: [16777215 130]
                        )
                      ]
                      spids: [16777215 146]
                    )
                    (C {(rm)} {(-f)} {(trace)})
                    (command.SimpleCommand
                      words: [{(git)} {(symbolic-ref)} {(HEAD)}]
                      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
                      more_env: [
                        (env_pair
                          name: GIT_TRACE_SETUP
                          val: 
                            {
                              (DQ 
                                (word_part.CommandSubPart
                                  command_list: (command.CommandList children:[(C {(pwd)})])
                                  left_token: <Left_CommandSub '$('>
                                  spids: [162 164]
                                ) (/trace)
                              )
                            }
                          spids: [160]
                        )
                      ]
                    )
                    (command.SimpleCommand
                      words: [{(grep)} {(SQ <'^setup: '>)} {(trace)}]
                      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(result)})]
                    )
                    (C {(test_cmp)} {(expected)} {(result)})
                  ]
                )
              spids: [75 201]
            )
          ]
          spids: [72]
        )
      spids: [67 71]
    )
    (command.FuncDef
      name: maybe_config
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:file spids:[214])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [214]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:var spids:[217])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [217]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:value spids:[220])
                      op: Equal
                      rhs: {($ VSub_Number '$3')}
                      spids: [220]
                    )
                  ]
                  spids: [214]
                )
                (command.If
                  arms: [
                    (if_arm
                      cond: [
                        (C {(test)} {(DQ ($ VSub_Name '$value'))} {(KW_Bang '!') (Lit_Other '=')} 
                          {(unset)}
                        )
                      ]
                      action: [
                        (C {(git)} {(config)} {(--file) (Lit_Other '=') (DQ ($ VSub_Name '$file'))} 
                          {(DQ ($ VSub_Name '$var'))} {(DQ ($ VSub_Name '$value'))}
                        )
                      ]
                      spids: [16777215 240]
                    )
                  ]
                  spids: [16777215 262]
                )
              ]
            )
          ]
          spids: [211]
        )
      spids: [206 210]
    )
    (command.FuncDef
      name: setup_repo
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:name spids:[275])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [275]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:worktreecfg spids:[278])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [278]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:gitfile spids:[281])
                      op: Equal
                      rhs: {($ VSub_Number '$3')}
                      spids: [281]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:barecfg spids:[284])
                      op: Equal
                      rhs: {($ VSub_Number '$4')}
                      spids: [284]
                    )
                  ]
                  spids: [275]
                )
                (C {(sane_unset)} {(GIT_DIR)} {(GIT_WORK_TREE)})
                (C {(git)} {(init)} {(DQ ($ VSub_Name '$name'))})
                (C {(maybe_config)} {(DQ ($ VSub_Name '$name') (/.git/config))} {(core.worktree)} 
                  {(DQ ($ VSub_Name '$worktreecfg'))}
                )
                (C {(maybe_config)} {(DQ ($ VSub_Name '$name') (/.git/config))} {(core.bare)} 
                  {(DQ ($ VSub_Name '$barecfg'))}
                )
                (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$name') (/sub/sub))})
                (command.If
                  arms: [
                    (if_arm
                      cond: [
                        (C {(test)} 
                          {
                            (DQ 
                              (word_part.BracedVarSub
                                token: <VSub_Name gitfile>
                                suffix_op: 
                                  (suffix_op.StringUnary
                                    op_id: VTest_ColonPlus
                                    arg_word: {(set)}
                                  )
                                spids: [361 365]
                              )
                            )
                          }
                        )
                      ]
                      action: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(mv)} {(DQ ($ VSub_Name '$name') (/.git))} 
                              {(DQ ($ VSub_Name '$name') (.git))}
                            )
                            (command.SimpleCommand
                              words: [{(echo)} {(DQ ('gitdir: ../') ($ VSub_Name '$name') (.git))}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(DQ ($ VSub_Name '$name') (/.git))}
                                )
                              ]
                            )
                          ]
                        )
                      ]
                      spids: [16777215 369]
                    )
                  ]
                  spids: [16777215 402]
                )
              ]
            )
          ]
          spids: [272]
        )
      spids: [267 271]
    )
    (command.FuncDef
      name: maybe_set
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:var spids:[415])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [415]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:value spids:[418])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [418]
                    )
                  ]
                  spids: [415]
                )
                (command.If
                  arms: [
                    (if_arm
                      cond: [
                        (C {(test)} {(DQ ($ VSub_Name '$value'))} {(KW_Bang '!') (Lit_Other '=')} 
                          {(unset)}
                        )
                      ]
                      action: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(eval)} 
                              {
                                (DQ ($ VSub_Name '$var') ('=') 
                                  (word_part.EscapedLiteralPart
                                    token: <Lit_EscapedChar '\\$'>
                                  ) (value)
                                )
                              }
                            )
                            (C {(export)} {($ VSub_Name '$var')})
                          ]
                        )
                      ]
                      spids: [16777215 438]
                    )
                  ]
                  spids: [16777215 458]
                )
              ]
            )
          ]
          spids: [412]
        )
      spids: [407 411]
    )
    (command.FuncDef
      name: setup_env
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:worktreenv spids:[471])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [471]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:gitdirenv spids:[474])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [474]
                    )
                  ]
                  spids: [471]
                )
                (C {(sane_unset)} {(GIT_DIR)} {(GIT_WORK_TREE)})
                (C {(maybe_set)} {(GIT_DIR)} {(DQ ($ VSub_Name '$gitdirenv'))})
                (C {(maybe_set)} {(GIT_WORK_TREE)} {(DQ ($ VSub_Name '$worktreeenv'))})
              ]
            )
          ]
          spids: [468]
        )
      spids: [463 467]
    )
    (command.FuncDef
      name: expect
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(cat)}]
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(DQ ($ VSub_Number '$1') (/expected))}
                )
                (redir.HereDoc
                  op: <Redir_DLessDash '<<-'>
                  fd: 16777215
                  here_begin: {(EOF)}
                  here_end_span_id: 546
                  stdin_parts: [
                    ('setup: git_dir: ')
                    ($ VSub_Number '$2')
                    ('\n')
                    ('setup: git_common_dir: ')
                    ($ VSub_Number '$2')
                    ('\n')
                    ('setup: worktree: ')
                    ($ VSub_Number '$3')
                    ('\n')
                    ('setup: cwd: ')
                    ($ VSub_Number '$4')
                    ('\n')
                    ('setup: prefix: ')
                    ($ VSub_Number '$5')
                    ('\n')
                  ]
                )
              ]
            )
          ]
          spids: [516]
        )
      spids: [511 515]
    )
    (command.FuncDef
      name: try_case
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:name spids:[558])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [558]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:worktreeenv spids:[561])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [561]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:gitdirenv spids:[564])
                      op: Equal
                      rhs: {($ VSub_Number '$3')}
                      spids: [564]
                    )
                  ]
                  spids: [558]
                )
                (C {(setup_env)} {(DQ ($ VSub_Name '$worktreeenv'))} {(DQ ($ VSub_Name '$gitdirenv'))})
                (C {(expect)} {(DQ ($ VSub_Name '$name'))} {(DQ ($ VSub_Number '$4'))} 
                  {(DQ ($ VSub_Number '$5'))} {(DQ ($ VSub_Number '$6'))} {(DQ ($ VSub_Number '$7'))}
                )
                (C {(test_repo)} {(DQ ($ VSub_Name '$name'))})
              ]
            )
          ]
          spids: [555]
        )
      spids: [550 554]
    )
    (command.FuncDef
      name: run_wt_tests
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:N spids:[625])
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [625]
                )
                (assign_pair
                  lhs: (lhs_expr.LhsName name:gitfile spids:[628])
                  op: Equal
                  rhs: {($ VSub_Number '$2')}
                  spids: [628]
                )
              ]
              spids: [625]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:absgit spids:[633])
                  op: Equal
                  rhs: {(DQ ($ VSub_Name '$here') (/) ($ VSub_Name '$N') (/.git))}
                  spids: [633]
                )
              ]
              spids: [633]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:dotgit spids:[642])
                  op: Equal
                  rhs: {(.git)}
                  spids: [642]
                )
              ]
              spids: [642]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:dotdotgit spids:[646])
                  op: Equal
                  rhs: {(../../.git)}
                  spids: [646]
                )
              ]
              spids: [646]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [(C {(test)} {(DQ ($ VSub_Name '$gitfile'))})]
                  action: [
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:absgit spids:[663])
                          op: Equal
                          rhs: {(DQ ($ VSub_Name '$here') (/) ($ VSub_Name '$N') (.git))}
                          spids: [663]
                        )
                      ]
                      spids: [663]
                    )
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:dotgit spids:[672])
                          op: Equal
                          rhs: {($ VSub_Name '$absgit')}
                          spids: [672]
                        )
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:dotdotgit spids:[675])
                          op: Equal
                          rhs: {($ VSub_Name '$absgit')}
                          spids: [675]
                        )
                      ]
                      spids: [672]
                    )
                  ]
                  spids: [16777215 660]
                )
              ]
              spids: [16777215 679]
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': explicit GIT_WORK_TREE and GIT_DIR at toplevel'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N "$here/$N" .git \\\n'> 
                  <'\t\t\t"$dotgit" "$here/$N" "$here/$N" "(null)" &&\n'> <'\t\ttry_case $N . .git \\\n'> <'\t\t\t"$dotgit" "$here/$N" "$here/$N" "(null)" &&\n'> 
                  <'\t\ttry_case $N "$here/$N" "$here/$N/.git" \\\n'> <'\t\t\t"$absgit" "$here/$N" "$here/$N" "(null)" &&\n'> <'\t\ttry_case $N . "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N" "$here/$N" "(null)"\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': explicit GIT_WORK_TREE and GIT_DIR in subdir'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N/sub/sub "$here/$N" ../../.git \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N" "$here/$N" sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub ../.. ../../.git \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N" "$here/$N" sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub "$here/$N" "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N" "$here/$N" sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub ../.. "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N" "$here/$N" sub/sub/\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': explicit GIT_WORK_TREE from parent of worktree'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N "$here/$N/wt" .git \\\n'> 
                  <'\t\t\t"$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&\n'> <'\t\ttry_case $N wt .git \\\n'> <'\t\t\t"$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&\n'> 
                  <'\t\ttry_case $N wt "$here/$N/.git" \\\n'> <'\t\t\t"$absgit" "$here/$N/wt" "$here/$N" "(null)" &&\n'> 
                  <'\t\ttry_case $N "$here/$N/wt" "$here/$N/.git" \\\n'> <'\t\t\t"$absgit" "$here/$N/wt" "$here/$N" "(null)"\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': explicit GIT_WORK_TREE from nephew of worktree'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N/sub/sub "$here/$N/wt" ../../.git \\\n'> 
                  <'\t\t\t"$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&\n'> <'\t\ttry_case $N/sub/sub ../../wt ../../.git \\\n'> 
                  <'\t\t\t"$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&\n'> <'\t\ttry_case $N/sub/sub ../../wt "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&\n'> <'\t\ttry_case $N/sub/sub "$here/$N/wt" "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)"\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': chdir_to_toplevel uses worktree, not git dir'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N "$here" .git \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/ &&\n'> <'\t\ttry_case $N .. .git \\\n'> <'\t\t\t"$absgit" "$here" "$here" $N/ &&\n'> 
                  <'\t\ttry_case $N .. "$here/$N/.git" \\\n'> <'\t\t\t"$absgit" "$here" "$here" $N/ &&\n'> <'\t\ttry_case $N "$here" "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ ('#') ($ VSub_Name '$N') (': chdir_to_toplevel uses worktree (from subdir)'))} 
              {
                (SQ <'\n'> <'\t\ttry_case $N/sub/sub "$here" ../../.git \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub ../../.. ../../.git \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub ../../../ "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/sub/sub/ &&\n'> <'\t\ttry_case $N/sub/sub "$here" "$here/$N/.git" \\\n'> 
                  <'\t\t\t"$absgit" "$here" "$here" $N/sub/sub/\n'> <'\t'>
                )
              }
            )
          ]
          spids: [622]
        )
      spids: [617 621]
    )
    (command.FuncDef
      name: try_repo
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:name spids:[839])
                      op: Equal
                      rhs: {($ VSub_Number '$1')}
                      spids: [839]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:worktreeenv spids:[842])
                      op: Equal
                      rhs: {($ VSub_Number '$2')}
                      spids: [842]
                    )
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:gitdirenv spids:[845])
                      op: Equal
                      rhs: {($ VSub_Number '$3')}
                      spids: [845]
                    )
                  ]
                  spids: [839]
                )
                (C {(setup_repo)} {(DQ ($ VSub_Name '$name'))} {(DQ ($ VSub_Number '$4'))} 
                  {(DQ ($ VSub_Number '$5'))} {(DQ ($ VSub_Number '$6'))}
                )
                (C {(shift)} {(6)})
                (C {(try_case)} {(DQ ($ VSub_Name '$name'))} {(DQ ($ VSub_Name '$worktreeenv'))} 
                  {(DQ ($ VSub_Name '$gitdirenv'))} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))} {(DQ ($ VSub_Number '$3'))} 
                  {(DQ ($ VSub_Number '$4'))}
                )
                (C {(shift)} {(4)})
                (command.Case
                  to_match: {(DQ ($ VSub_Name '$gitdirenv'))}
                  arms: [
                    (case_arm
                      pat_list: [
                        {(/) (Lit_Other '*')}
                        {(Lit_Other '?') (Lit_Other ':') (/) (Lit_Other '*')}
                        {(unset)}
                      ]
                      spids: [930 943 945 16777215]
                    )
                    (case_arm
                      pat_list: [{(Lit_Other '*')}]
                      action: [
                        (command.Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (lhs_expr.LhsName name:gitdirenv spids:[952])
                              op: Equal
                              rhs: {(../) ($ VSub_Name '$gitdirenv')}
                              spids: [952]
                            )
                          ]
                          spids: [952]
                        )
                      ]
                      spids: [948 949 956 16777215]
                    )
                  ]
                  spids: [921 927 959]
                )
                (C {(try_case)} {(DQ ($ VSub_Name '$name') (/sub))} {(DQ ($ VSub_Name '$worktreeenv'))} 
                  {(DQ ($ VSub_Name '$gitdirenv'))} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))} {(DQ ($ VSub_Number '$3'))} 
                  {(DQ ($ VSub_Number '$4'))}
                )
              ]
            )
          ]
          spids: [836]
        )
      spids: [831 835]
    )
    (C {(test_expect_success)} {(SQ <'#0: nonbare repo, no explicit configuration'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 0 unset unset unset "" unset \\\n'> 
          <'\t\t.git "$here/0" "$here/0" "(null)" \\\n'> <'\t\t.git "$here/0" "$here/0" sub/ 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#1: GIT_WORK_TREE without explicit GIT_DIR is accepted'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p wt &&\n'> <'\ttry_repo 1 "$here" unset unset "" unset \\\n'> 
          <'\t\t"$here/1/.git" "$here" "$here" 1/ \\\n'> <'\t\t"$here/1/.git" "$here" "$here" 1/sub/ 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#2: worktree defaults to cwd with explicit GIT_DIR'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 2 unset "$here/2/.git" unset "" unset \\\n'> 
          <'\t\t"$here/2/.git" "$here/2" "$here/2" "(null)" \\\n'> <'\t\t"$here/2/.git" "$here/2/sub" "$here/2/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#2b: relative GIT_DIR'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 2b unset ".git" unset "" unset \\\n'> 
          <'\t\t".git" "$here/2b" "$here/2b" "(null)" \\\n'> <'\t\t"../.git" "$here/2b/sub" "$here/2b/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#3: setup'>)} 
      {(SQ <'\n'> <'\tsetup_repo 3 unset "" unset &&\n'> <'\tmkdir -p 3/sub/sub 3/wt/sub\n'>)}
    )
    (C {(run_wt_tests)} {(3)})
    (C {(test_expect_success)} {(SQ <'#4: core.worktree without GIT_DIR set is accepted'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 4 ../sub "" unset &&\n'> <'\tmkdir -p 4/sub sub &&\n'> 
          <'\ttry_case 4 unset unset \\\n'> <'\t\t.git "$here/4/sub" "$here/4" "(null)" \\\n'> 
          <'\t\t"$here/4/.git" "$here/4/sub" "$here/4/sub" "(null)" 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#5: core.worktree + GIT_WORK_TREE is accepted'>)} 
      {
        (SQ <'\n'> <'\t# or: you cannot intimidate away the lack of GIT_DIR setting\n'> 
          <'\ttry_repo 5 "$here" unset "$here/5" "" unset \\\n'> <'\t\t"$here/5/.git" "$here" "$here" 5/ \\\n'> 
          <'\t\t"$here/5/.git" "$here" "$here" 5/sub/ 2>message &&\n'> <'\ttry_repo 5a .. unset "$here/5a" "" unset \\\n'> <'\t\t"$here/5a/.git" "$here" "$here" 5a/ \\\n'> 
          <'\t\t"$here/5a/.git" "$here/5a" "$here/5a" sub/ &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6: setting GIT_DIR brings core.worktree to life'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6 "$here/6" "" unset &&\n'> <'\ttry_case 6 unset .git \\\n'> 
          <'\t\t.git "$here/6" "$here/6" "(null)" &&\n'> <'\ttry_case 6 unset "$here/6/.git" \\\n'> <'\t\t"$here/6/.git" "$here/6" "$here/6" "(null)" &&\n'> 
          <'\ttry_case 6/sub/sub unset ../../.git \\\n'> <'\t\t"$here/6/.git" "$here/6" "$here/6" sub/sub/ &&\n'> 
          <'\ttry_case 6/sub/sub unset "$here/6/.git" \\\n'> <'\t\t"$here/6/.git" "$here/6" "$here/6" sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6b: GIT_DIR set, core.worktree relative'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6b .. "" unset &&\n'> <'\ttry_case 6b unset .git \\\n'> 
          <'\t\t.git "$here/6b" "$here/6b" "(null)" &&\n'> <'\ttry_case 6b unset "$here/6b/.git" \\\n'> 
          <'\t\t"$here/6b/.git" "$here/6b" "$here/6b" "(null)" &&\n'> <'\ttry_case 6b/sub/sub unset ../../.git \\\n'> 
          <'\t\t"$here/6b/.git" "$here/6b" "$here/6b" sub/sub/ &&\n'> <'\ttry_case 6b/sub/sub unset "$here/6b/.git" \\\n'> 
          <'\t\t"$here/6b/.git" "$here/6b" "$here/6b" sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6c: GIT_DIR set, core.worktree=../wt (absolute)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6c "$here/6c/wt" "" unset &&\n'> <'\tmkdir -p 6c/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 6c unset .git \\\n'> <'\t\t.git "$here/6c/wt" "$here/6c" "(null)" &&\n'> <'\ttry_case 6c unset "$here/6c/.git" \\\n'> 
          <'\t\t"$here/6c/.git" "$here/6c/wt" "$here/6c" "(null)" &&\n'> <'\ttry_case 6c/sub/sub unset ../../.git \\\n'> 
          <'\t\t../../.git "$here/6c/wt" "$here/6c/sub/sub" "(null)" &&\n'> <'\ttry_case 6c/sub/sub unset "$here/6c/.git" \\\n'> 
          <'\t\t"$here/6c/.git" "$here/6c/wt" "$here/6c/sub/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6d: GIT_DIR set, core.worktree=../wt (relative)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6d "$here/6d/wt" "" unset &&\n'> <'\tmkdir -p 6d/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 6d unset .git \\\n'> <'\t\t.git "$here/6d/wt" "$here/6d" "(null)" &&\n'> <'\ttry_case 6d unset "$here/6d/.git" \\\n'> 
          <'\t\t"$here/6d/.git" "$here/6d/wt" "$here/6d" "(null)" &&\n'> <'\ttry_case 6d/sub/sub unset ../../.git \\\n'> 
          <'\t\t../../.git "$here/6d/wt" "$here/6d/sub/sub" "(null)" &&\n'> <'\ttry_case 6d/sub/sub unset "$here/6d/.git" \\\n'> 
          <'\t\t"$here/6d/.git" "$here/6d/wt" "$here/6d/sub/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6e: GIT_DIR set, core.worktree=../.. (absolute)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6e "$here" "" unset &&\n'> <'\ttry_case 6e unset .git \\\n'> 
          <'\t\t"$here/6e/.git" "$here" "$here" 6e/ &&\n'> <'\ttry_case 6e unset "$here/6e/.git" \\\n'> <'\t\t"$here/6e/.git" "$here" "$here" 6e/ &&\n'> 
          <'\ttry_case 6e/sub/sub unset ../../.git \\\n'> <'\t\t"$here/6e/.git" "$here" "$here" 6e/sub/sub/ &&\n'> 
          <'\ttry_case 6e/sub/sub unset "$here/6e/.git" \\\n'> <'\t\t"$here/6e/.git" "$here" "$here" 6e/sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#6f: GIT_DIR set, core.worktree=../.. (relative)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 6f ../../ "" unset &&\n'> <'\ttry_case 6f unset .git \\\n'> 
          <'\t\t"$here/6f/.git" "$here" "$here" 6f/ &&\n'> <'\ttry_case 6f unset "$here/6f/.git" \\\n'> <'\t\t"$here/6f/.git" "$here" "$here" 6f/ &&\n'> 
          <'\ttry_case 6f/sub/sub unset ../../.git \\\n'> <'\t\t"$here/6f/.git" "$here" "$here" 6f/sub/sub/ &&\n'> 
          <'\ttry_case 6f/sub/sub unset "$here/6f/.git" \\\n'> <'\t\t"$here/6f/.git" "$here" "$here" 6f/sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#7: setup'>)} 
      {(SQ <'\n'> <'\tsetup_repo 7 non-existent "" unset &&\n'> <'\tmkdir -p 7/sub/sub 7/wt/sub\n'>)}
    )
    (C {(run_wt_tests)} {(7)})
    (C {(test_expect_success)} {(SQ <'#8: gitfile, easy case'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 8 unset unset unset gitfile unset \\\n'> 
          <'\t\t"$here/8.git" "$here/8" "$here/8" "(null)" \\\n'> <'\t\t"$here/8.git" "$here/8" "$here/8" sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#9: GIT_WORK_TREE accepted with gitfile'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p 9/wt &&\n'> <'\ttry_repo 9 wt unset unset gitfile unset \\\n'> 
          <'\t\t"$here/9.git" "$here/9/wt" "$here/9" "(null)" \\\n'> <'\t\t"$here/9.git" "$here/9/sub/wt" "$here/9/sub" "(null)" 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#10: GIT_DIR can point to gitfile'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 10 unset "$here/10/.git" unset gitfile unset \\\n'> 
          <'\t\t"$here/10.git" "$here/10" "$here/10" "(null)" \\\n'> <'\t\t"$here/10.git" "$here/10/sub" "$here/10/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#10b: relative GIT_DIR can point to gitfile'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 10b unset .git unset gitfile unset \\\n'> 
          <'\t\t"$here/10b.git" "$here/10b" "$here/10b" "(null)" \\\n'> <'\t\t"$here/10b.git" "$here/10b/sub" "$here/10b/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#11: setup'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 11 unset gitfile unset &&\n'> <'\tmkdir -p 11/sub/sub 11/wt/sub\n'>)
      }
    )
    (C {(run_wt_tests)} {(11)} {(gitfile)})
    (C {(test_expect_success)} {(SQ <'#12: core.worktree with gitfile is accepted'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 12 unset unset "$here/12" gitfile unset \\\n'> 
          <'\t\t"$here/12.git" "$here/12" "$here/12" "(null)" \\\n'> <'\t\t"$here/12.git" "$here/12" "$here/12" sub/ 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)'>)} 
      {
        (SQ <'\n'> <'\t# or: you cannot intimidate away the lack of GIT_DIR setting\n'> 
          <'\ttry_repo 13 non-existent-too unset non-existent gitfile unset \\\n'> <'\t\t"$here/13.git" "$here/13/non-existent-too" "$here/13" "(null)" \\\n'> 
          <
'\t\t"$here/13.git" "$here/13/sub/non-existent-too" "$here/13/sub" "(null)" 2>message &&\n'
          > <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#14: core.worktree with GIT_DIR pointing to gitfile'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 14 "$here/14" gitfile unset &&\n'> <'\ttry_case 14 unset .git \\\n'> 
          <'\t\t"$here/14.git" "$here/14" "$here/14" "(null)" &&\n'> <'\ttry_case 14 unset "$here/14/.git" \\\n'> 
          <'\t\t"$here/14.git" "$here/14" "$here/14" "(null)" &&\n'> <'\ttry_case 14/sub/sub unset ../../.git \\\n'> 
          <'\t\t"$here/14.git" "$here/14" "$here/14" sub/sub/ &&\n'> <'\ttry_case 14/sub/sub unset "$here/14/.git" \\\n'> 
          <'\t\t"$here/14.git" "$here/14" "$here/14" sub/sub/ &&\n'> <'\n'> <'\tsetup_repo 14c "$here/14c/wt" gitfile unset &&\n'> <'\tmkdir -p 14c/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 14c unset .git \\\n'> <'\t\t"$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&\n'> 
          <'\ttry_case 14c unset "$here/14c/.git" \\\n'> <'\t\t"$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&\n'> 
          <'\ttry_case 14c/sub/sub unset ../../.git \\\n'> <'\t\t"$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&\n'> 
          <'\ttry_case 14c/sub/sub unset "$here/14c/.git" \\\n'> <'\t\t"$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&\n'> <'\n'> 
          <'\tsetup_repo 14d "$here/14d/wt" gitfile unset &&\n'> <'\tmkdir -p 14d/wt/sub &&\n'> <'\n'> <'\ttry_case 14d unset .git \\\n'> 
          <'\t\t"$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&\n'> <'\ttry_case 14d unset "$here/14d/.git" \\\n'> 
          <'\t\t"$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&\n'> <'\ttry_case 14d/sub/sub unset ../../.git \\\n'> 
          <'\t\t"$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&\n'> <'\ttry_case 14d/sub/sub unset "$here/14d/.git" \\\n'> 
          <'\t\t"$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&\n'> <'\n'> <'\tsetup_repo 14e "$here" gitfile unset &&\n'> <'\ttry_case 14e unset .git \\\n'> 
          <'\t\t"$here/14e.git" "$here" "$here" 14e/ &&\n'> <'\ttry_case 14e unset "$here/14e/.git" \\\n'> <'\t\t"$here/14e.git" "$here" "$here" 14e/ &&\n'> 
          <'\ttry_case 14e/sub/sub unset ../../.git \\\n'> <'\t\t"$here/14e.git" "$here" "$here" 14e/sub/sub/ &&\n'> 
          <'\ttry_case 14e/sub/sub unset "$here/14e/.git" \\\n'> <'\t\t"$here/14e.git" "$here" "$here" 14e/sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#14b: core.worktree is relative to actual git dir'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 14b ../14b gitfile unset &&\n'> <'\ttry_case 14b unset .git \\\n'> 
          <'\t\t"$here/14b.git" "$here/14b" "$here/14b" "(null)" &&\n'> <'\ttry_case 14b unset "$here/14b/.git" \\\n'> 
          <'\t\t"$here/14b.git" "$here/14b" "$here/14b" "(null)" &&\n'> <'\ttry_case 14b/sub/sub unset ../../.git \\\n'> 
          <'\t\t"$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&\n'> <'\ttry_case 14b/sub/sub unset "$here/14b/.git" \\\n'> 
          <'\t\t"$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&\n'> <'\n'> <'\tsetup_repo 14f ../ gitfile unset &&\n'> <'\ttry_case 14f unset .git \\\n'> 
          <'\t\t"$here/14f.git" "$here" "$here" 14f/ &&\n'> <'\ttry_case 14f unset "$here/14f/.git" \\\n'> <'\t\t"$here/14f.git" "$here" "$here" 14f/ &&\n'> 
          <'\ttry_case 14f/sub/sub unset ../../.git \\\n'> <'\t\t"$here/14f.git" "$here" "$here" 14f/sub/sub/ &&\n'> 
          <'\ttry_case 14f/sub/sub unset "$here/14f/.git" \\\n'> <'\t\t"$here/14f.git" "$here" "$here" 14f/sub/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#15: setup'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 15 non-existent gitfile unset &&\n'> 
          <'\tmkdir -p 15/sub/sub 15/wt/sub\n'>
        )
      }
    )
    (C {(run_wt_tests)} {(15)} {(gitfile)})
    (C {(test_expect_success)} {(SQ <'#16a: implicitly bare repo (cwd inside .git dir)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 16a unset "" unset &&\n'> <'\tmkdir -p 16a/.git/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 16a/.git unset unset \\\n'> <'\t\t. "(null)" "$here/16a/.git" "(null)" &&\n'> <'\ttry_case 16a/.git/wt unset unset \\\n'> 
          <'\t\t"$here/16a/.git" "(null)" "$here/16a/.git/wt" "(null)" &&\n'> <'\ttry_case 16a/.git/wt/sub unset unset \\\n'> 
          <'\t\t"$here/16a/.git" "(null)" "$here/16a/.git/wt/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#16b: bare .git (cwd inside .git dir)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 16b unset "" true &&\n'> <'\tmkdir -p 16b/.git/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 16b/.git unset unset \\\n'> <'\t\t. "(null)" "$here/16b/.git" "(null)" &&\n'> <'\ttry_case 16b/.git/wt unset unset \\\n'> 
          <'\t\t"$here/16b/.git" "(null)" "$here/16b/.git/wt" "(null)" &&\n'> <'\ttry_case 16b/.git/wt/sub unset unset \\\n'> 
          <'\t\t"$here/16b/.git" "(null)" "$here/16b/.git/wt/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#16c: bare .git has no worktree'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 16c unset unset unset "" true \\\n'> 
          <'\t\t.git "(null)" "$here/16c" "(null)" \\\n'> <'\t\t"$here/16c/.git" "(null)" "$here/16c/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#16d: bareness preserved across alias'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 16d unset "" unset &&\n'> <'\t(\n'> <'\t\tcd 16d/.git &&\n'> 
          <'\t\ttest_must_fail git status &&\n'> <'\t\tgit config alias.st status &&\n'> <'\t\ttest_must_fail git st\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#16e: bareness preserved by --bare'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 16e unset "" unset &&\n'> <'\t(\n'> <'\t\tcd 16e/.git &&\n'> 
          <'\t\ttest_must_fail git status &&\n'> <'\t\ttest_must_fail git --bare status\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'#17: GIT_WORK_TREE without explicit GIT_DIR is accepted (bare case)'>)} 
      {
        (SQ <'\n'> <'\t# Just like #16.\n'> <'\tsetup_repo 17a unset "" true &&\n'> 
          <'\tsetup_repo 17b unset "" true &&\n'> <'\tmkdir -p 17a/.git/wt/sub &&\n'> <'\tmkdir -p 17b/.git/wt/sub &&\n'> <'\n'> 
          <'\ttry_case 17a/.git "$here/17a" unset \\\n'> <'\t\t"$here/17a/.git" "$here/17a" "$here/17a" .git/ \\\n'> <'\t\t2>message &&\n'> 
          <'\ttry_case 17a/.git/wt "$here/17a" unset \\\n'> <'\t\t"$here/17a/.git" "$here/17a" "$here/17a" .git/wt/ &&\n'> 
          <'\ttry_case 17a/.git/wt/sub "$here/17a" unset \\\n'> <'\t\t"$here/17a/.git" "$here/17a" "$here/17a" .git/wt/sub/ &&\n'> <'\n'> 
          <'\ttry_case 17b/.git "$here/17b" unset \\\n'> <'\t\t"$here/17b/.git" "$here/17b" "$here/17b" .git/ &&\n'> 
          <'\ttry_case 17b/.git/wt "$here/17b" unset \\\n'> <'\t\t"$here/17b/.git" "$here/17b" "$here/17b" .git/wt/ &&\n'> 
          <'\ttry_case 17b/.git/wt/sub "$here/17b" unset \\\n'> <'\t\t"$here/17b/.git" "$here/17b" "$here/17b" .git/wt/sub/ &&\n'> <'\n'> 
          <'\ttry_repo 17c "$here/17c" unset unset "" true \\\n'> <'\t\t.git "$here/17c" "$here/17c" "(null)" \\\n'> 
          <'\t\t"$here/17c/.git" "$here/17c" "$here/17c" sub/ 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#18: bare .git named by GIT_DIR has no worktree'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 18 unset .git unset "" true \\\n'> 
          <'\t\t.git "(null)" "$here/18" "(null)" \\\n'> <'\t\t../.git "(null)" "$here/18/sub" "(null)" &&\n'> 
          <'\ttry_repo 18b unset "$here/18b/.git" unset "" true \\\n'> <'\t\t"$here/18b/.git" "(null)" "$here/18b" "(null)" \\\n'> 
          <'\t\t"$here/18b/.git" "(null)" "$here/18b/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#19: setup'>)} 
      {(SQ <'\n'> <'\tsetup_repo 19 unset "" true &&\n'> <'\tmkdir -p 19/sub/sub 19/wt/sub\n'>)}
    )
    (C {(run_wt_tests)} {(19)})
    (C {(test_expect_success)} {(SQ <'#20a: core.worktree without GIT_DIR accepted (inside .git)'>)} 
      {
        (SQ <'\n'> <'\t# Unlike case #16a.\n'> <'\tsetup_repo 20a "$here/20a" "" unset &&\n'> 
          <'\tmkdir -p 20a/.git/wt/sub &&\n'> <'\ttry_case 20a/.git unset unset \\\n'> 
          <'\t\t"$here/20a/.git" "$here/20a" "$here/20a" .git/ 2>message &&\n'> <'\ttry_case 20a/.git/wt unset unset \\\n'> 
          <'\t\t"$here/20a/.git" "$here/20a" "$here/20a" .git/wt/ &&\n'> <'\ttry_case 20a/.git/wt/sub unset unset \\\n'> 
          <'\t\t"$here/20a/.git" "$here/20a" "$here/20a" .git/wt/sub/ &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#20b/c: core.worktree and core.bare conflict'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 20b non-existent "" true &&\n'> <'\tmkdir -p 20b/.git/wt/sub &&\n'> 
          <'\t(\n'> <'\t\tcd 20b/.git &&\n'> <'\t\ttest_must_fail git status >/dev/null\n'> <'\t) 2>message &&\n'> 
          <'\tgrep "core.bare and core.worktree" message\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'#20d: core.worktree and core.bare OK when working tree not needed'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 20d non-existent "" true &&\n'> <'\tmkdir -p 20d/.git/wt/sub &&\n'> 
          <'\t(\n'> <'\t\tcd 20d/.git &&\n'> <'\t\tgit config foo.bar value\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#21: setup, core.worktree warns before overriding core.bare'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 21 non-existent "" unset &&\n'> <'\tmkdir -p 21/.git/wt/sub &&\n'> 
          <'\t(\n'> <'\t\tcd 21/.git &&\n'> <'\t\tGIT_WORK_TREE="$here/21" &&\n'> <'\t\texport GIT_WORK_TREE &&\n'> 
          <'\t\tgit status >/dev/null\n'> <'\t) 2>message &&\n'> <'\t! test -s message\n'> <'\n'>
        )
      }
    )
    (C {(run_wt_tests)} {(21)})
    (C {(test_expect_success)} {(SQ <'#22a: core.worktree = GIT_DIR = .git dir'>)} 
      {
        (SQ <'\n'> <'\t# like case #6.\n'> <'\n'> <'\tsetup_repo 22a "$here/22a/.git" "" unset &&\n'> 
          <'\tsetup_repo 22ab . "" unset &&\n'> <'\tmkdir -p 22a/.git/sub 22a/sub &&\n'> <'\tmkdir -p 22ab/.git/sub 22ab/sub &&\n'> 
          <'\ttry_case 22a/.git unset . \\\n'> <'\t\t. "$here/22a/.git" "$here/22a/.git" "(null)" &&\n'> 
          <'\ttry_case 22a/.git unset "$here/22a/.git" \\\n'> <'\t\t"$here/22a/.git" "$here/22a/.git" "$here/22a/.git" "(null)" &&\n'> 
          <'\ttry_case 22a/.git/sub unset .. \\\n'> <'\t\t"$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&\n'> 
          <'\ttry_case 22a/.git/sub unset "$here/22a/.git" \\\n'> <'\t\t"$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&\n'> <'\n'> 
          <'\ttry_case 22ab/.git unset . \\\n'> <'\t\t. "$here/22ab/.git" "$here/22ab/.git" "(null)" &&\n'> 
          <'\ttry_case 22ab/.git unset "$here/22ab/.git" \\\n'> <'\t\t"$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)" &&\n'> 
          <'\ttry_case 22ab/.git/sub unset .. \\\n'> <'\t\t"$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" sub/ &&\n'> 
          <'\ttry_case 22ab/.git unset "$here/22ab/.git" \\\n'> <'\t\t"$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#22b: core.worktree child of .git, GIT_DIR=.git'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 22b "$here/22b/.git/wt" "" unset &&\n'> 
          <'\tsetup_repo 22bb wt "" unset &&\n'> <'\tmkdir -p 22b/.git/sub 22b/sub 22b/.git/wt/sub 22b/wt/sub &&\n'> 
          <'\tmkdir -p 22bb/.git/sub 22bb/sub 22bb/.git/wt 22bb/wt &&\n'> <'\n'> <'\ttry_case 22b/.git unset . \\\n'> 
          <'\t\t. "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&\n'> <'\ttry_case 22b/.git unset "$here/22b/.git" \\\n'> 
          <'\t\t"$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&\n'> <'\ttry_case 22b/.git/sub unset .. \\\n'> 
          <'\t\t.. "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&\n'> <'\ttry_case 22b/.git/sub unset "$here/22b/.git" \\\n'> 
          <'\t\t"$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&\n'> <'\n'> <'\ttry_case 22bb/.git unset . \\\n'> 
          <'\t\t. "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&\n'> <'\ttry_case 22bb/.git unset "$here/22bb/.git" \\\n'> 
          <'\t\t"$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&\n'> <'\ttry_case 22bb/.git/sub unset .. \\\n'> 
          <'\t\t.. "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)" &&\n'> <'\ttry_case 22bb/.git/sub unset "$here/22bb/.git" \\\n'> 
          <'\t\t"$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#22c: core.worktree = .git/.., GIT_DIR=.git'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 22c "$here/22c" "" unset &&\n'> 
          <'\tsetup_repo 22cb .. "" unset &&\n'> <'\tmkdir -p 22c/.git/sub 22c/sub &&\n'> <'\tmkdir -p 22cb/.git/sub 22cb/sub &&\n'> <'\n'> 
          <'\ttry_case 22c/.git unset . \\\n'> <'\t\t"$here/22c/.git" "$here/22c" "$here/22c" .git/ &&\n'> 
          <'\ttry_case 22c/.git unset "$here/22c/.git" \\\n'> <'\t\t"$here/22c/.git" "$here/22c" "$here/22c" .git/ &&\n'> <'\ttry_case 22c/.git/sub unset .. \\\n'> 
          <'\t\t"$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&\n'> <'\ttry_case 22c/.git/sub unset "$here/22c/.git" \\\n'> 
          <'\t\t"$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&\n'> <'\n'> <'\ttry_case 22cb/.git unset . \\\n'> 
          <'\t\t"$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&\n'> <'\ttry_case 22cb/.git unset "$here/22cb/.git" \\\n'> 
          <'\t\t"$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&\n'> <'\ttry_case 22cb/.git/sub unset .. \\\n'> 
          <'\t\t"$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/ &&\n'> <'\ttry_case 22cb/.git/sub unset "$here/22cb/.git" \\\n'> 
          <'\t\t"$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#22.2: core.worktree and core.bare conflict'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 22 "$here/22" "" true &&\n'> <'\t(\n'> <'\t\tcd 22/.git &&\n'> 
          <'\t\tGIT_DIR=. &&\n'> <'\t\texport GIT_DIR &&\n'> <'\t\ttest_must_fail git status 2>result\n'> <'\t) &&\n'> <'\t(\n'> 
          <'\t\tcd 22 &&\n'> <'\t\tGIT_DIR=.git &&\n'> <'\t\texport GIT_DIR &&\n'> <'\t\ttest_must_fail git status 2>result\n'> 
          <'\t) &&\n'> <'\tgrep "core.bare and core.worktree" 22/.git/result &&\n'> 
          <'\tgrep "core.bare and core.worktree" 22/result\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#23: setup'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 23 non-existent "" true &&\n'> <'\tmkdir -p 23/sub/sub 23/wt/sub\n'>)
      }
    )
    (C {(run_wt_tests)} {(23)})
    (C {(test_expect_success)} {(SQ <'#24: bare repo has no worktree (gitfile case)'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 24 unset unset unset gitfile true \\\n'> 
          <'\t\t"$here/24.git" "(null)" "$here/24" "(null)" \\\n'> <'\t\t"$here/24.git" "(null)" "$here/24/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'#25: GIT_WORK_TREE accepted if GIT_DIR unset (bare gitfile case)'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 25 "$here/25" unset unset gitfile true \\\n'> 
          <'\t\t"$here/25.git" "$here/25" "$here/25" "(null)"  \\\n'> <'\t\t"$here/25.git" "$here/25" "$here/25" "sub/" 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#26: bare repo has no worktree (GIT_DIR -> gitfile case)'>)} 
      {
        (SQ <'\n'> <'\ttry_repo 26 unset "$here/26/.git" unset gitfile true \\\n'> 
          <'\t\t"$here/26.git" "(null)" "$here/26" "(null)" \\\n'> <'\t\t"$here/26.git" "(null)" "$here/26/sub" "(null)" &&\n'> 
          <'\ttry_repo 26b unset .git unset gitfile true \\\n'> <'\t\t"$here/26b.git" "(null)" "$here/26b" "(null)" \\\n'> 
          <'\t\t"$here/26b.git" "(null)" "$here/26b/sub" "(null)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#27: setup'>)} 
      {(SQ <'\n'> <'\tsetup_repo 27 unset gitfile true &&\n'> <'\tmkdir -p 27/sub/sub 27/wt/sub\n'>)}
    )
    (C {(run_wt_tests)} {(27)} {(gitfile)})
    (C {(test_expect_success)} {(SQ <'#28: core.worktree and core.bare conflict (gitfile case)'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 28 "$here/28" gitfile true &&\n'> <'\t(\n'> <'\t\tcd 28 &&\n'> 
          <'\t\ttest_must_fail git status\n'> <'\t) 2>message &&\n'> <'\tgrep "core.bare and core.worktree" message\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#29: setup'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 29 non-existent gitfile true &&\n'> 
          <'\tmkdir -p 29/sub/sub 29/wt/sub &&\n'> <'\t(\n'> <'\t\tcd 29 &&\n'> <'\t\tGIT_WORK_TREE="$here/29" &&\n'> <'\t\texport GIT_WORK_TREE &&\n'> 
          <'\t\tgit status\n'> <'\t) 2>message &&\n'> <'\t! test -s message\n'>
        )
      }
    )
    (C {(run_wt_tests)} {(29)} {(gitfile)})
    (C {(test_expect_success)} {(SQ <'#30: core.worktree and core.bare conflict (gitfile version)'>)} 
      {
        (SQ <'\n'> <'\t# Just like case #22.\n'> <'\tsetup_repo 30 "$here/30" gitfile true &&\n'> 
          <'\t(\n'> <'\t\tcd 30 &&\n'> <'\t\ttest_must_fail env GIT_DIR=.git git status 2>result\n'> <'\t) &&\n'> 
          <'\tgrep "core.bare and core.worktree" 30/result\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'#31: setup'>)} 
      {
        (SQ <'\n'> <'\tsetup_repo 31 non-existent gitfile true &&\n'> 
          <'\tmkdir -p 31/sub/sub 31/wt/sub\n'>
        )
      }
    )
    (C {(run_wt_tests)} {(31)} {(gitfile)})
    (C {(test_done)})
  ]
)