(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'git p4 client view'>)}
        )
      ]
    )
    (C {(.)} {(./lib-git-p4.sh)})
    (C {(test_expect_success)} {(SQ <'start p4d'>)} {(SQ <'\n'> <'\tstart_p4d\n'>)})
    (command.FuncDef
      name: check_files_exist
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Assignment
                  keyword: Assign_None
                  pairs: [(assign_pair lhs:(lhs_expr.LhsName name:ok) op:Equal rhs:{(0)})]
                )
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:num)
                      op: Equal
                      rhs: {($ VSub_Pound '$#')}
                    )
                  ]
                )
                (command.ForEach
                  iter_name: arg
                  do_arg_iter: T
                  body: 
                    (command.DoGroup
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(test_path_is_file)} {(DQ ($ VSub_DollarName '$arg'))})
                            (command.Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:ok)
                                  op: Equal
                                  rhs: 
                                    {
                                      (word_part.ArithSubPart
                                        anode: 
                                          (arith_expr.ArithBinary
                                            op_id: Arith_Plus
                                            left: (arith_expr.ArithWord w:{($ VSub_DollarName '$ok')})
                                            right: (arith_expr.ArithWord w:{(Lit_Digits 1)})
                                          )
                                      )
                                    }
                                )
                              ]
                            )
                          ]
                        )
                      ]
                    )
                )
                (C {(test)} {($ VSub_DollarName '$ok')} {(-eq)} {($ VSub_DollarName '$num')})
                (C {(test_line_count)} {(Lit_Other '=')} {($ VSub_DollarName '$num')} {(files)})
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: client_verify
      body: 
        (command.BraceGroup
          children: [
            (command.Subshell
              command_list: 
                (command.CommandList
                  children: [
                    (command.AndOr
                      ops: [Op_DAmp Op_DAmp Op_DAmp]
                      children: [
                        (C {(cd)} {(DQ ($ VSub_DollarName '$cli'))})
                        (C {(p4)} {(sync)})
                        (command.SimpleCommand
                          words: [{(find)} {(.)} {(-type)} {(f)} {(KW_Bang '!')} {(-name)} {(files)}]
                          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(files)})]
                        )
                        (C {(check_files_exist)} {(DQ ($ VSub_At '$@'))})
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.FuncDef
      name: git_verify
      body: 
        (command.BraceGroup
          children: [
            (command.Subshell
              command_list: 
                (command.CommandList
                  children: [
                    (command.AndOr
                      ops: [Op_DAmp Op_DAmp]
                      children: [
                        (C {(cd)} {(DQ ($ VSub_DollarName '$git'))})
                        (command.SimpleCommand
                          words: [{(git)} {(ls-files)}]
                          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(files)})]
                        )
                        (C {(check_files_exist)} {(DQ ($ VSub_At '$@'))})
                      ]
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.FuncDef
      name: init_depot
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (command.ForEach
                  iter_name: d
                  iter_words: [{(1)} {(2)}]
                  do_arg_iter: F
                  body: 
                    (command.DoGroup
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(mkdir)} {(-p)} {(dir) ($ VSub_DollarName '$d')})
                            (command.ForEach
                              iter_name: f
                              iter_words: [{(1)} {(2)}]
                              do_arg_iter: F
                              body: 
                                (command.DoGroup
                                  children: [
                                    (command.AndOr
                                      ops: [Op_DAmp Op_DAmp]
                                      children: [
                                        (command.SimpleCommand
                                          words: [
                                            {(echo)}
                                            {(dir) ($ VSub_DollarName '$d') (/file) 
                                              ($ VSub_DollarName '$d') ($ VSub_DollarName '$f')
                                            }
                                          ]
                                          redirects: [
                                            (redir.Redir
                                              op: <Redir_Great '>'>
                                              fd: 16777215
                                              arg_word: 
                                                {(dir) ($ VSub_DollarName '$d') (/file) 
                                                  ($ VSub_DollarName '$d') ($ VSub_DollarName '$f')
                                                }
                                            )
                                          ]
                                        )
                                        (C {(p4)} {(add)} 
                                          {(dir) ($ VSub_DollarName '$d') (/file) 
                                            ($ VSub_DollarName '$d') ($ VSub_DollarName '$f')
                                          }
                                        )
                                        (C {(p4)} {(submit)} {(-d)} 
                                          {
                                            (DQ (dir) ($ VSub_DollarName '$d') (/file) 
                                              ($ VSub_DollarName '$d') ($ VSub_DollarName '$f')
                                            )
                                          }
                                        )
                                      ]
                                    )
                                  ]
                                )
                            )
                          ]
                        )
                      ]
                    )
                )
                (command.SimpleCommand
                  words: [{(find)} {(.)} {(-type)} {(f)} {(KW_Bang '!')} {(-name)} {(files)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(files)})]
                )
                (C {(check_files_exist)} {(dir1/file11)} {(dir1/file12)} {(dir2/file21)} {(dir2/file22)})
              ]
            )
          ]
        )
    )
    (C {(test_expect_success)} {(SQ <'init depot'>)} 
      {(SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tinit_depot\n'> <'\t)\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'view wildcard %%n'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/%%%%1/sub/... //client/sub/%%%%1/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'view wildcard *'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/*/bar/... //client/*/bar/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'wildcard ... in the middle'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/.../file11 //client/.../file11" &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'wildcard ... in the middle and at the end'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/.../a/... //client/.../a/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'basic map'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/cli1/..." &&\n'> 
          <'\tfiles="cli1/file11 cli1/file12" &&\n'> <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'client view with no mappings'>)} 
      {
        (SQ <'\n'> <'\tclient_view &&\n'> <'\tclient_verify &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'single file map'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/file11 //client/file11" &&\n'> 
          <'\tfiles="file11" &&\n'> <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'later mapping takes precedence (entire repo)'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/cli1/..." \\\n'> 
          <'\t\t    "//depot/... //client/cli2/..." &&\n'> <'\tfiles="cli2/dir1/file11 cli2/dir1/file12\n'> <'\t       cli2/dir2/file21 cli2/dir2/file22" &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'later mapping takes precedence (partial repo)'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "//depot/dir2/... //client/..." &&\n'> <'\tfiles="file21 file22" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'depot path matching rejected client path'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/cli3/..." \\\n'> 
          <'\t\t    "//depot/dir1/... //client/cli12/..." \\\n'> <'\t\t    "//depot/dir2/... //client/cli12/..." &&\n'> <'\tfiles="cli12/file21 cli12/file22" &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exclusion wildcard, client rhs same (odd)'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." \\\n'> 
          <'\t\t    "-//depot/dir2/... //client/..." &&\n'> <'\tclient_verify &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exclusion wildcard, client rhs different (normal)'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." \\\n'> 
          <'\t\t    "-//depot/dir2/... //client/dir2/..." &&\n'> <'\tfiles="dir1/file11 dir1/file12" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exclusion single file'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." \\\n'> 
          <'\t\t    "-//depot/dir2/file22 //client/file22" &&\n'> <'\tfiles="dir1/file11 dir1/file12 dir2/file21" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay wildcard'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/cli/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/cli/..." &&\n'> <'\tfiles="cli/file11 cli/file12 cli/file21 cli/file22" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay single file'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/cli/..." \\\n'> 
          <'\t\t    "+//depot/dir2/file21 //client/cli/file21" &&\n'> <'\tfiles="cli/file11 cli/file12 cli/file21" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exclusion with later inclusion'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." \\\n'> 
          <'\t\t    "-//depot/dir2/... //client/dir2/..." \\\n'> <'\t\t    "//depot/dir2/... //client/dir2incl/..." &&\n'> 
          <'\tfiles="dir1/file11 dir1/file12 dir2incl/file21 dir2incl/file22" &&\n'> <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'quotes on rhs only'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... \\"//client/cdir 1/...\\"" &&\n'> 
          <'\tclient_verify "cdir 1/file11" "cdir 1/file12" &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify "cdir 1/file11" "cdir 1/file12"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone --use-client-spec sets useClientSpec'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config --bool git-p4.useClientSpec >actual &&\n'> <'\t\techo true >true &&\n'> <'\t\ttest_cmp actual true\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\tfiles="dir1/file11 dir1/file12 dir2/file21 dir2/file22" &&\n'> <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\tgit_verify dir1/file11 dir1/file12\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone, submit modify'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\techo line >>dir1/file12 &&\n'> <'\t\tgit add dir1/file12 &&\n'> 
          <'\t\tgit commit -m dir1/file12 &&\n'> <'\t\tgit p4 submit\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\ttest_path_is_file dir1/file12 &&\n'> <'\t\ttest_line_count = 2 dir1/file12\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone, submit add'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\techo file13 >dir1/file13 &&\n'> <'\t\tgit add dir1/file13 &&\n'> 
          <'\t\tgit commit -m dir1/file13 &&\n'> <'\t\tgit p4 submit\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\ttest_path_is_file dir1/file13\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone, submit delete'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\tgit rm dir1/file12 &&\n'> <'\t\tgit commit -m "delete dir1/file12" &&\n'> <'\t\tgit p4 submit\n'> 
          <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\ttest_path_is_missing dir1/file12\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone, submit copy'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\tgit config git-p4.detectCopies true &&\n'> <'\t\tcp dir1/file11 dir1/file11a &&\n'> 
          <'\t\tgit add dir1/file11a &&\n'> <'\t\tgit commit -m "copy to dir1/file11a" &&\n'> <'\t\tgit p4 submit\n'> <'\t) &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\ttest_path_is_file dir1/file11a &&\n'> <'\t\t! is_cli_file_writeable dir1/file11a\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'subdir clone, submit rename'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> <'\t\tgit config git-p4.detectRenames true &&\n'> <'\t\tgit mv dir1/file13 dir1/file13a &&\n'> 
          <'\t\tgit commit -m "rename dir1/file13 to dir1/file13a" &&\n'> <'\t\tgit p4 submit\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\ttest_path_is_missing dir1/file13 &&\n'> <'\t\ttest_path_is_file dir1/file13a &&\n'> <'\t\t! is_cli_file_writeable dir1/file13a\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'wildcard files submit back to p4, client-spec case'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot/dir1 &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\techo git-wild-hash >dir1/git-wild#hash &&\n'> <'\t\tif test_have_prereq !MINGW,!CYGWIN\n'> <'\t\tthen\n'> 
          <'\t\t\techo git-wild-star >dir1/git-wild\\*star\n'> <'\t\tfi &&\n'> <'\t\techo git-wild-at >dir1/git-wild@at &&\n'> 
          <'\t\techo git-wild-percent >dir1/git-wild%percent &&\n'> <'\t\tgit add dir1/git-wild* &&\n'> <'\t\tgit commit -m "add some wildcard filenames" &&\n'> 
          <'\t\tgit config git-p4.skipSubmitEditCheck true &&\n'> <'\t\tgit p4 submit\n'> <'\t) &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\ttest_path_is_file dir1/git-wild#hash &&\n'> <'\t\tif test_have_prereq !MINGW,!CYGWIN\n'> <'\t\tthen\n'> 
          <'\t\t\ttest_path_is_file dir1/git-wild\\*star\n'> <'\t\tfi &&\n'> <'\t\ttest_path_is_file dir1/git-wild@at &&\n'> 
          <'\t\ttest_path_is_file dir1/git-wild%percent\n'> <'\t) &&\n'> <'\t(\n'> <'\t\t# delete these carefully, cannot just do "p4 delete"\n'> 
          <'\t\t# on files with wildcards; but git-p4 knows how\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit rm dir1/git-wild* &&\n'> 
          <'\t\tgit commit -m "clean up the wildcards" &&\n'> <'\t\tgit p4 submit\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'reinit depot'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\trm files &&\n'> <'\t\tp4 delete */* &&\n'> 
          <'\t\tp4 submit -d "delete all files" &&\n'> <'\t\tinit_depot\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay collision setup'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 sync &&\n'> <'\t\techo dir1/filecollide >dir1/filecollide &&\n'> <'\t\tp4 add dir1/filecollide &&\n'> 
          <'\t\tp4 submit -d dir1/filecollide &&\n'> <'\t\techo dir2/filecollide >dir2/filecollide &&\n'> <'\t\tp4 add dir2/filecollide &&\n'> 
          <'\t\tp4 submit -d dir2/filecollide\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay collision 1 to 2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 filecollide" &&\n'> <'\techo dir2/filecollide >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/filecollide &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files &&\n'> <'\ttest_cmp actual "$git"/filecollide\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'overlay collision 2 to 1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir1/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 filecollide" &&\n'> <'\techo dir1/filecollide >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/filecollide &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files &&\n'> <'\ttest_cmp actual "$git"/filecollide\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay collision delete 2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 sync &&\n'> <'\t\tp4 delete dir2/filecollide &&\n'> <'\t\tp4 submit -d "remove dir2/filecollide"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'overlay collision 1 to 2, but 2 deleted'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay collision update 1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/dir1/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\tp4 open dir1/filecollide &&\n'> 
          <'\t\techo dir1/filecollide update >dir1/filecollide &&\n'> <'\t\tp4 submit -d "update dir1/filecollide"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'overlay collision 1 to 2, but 2 deleted, then 1 updated'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay collision delete filecollides'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 sync &&\n'> <'\t\tp4 delete dir1/filecollide dir2/filecollide &&\n'> <'\t\tp4 submit -d "remove filecollides"\n'> 
          <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: add colA in dir1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/dir1/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir1/colA >dir1/colA &&\n'> <'\t\tp4 add dir1/colA &&\n'> 
          <'\t\tp4 submit -d dir1/colA\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: initial git checkout'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA" &&\n'> <'\techo dir1/colA >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colA &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> 
          <'\tgit_verify $files &&\n'> <'\ttest_cmp actual "$git"/colA\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: add colA in dir2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/dir2/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir2/colA >dir2/colA &&\n'> <'\t\tp4 add dir2/colA &&\n'> 
          <'\t\tp4 submit -d dir2/colA\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: colA content switch'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA" &&\n'> <'\techo dir2/colA >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colA &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit p4 sync --use-client-spec &&\n'> <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> <'\tgit_verify $files &&\n'> 
          <'\ttest_cmp actual "$git"/colA\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: add colB in dir1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/dir1/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir1/colB >dir1/colB &&\n'> <'\t\tp4 add dir1/colB &&\n'> 
          <'\t\tp4 submit -d dir1/colB\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: colB appears'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA colB" &&\n'> <'\techo dir1/colB >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colB &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit p4 sync --use-client-spec &&\n'> <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> <'\tgit_verify $files &&\n'> 
          <'\ttest_cmp actual "$git"/colB\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: add/delete colB in dir2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/dir2/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir2/colB >dir2/colB &&\n'> <'\t\tp4 add dir2/colB &&\n'> 
          <'\t\tp4 submit -d dir2/colB &&\n'> <'\t\tp4 delete dir2/colB &&\n'> <'\t\tp4 submit -d "delete dir2/colB"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: colB disappears'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir2/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA" &&\n'> <'\tclient_verify $files &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit p4 sync --use-client-spec &&\n'> 
          <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> <'\tgit_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync: cleanup'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 sync &&\n'> <'\t\tp4 delete dir1/colA dir2/colA dir1/colB &&\n'> 
          <'\t\tp4 submit -d "remove overlay sync files"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: add colA in dir1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/dir1/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir1/colA >dir1/colA &&\n'> <'\t\tp4 add dir1/colA &&\n'> 
          <'\t\tp4 submit -d dir1/colA\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: initial git checkout'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir1/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA" &&\n'> <'\techo dir1/colA >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colA &&\n'> <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> 
          <'\tgit_verify $files &&\n'> <'\ttest_cmp actual "$git"/colA\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: add colA in dir2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/dir2/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir2/colA >dir2/colA &&\n'> <'\t\tp4 add dir2/colA &&\n'> 
          <'\t\tp4 submit -d dir2/colA\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'overlay sync swap: colA no content switch'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir1/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA" &&\n'> <'\techo dir1/colA >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colA &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit p4 sync --use-client-spec &&\n'> <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> <'\tgit_verify $files &&\n'> 
          <'\ttest_cmp actual "$git"/colA\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: add colB in dir1'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir1/... //client/dir1/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir1/colB >dir1/colB &&\n'> <'\t\tp4 add dir1/colB &&\n'> 
          <'\t\tp4 submit -d dir1/colB\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: colB appears'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir1/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA colB" &&\n'> <'\techo dir1/colB >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colB &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit p4 sync --use-client-spec &&\n'> <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> <'\tgit_verify $files &&\n'> 
          <'\ttest_cmp actual "$git"/colB\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: add/delete colB in dir2'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/dir2/..." &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\tp4 sync &&\n'> <'\t\techo dir2/colB >dir2/colB &&\n'> <'\t\tp4 add dir2/colB &&\n'> 
          <'\t\tp4 submit -d dir2/colB &&\n'> <'\t\tp4 delete dir2/colB &&\n'> <'\t\tp4 submit -d "delete dir2/colB"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'overlay sync swap: colB no change'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/dir2/... //client/..." \\\n'> 
          <'\t\t    "+//depot/dir1/... //client/..." &&\n'> <'\tfiles="file11 file12 file21 file22 colA colB" &&\n'> <'\techo dir1/colB >actual &&\n'> 
          <'\tclient_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colB &&\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> 
          <'\t\tcd "$git" &&\n'> <'\t\tgit p4 sync --use-client-spec &&\n'> <'\t\tgit merge --ff-only p4/master\n'> <'\t) &&\n'> 
          <'\tgit_verify $files &&\n'> <'\ttest_cmp actual "$cli"/colB\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'overlay sync swap: cleanup'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 sync &&\n'> <'\t\tp4 delete dir1/colA dir2/colA dir1/colB &&\n'> 
          <'\t\tp4 submit -d "remove overlay sync files"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'rename files to introduce spaces'>)} 
      {
        (SQ <'\n'> <'\tclient_view "//depot/... //client/..." &&\n'> 
          <'\tclient_verify dir1/file11 dir1/file12 \\\n'> <'\t\t      dir2/file21 dir2/file22 &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 open dir1/... &&\n'> <'\t\tp4 move dir1/... "dir 1"/... &&\n'> <'\t\tp4 open dir2/... &&\n'> 
          <'\t\tp4 move dir2/... "dir 2"/... &&\n'> <'\t\tp4 submit -d "rename with spaces"\n'> <'\t) &&\n'> 
          <'\tclient_verify "dir 1/file11" "dir 1/file12" \\\n'> <'\t\t      "dir 2/file21" "dir 2/file22"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'quotes on lhs only'>)} 
      {
        (SQ <'\n'> <'\tclient_view "\\"//depot/dir 1/...\\" //client/cdir1/..." &&\n'> 
          <'\tfiles="cdir1/file11 cdir1/file12" &&\n'> <'\tclient_verify $files &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tclient_verify $files\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'quotes on both sides'>)} 
      {
        (SQ <'\n'> <'\tclient_view "\\"//depot/dir 1/...\\" \\"//client/cdir 1/...\\"" &&\n'> 
          <'\tclient_verify "cdir 1/file11" "cdir 1/file12" &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --use-client-spec --dest="$git" //depot &&\n'> <'\tgit_verify "cdir 1/file11" "cdir 1/file12"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'kill p4d'>)} {(SQ <'\n'> <'\tkill_p4d\n'>)})
    (C {(test_done)})
  ]
)