(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"git p4 submit failure handling">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./lib-git-p4.sh)})
    (C {(test_expect_success)} {(SQ <"start p4d">)} {(SQ <"\n"> <"\tstart_p4d\n">)})
    (C {(test_expect_success)} {(SQ <"init depot">)} 
      {
        (SQ <"\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> 
          <"\t\tp4 client -o | sed \"/LineEnd/s/:.*/:unix/\" | p4 client -i &&\n"> <"\t\techo line1 >file1 &&\n"> <"\t\tp4 add file1 &&\n"> <"\t\tp4 submit -d \"line1 in file1\"\n"> 
          <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on one commit">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line2 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line2 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\t# now this commit should cause a conflict\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> <"\t\techo line3 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> 
          <"\t\tgit commit -m \"line3 in file1 will conflict\" &&\n"> <"\t\ttest_expect_code 1 git p4 submit >out &&\n"> <"\t\ttest_i18ngrep \"No commits applied\" out\n"> 
          <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on second of two commits">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line3 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line3 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> 
          <"\t\t# this commit is okay\n"> <"\t\ttest_commit \"first_commit_okay\" &&\n"> <"\t\t# now this submit should cause a conflict\n"> 
          <"\t\techo line4 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> <"\t\tgit commit -m \"line4 in file1 will conflict\" &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit >out &&\n"> <"\t\ttest_i18ngrep \"Applied only the commits\" out\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on first of two commits, skip">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line4 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line4 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> 
          <"\t\t# this submit should cause a conflict\n"> <"\t\techo line5 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> 
          <"\t\tgit commit -m \"line5 in file1 will conflict\" &&\n"> <"\t\t# but this commit is okay\n"> <"\t\ttest_commit \"okay_commit_after_skip\" &&\n"> 
          <"\t\techo s | test_expect_code 1 git p4 submit >out &&\n"> <"\t\ttest_i18ngrep \"Applied only the commits\" out\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on first of two commits, quit">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line7 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line7 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> 
          <"\t\t# this submit should cause a conflict\n"> <"\t\techo line8 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> 
          <"\t\tgit commit -m \"line8 in file1 will conflict\" &&\n"> <"\t\t# but this commit is okay\n"> <"\t\ttest_commit \"okay_commit_after_quit\" &&\n"> 
          <"\t\techo q | test_expect_code 1 git p4 submit >out &&\n"> <"\t\ttest_i18ngrep \"No commits applied\" out\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict cli and config options">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit p4 submit --conflict=ask &&\n"> 
          <"\t\tgit p4 submit --conflict=skip &&\n"> <"\t\tgit p4 submit --conflict=quit &&\n"> 
          <"\t\ttest_expect_code 2 git p4 submit --conflict=foo &&\n"> <"\t\ttest_expect_code 2 git p4 submit --conflict &&\n"> <"\t\tgit config git-p4.conflict foo &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit &&\n"> <"\t\tgit config --unset git-p4.conflict &&\n"> <"\t\tgit p4 submit\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on first of two commits, --conflict=skip">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line9 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line9 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> 
          <"\t\t# this submit should cause a conflict\n"> <"\t\techo line10 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> 
          <"\t\tgit commit -m \"line10 in file1 will conflict\" &&\n"> <"\t\t# but this commit is okay\n"> <"\t\ttest_commit \"okay_commit_after_auto_skip\" &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit --conflict=skip >out &&\n"> <"\t\ttest_i18ngrep \"Applied only the commits\" out\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"conflict on first of two commits, --conflict=quit">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\tp4 open file1 &&\n"> <"\t\techo line11 >>file1 &&\n"> 
          <"\t\tp4 submit -d \"line11 in file1\"\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit config git-p4.skipSubmitEdit true &&\n"> 
          <"\t\t# this submit should cause a conflict\n"> <"\t\techo line12 >>file1 &&\n"> <"\t\tgit add file1 &&\n"> 
          <"\t\tgit commit -m \"line12 in file1 will conflict\" &&\n"> <"\t\t# but this commit is okay\n"> <"\t\ttest_commit \"okay_commit_after_auto_quit\" &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit --conflict=quit >out &&\n"> <"\t\ttest_i18ngrep \"No commits applied\" out\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup edit p4 populate">)} 
      {
        (SQ <"\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\techo text file >text &&\n"> 
          <"\t\tp4 add text &&\n"> <"\t\techo text+x file >text+x &&\n"> <"\t\tchmod 755 text+x &&\n"> <"\t\tp4 add text+x &&\n"> 
          <"\t\tp4 submit -d \"populate p4\"\n"> <"\t)\n">
        )
      }
    )
    (FuncDef
      name: setup_conflict
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(test_when_finished)} {(cleanup_git)})
                (AndOr
                  children: [
                    (C {(git)} {(p4)} {(clone)} {(--dest) (Lit_Other "=") (DQ ($ VSub_Name "$git"))} 
                      {(//depot)}
                    )
                    (AndOr
                      children: [
                        (C {(test_tick)})
                        (AndOr
                          children: [
                            (Subshell
                              child: 
                                (AndOr
                                  children: [
                                    (C {(cd)} {(DQ ($ VSub_Name "$cli"))})
                                    (AndOr
                                      children: [
                                        (C {(p4)} {(open)} {(file1)})
                                        (AndOr
                                          children: [
                                            (SimpleCommand
                                              words: [{(echo)} {($ VSub_Name "$test_tick")}]
                                              redirects: [
                                                (Redir
                                                  op_id: Redir_DGreat
                                                  fd: -1
                                                  arg_word: {(file1)}
                                                  spids: [362]
                                                )
                                              ]
                                            )
                                            (C {(p4)} {(submit)} {(-d)} 
                                              {(DQ ($ VSub_Name "$test_tick") (" in file1"))}
                                            )
                                          ]
                                          op_id: Op_DAmp
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  ]
                                  op_id: Op_DAmp
                                )
                              spids: [337 380]
                            )
                            (AndOr
                              children: [
                                (C {(test_tick)})
                                (Subshell
                                  child: 
                                    (AndOr
                                      children: [
                                        (C {(cd)} {(DQ ($ VSub_Name "$git"))})
                                        (AndOr
                                          children: [
                                            (C {(git)} {(config)} {(git-p4.skipSubmitEdit)} {(true)})
                                            (AndOr
                                              children: [
                                                (SimpleCommand
                                                  words: [{(echo)} {($ VSub_Name "$test_tick")}]
                                                  redirects: [
                                                    (Redir
                                                      op_id: Redir_DGreat
                                                      fd: -1
                                                      arg_word: {(file1)}
                                                      spids: [421]
                                                    )
                                                  ]
                                                )
                                                (C {(git)} {(add)} {(file1)})
                                              ]
                                              op_id: Op_DAmp
                                            )
                                          ]
                                          op_id: Op_DAmp
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  spids: [390 438]
                                )
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [297]
        )
      spids: [293 296]
    )
    (C {(test_expect_success)} {(SQ <"cleanup edit after submit fail">)} 
      {
        (SQ <"\n"> <"\tsetup_conflict &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\techo another line >>text &&\n"> <"\t\tgit add text &&\n"> <"\t\tgit commit -m \"conflict\" &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\t# make sure it is not open\n"> 
          <"\t\t! p4 fstat -T action text\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup add after submit fail">)} 
      {
        (SQ <"\n"> <"\tsetup_conflict &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\techo new file >textnew &&\n"> <"\t\tgit add textnew &&\n"> <"\t\tgit commit -m \"conflict\" &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\t# make sure it is not there\n"> 
          <"\t\t# and that p4 thinks it is not added\n"> <"\t\t#   P4 returns 0 both for \"not there but added\" and\n"> <"\t\t#   \"not there\", so grep.\n"> 
          <"\t\ttest_path_is_missing textnew &&\n"> <"\t\tp4 fstat -T action textnew 2>&1 | grep \"no such file\"\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup delete after submit fail">)} 
      {
        (SQ <"\n"> <"\tsetup_conflict &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\tgit rm text+x &&\n"> <"\t\tgit commit -m \"conflict\" &&\n"> <"\t\ttest_expect_code 1 git p4 submit\n"> <"\t) &&\n"> 
          <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\t# make sure it is there\n"> <"\t\ttest_path_is_file text+x &&\n"> 
          <"\t\t! p4 fstat -T action text+x\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup copy after submit fail">)} 
      {
        (SQ <"\n"> <"\tsetup_conflict &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\tcp text text2 &&\n"> <"\t\tgit add text2 &&\n"> <"\t\tgit commit -m \"conflict\" &&\n"> 
          <"\t\tgit config git-p4.detectCopies true &&\n"> <"\t\tgit config git-p4.detectCopiesHarder true &&\n"> <"\t\t# make sure setup is okay\n"> 
          <"\t\tgit diff-tree -r -C --find-copies-harder HEAD | grep text2 | grep C100 &&\n"> <"\t\ttest_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> 
          <"\t\ttest_path_is_missing text2 &&\n"> <"\t\tp4 fstat -T action text2 2>&1 | grep \"no such file\"\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup rename after submit fail">)} 
      {
        (SQ <"\n"> <"\tsetup_conflict &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> 
          <"\t\tgit mv text text2 &&\n"> <"\t\tgit commit -m \"conflict\" &&\n"> <"\t\tgit config git-p4.detectRenames true &&\n"> 
          <"\t\t# make sure setup is okay\n"> <"\t\tgit diff-tree -r -M HEAD | grep text2 | grep R100 &&\n"> 
          <"\t\ttest_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\ttest_path_is_missing text2 &&\n"> 
          <"\t\tp4 fstat -T action text2 2>&1 | grep \"no such file\"\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup edit after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\techo line >>text &&\n"> <"\t\tgit add text &&\n"> 
          <"\t\tgit commit -m text &&\n"> <"\t\techo n | test_expect_code 1 git p4 submit &&\n"> <"\t\tgit reset --hard HEAD^\n"> <"\t) &&\n"> 
          <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\t! p4 fstat -T action text &&\n"> <"\t\ttest_cmp \"$git\"/text text\n"> 
          <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup add after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\techo line >textnew &&\n"> <"\t\tgit add textnew &&\n"> 
          <"\t\tgit commit -m textnew &&\n"> <"\t\techo n | test_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> 
          <"\t\ttest_path_is_missing textnew &&\n"> <"\t\tp4 fstat -T action textnew 2>&1 | grep \"no such file\"\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup delete after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit rm text &&\n"> <"\t\tgit commit -m \"rm text\" &&\n"> 
          <"\t\techo n | test_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\ttest_path_is_file text &&\n"> 
          <"\t\t! p4 fstat -T action text\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup copy after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tcp text text2 &&\n"> <"\t\tgit add text2 &&\n"> 
          <"\t\tgit commit -m text2 &&\n"> <"\t\tgit config git-p4.detectCopies true &&\n"> 
          <"\t\tgit config git-p4.detectCopiesHarder true &&\n"> <"\t\tgit diff-tree -r -C --find-copies-harder HEAD | grep text2 | grep C100 &&\n"> 
          <"\t\techo n | test_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\ttest_path_is_missing text2 &&\n"> 
          <"\t\tp4 fstat -T action text2 2>&1 | grep \"no such file\"\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup rename after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\tgit mv text text2 &&\n"> <"\t\tgit commit -m text2 &&\n"> 
          <"\t\tgit config git-p4.detectRenames true &&\n"> <"\t\tgit diff-tree -r -M HEAD | grep text2 | grep R100 &&\n"> 
          <"\t\techo n | test_expect_code 1 git p4 submit\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\ttest_path_is_missing text2 &&\n"> 
          <"\t\tp4 fstat -T action text2 2>&1 | grep \"no such file\"\n"> <"\t\ttest_path_is_file text &&\n"> <"\t\t! p4 fstat -T action text\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cleanup chmod after submit cancel">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished cleanup_git &&\n"> 
          <"\tgit p4 clone --dest=\"$git\" //depot &&\n"> <"\t(\n"> <"\t\tcd \"$git\" &&\n"> <"\t\ttest_chmod +x text &&\n"> <"\t\ttest_chmod -x text+x &&\n"> 
          <"\t\tgit add text text+x &&\n"> <"\t\tgit commit -m \"chmod texts\" &&\n"> <"\t\techo n | test_expect_code 1 git p4 submit\n"> 
          <"\t) &&\n"> <"\t(\n"> <"\t\tcd \"$cli\" &&\n"> <"\t\ttest_path_is_file text &&\n"> 
          <"\t\t! p4 fstat -T action text &&\n"> <"\t\ttest_path_is_file text+x &&\n"> <"\t\t! p4 fstat -T action text+x &&\n"> 
          <"\t\tls -l text | egrep ^-r-- &&\n"> <"\t\tls -l text+x | egrep ^-r-x\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"kill p4d">)} {(SQ <"\n"> <"\tkill_p4d\n">)})
    (C {(test_done)})
  ]
)