(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ (Token id:Id.Lit_Chars val:'undoing resolution' span_id:6))}
          spids: [4]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.ShFunction
      name: check_resolve_undo
      body: 
        (command.BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:msg)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [23]
                )
              ]
            )
            (C {(shift)})
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.WhileUntil
                  keyword: (Token id:Id.KW_While val:while span_id:30)
                  cond: [
                    (command.Case
                      to_match: {($ Id.VSub_Pound '$#')}
                      arms: [
                        (case_arm
                          pat_list: [{(0)}]
                          action: [
                            (command.ControlFlow
                              token: (Token id:Id.ControlFlow_Break val:break span_id:42)
                            )
                          ]
                          spids: [39 40 44 -1]
                        )
                        (case_arm
                          pat_list: [{(1)} {(2)} {(3)}]
                          action: [(C {(die)} {(DQ ('Bug in check-resolve-undo test'))})]
                          spids: [47 52 60 -1]
                        )
                      ]
                    )
                  ]
                  body: 
                    (command.DoGroup
                      children: [
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:path)
                              op: assign_op.Equal
                              rhs: {($ Id.VSub_Number '$1')}
                              spids: [69]
                            )
                          ]
                        )
                        (C {(shift)})
                        (command.ForEach
                          iter_name: stage
                          iter_words: [{(1)} {(2)} {(3)}]
                          do_arg_iter: F
                          body: 
                            (command.DoGroup
                              children: [
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name name:sha1)
                                      op: assign_op.Equal
                                      rhs: {($ Id.VSub_Number '$1')}
                                      spids: [92]
                                    )
                                  ]
                                )
                                (C {(shift)})
                                (command.Case
                                  to_match: {(DQ ($ Id.VSub_DollarName '$sha1'))}
                                  arms: [
                                    (case_arm
                                      pat_list: [{(SQ )}]
                                      action: [
                                        (command.ControlFlow
                                          token: 
                                            (Token
                                              id: Id.ControlFlow_Continue
                                              val: continue
                                              span_id: 112
                                            )
                                        )
                                      ]
                                      spids: [108 110 114 -1]
                                    )
                                  ]
                                )
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name name:sha1)
                                      op: assign_op.Equal
                                      rhs: 
                                        {
                                          (command_sub
                                            left_token: 
                                              (Token
                                                id: Id.Left_DollarParen
                                                val: '$('
                                                span_id: 121
                                              )
                                            command_list: 
                                              (command.CommandList
                                                children: [
                                                  (C {(git)} {(rev-parse)} {(--verify)} 
                                                    {(DQ ($ Id.VSub_DollarName '$sha1'))}
                                                  )
                                                ]
                                              )
                                          )
                                        }
                                      spids: [120]
                                    )
                                  ]
                                )
                                (C {(printf)} 
                                  {
                                    (DQ ('100644 %s %s') (Id.Lit_Other '\\') ('t%s') (Id.Lit_Other '\\') 
                                      (n)
                                    )
                                  } {($ Id.VSub_DollarName '$sha1')} {($ Id.VSub_DollarName '$stage')} {($ Id.VSub_DollarName '$path')}
                                )
                              ]
                            )
                        )
                      ]
                    )
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:156)
                      fd: -1
                      arg_word: {(DQ ($ Id.VSub_DollarName '$msg') (.expect))}
                    )
                  ]
                )
                (command.Simple
                  words: [{(git)} {(ls-files)} {(--resolve-undo)}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:171)
                      fd: -1
                      arg_word: {(DQ ($ Id.VSub_DollarName '$msg') (.actual))}
                    )
                  ]
                )
                (C {(test_cmp)} {(DQ ($ Id.VSub_DollarName '$msg') (.expect))} 
                  {(DQ ($ Id.VSub_DollarName '$msg') (.actual))}
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: prime_resolve_undo
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
                Id.Op_DAmp
              ]
              children: [
                (C {(git)} {(reset)} {(--hard)})
                (C {(git)} {(checkout)} {(second) (Id.Lit_Other '^') (0)})
                (C {(test_tick)})
                (C {(test_must_fail)} {(git)} {(merge)} {(third) (Id.Lit_Other '^') (0)})
                (C {(echo)} {(merge)} {(does)} {(not)} {(leave)} {(anything)})
                (C {(check_resolve_undo)} {(empty)})
                (command.Simple
                  words: [{(echo)} {(different)}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:267)
                      fd: -1
                      arg_word: {(fi/le)}
                    )
                  ]
                )
                (C {(git)} {(add)} {(fi/le)})
                (C {(echo)} {(resolving)} {(records)})
                (C {(check_resolve_undo)} {(recorded)} {(fi/le)} {(initial) (Id.Lit_Other ':') (fi/le)} 
                  {(second) (Id.Lit_Other ':') (fi/le)} {(third) (Id.Lit_Other ':') (fi/le)}
                )
              ]
            )
          ]
        )
    )
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:317) 
          (Token id:Id.Lit_Chars val:'\tmkdir fi &&\n' span_id:318) (Token id:Id.Lit_Chars val:'\tprintf "a\\0a" >binary &&\n' span_id:319) 
          (Token id:Id.Lit_Chars val:'\tgit add binary &&\n' span_id:320) (Token id:Id.Lit_Chars val:'\ttest_commit initial fi/le first &&\n' span_id:321) 
          (Token id:Id.Lit_Chars val:'\tgit branch side &&\n' span_id:322) (Token id:Id.Lit_Chars val:'\tgit branch another &&\n' span_id:323) 
          (Token id:Id.Lit_Chars val:'\tprintf "a\\0b" >binary &&\n' span_id:324) (Token id:Id.Lit_Chars val:'\tgit add binary &&\n' span_id:325) 
          (Token id:Id.Lit_Chars val:'\ttest_commit second fi/le second &&\n' span_id:326) (Token id:Id.Lit_Chars val:'\tgit checkout side &&\n' span_id:327) 
          (Token id:Id.Lit_Chars val:'\ttest_commit third fi/le third &&\n' span_id:328) (Token id:Id.Lit_Chars val:'\tgit branch add-add &&\n' span_id:329) 
          (Token id:Id.Lit_Chars val:'\tgit checkout another &&\n' span_id:330) (Token id:Id.Lit_Chars val:'\ttest_commit fourth fi/le fourth &&\n' span_id:331) 
          (Token id:Id.Lit_Chars val:'\tgit checkout add-add &&\n' span_id:332) (Token id:Id.Lit_Chars val:'\ttest_commit fifth add-differently &&\n' span_id:333) 
          (Token id:Id.Lit_Chars val:'\tgit checkout master\n' span_id:334)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'add records switch clears' span_id:341))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:345) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:346) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:347) 
          (Token id:Id.Lit_Chars val:'\tgit commit -m merged &&\n' span_id:348) (Token id:Id.Lit_Chars val:'\techo committing keeps &&\n' span_id:349) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n'
            span_id: 350
          ) (Token id:Id.Lit_Chars val:'\tgit checkout second^0 &&\n' span_id:351) 
          (Token id:Id.Lit_Chars val:'\techo switching clears &&\n' span_id:352) (Token id:Id.Lit_Chars val:'\tcheck_resolve_undo cleared\n' span_id:353)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'rm records reset clears' span_id:360))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:364) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:365) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:366) 
          (Token id:Id.Lit_Chars val:'\tgit commit -m merged &&\n' span_id:367) (Token id:Id.Lit_Chars val:'\techo committing keeps &&\n' span_id:368) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n'
            span_id: 369
          ) (Token id:Id.Lit_Chars val:'\n' span_id:370) 
          (Token id:Id.Lit_Chars val:'\techo merge clears upfront &&\n' span_id:371) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge fourth^0 &&\n' span_id:372) 
          (Token id:Id.Lit_Chars val:'\tcheck_resolve_undo nuked &&\n' span_id:373) (Token id:Id.Lit_Chars val:'\n' span_id:374) 
          (Token id:Id.Lit_Chars val:'\tgit rm -f fi/le &&\n' span_id:375) (Token id:Id.Lit_Chars val:'\techo resolving records &&\n' span_id:376) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo recorded fi/le initial:fi/le HEAD:fi/le fourth:fi/le &&\n'
            span_id: 377
          ) (Token id:Id.Lit_Chars val:'\n' span_id:378) 
          (Token id:Id.Lit_Chars val:'\tgit reset --hard &&\n' span_id:379) (Token id:Id.Lit_Chars val:'\techo resetting discards &&\n' span_id:380) 
          (Token id:Id.Lit_Chars val:'\tcheck_resolve_undo discarded\n' span_id:381)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'plumbing clears' span_id:388))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:392) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:393) (Token id:Id.Lit_Chars val:'\ttest_tick &&\n' span_id:394) 
          (Token id:Id.Lit_Chars val:'\tgit commit -m merged &&\n' span_id:395) (Token id:Id.Lit_Chars val:'\techo committing keeps &&\n' span_id:396) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n'
            span_id: 397
          ) (Token id:Id.Lit_Chars val:'\n' span_id:398) 
          (Token id:Id.Lit_Chars val:'\techo plumbing clear &&\n' span_id:399) (Token id:Id.Lit_Chars val:'\tgit update-index --clear-resolve-undo &&\n' span_id:400) 
          (Token id:Id.Lit_Chars val:'\tcheck_resolve_undo cleared\n' span_id:401)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'add records checkout -m undoes' span_id:408))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:412) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:413) (Token id:Id.Lit_Chars val:'\tgit diff HEAD &&\n' span_id:414) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit checkout --conflict=merge fi/le &&\n'
            span_id: 415
          ) (Token id:Id.Lit_Chars val:'\techo checkout used the record and removed it &&\n' span_id:416) 
          (Token id:Id.Lit_Chars val:'\tcheck_resolve_undo removed &&\n' span_id:417) (Token id:Id.Lit_Chars val:'\techo the index and the work tree is unmerged again &&\n' span_id:418) 
          (Token id:Id.Lit_Chars val:'\tgit diff >actual &&\n' span_id:419) (Token id:Id.Lit_Chars val:'\tgrep "^++<<<<<<<" actual\n' span_id:420)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'unmerge with plumbing' span_id:427))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:431) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:432) (Token id:Id.Lit_Chars val:'\tgit update-index --unresolve fi/le &&\n' span_id:433) 
          (Token id:Id.Lit_Chars val:'\tgit ls-files -u >actual &&\n' span_id:434) (Token id:Id.Lit_Chars val:'\ttest_line_count = 3 actual\n' span_id:435)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'rerere and rerere forget' span_id:442))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:446) 
          (Token id:Id.Lit_Chars val:'\tmkdir .git/rr-cache &&\n' span_id:447) (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:448) 
          (Token id:Id.Lit_Chars val:'\techo record the resolution &&\n' span_id:449) (Token id:Id.Lit_Chars val:'\tgit rerere &&\n' span_id:450) 
          (Token
            id: Id.Lit_Chars
            val: '\trerere_id=$(cd .git/rr-cache && echo */postimage) &&\n'
            span_id: 451
          ) (Token id:Id.Lit_Chars val:'\trerere_id=${rerere_id%/postimage} &&\n' span_id:452) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -f .git/rr-cache/$rerere_id/postimage &&\n'
            span_id: 453
          ) (Token id:Id.Lit_Chars val:'\tgit checkout -m fi/le &&\n' span_id:454) 
          (Token id:Id.Lit_Chars val:'\techo resurrect the conflict &&\n' span_id:455) (Token id:Id.Lit_Chars val:'\tgrep "^=======" fi/le &&\n' span_id:456) 
          (Token id:Id.Lit_Chars val:'\techo reresolve the conflict &&\n' span_id:457) (Token id:Id.Lit_Chars val:'\tgit rerere &&\n' span_id:458) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "z$(cat fi/le)" = zdifferent &&\n'
            span_id: 459
          ) (Token id:Id.Lit_Chars val:'\techo register the resolution again &&\n' span_id:460) 
          (Token id:Id.Lit_Chars val:'\tgit add fi/le &&\n' span_id:461) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n'
            span_id: 462
          ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git ls-files -u)" &&\n' span_id:463) 
          (Token id:Id.Lit_Chars val:'\tgit rerere forget fi/le &&\n' span_id:464) (Token id:Id.Lit_Chars val:'\t! test -f .git/rr-cache/$rerere_id/postimage &&\n' span_id:465) 
          (Token
            id: Id.Lit_Chars
            val: '\ttr "\\0" "\\n" <.git/MERGE_RR >actual &&\n'
            span_id: 466
          ) (Token id:Id.Lit_Chars val:'\techo "$rerere_id\tfi/le" >expect &&\n' span_id:467) 
          (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:468)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'rerere and rerere forget (subdirectory)' span_id:475))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:479) 
          (Token id:Id.Lit_Chars val:'\trm -fr .git/rr-cache &&\n' span_id:480) (Token id:Id.Lit_Chars val:'\tmkdir .git/rr-cache &&\n' span_id:481) 
          (Token id:Id.Lit_Chars val:'\tprime_resolve_undo &&\n' span_id:482) (Token id:Id.Lit_Chars val:'\techo record the resolution &&\n' span_id:483) 
          (Token id:Id.Lit_Chars val:'\t(cd fi && git rerere) &&\n' span_id:484) (Token id:Id.Lit_Chars val:'\trerere_id=$(cd .git/rr-cache && echo */postimage) &&\n' span_id:485) 
          (Token
            id: Id.Lit_Chars
            val: '\trerere_id=${rerere_id%/postimage} &&\n'
            span_id: 486
          ) (Token id:Id.Lit_Chars val:'\ttest -f .git/rr-cache/$rerere_id/postimage &&\n' span_id:487) 
          (Token id:Id.Lit_Chars val:'\t(cd fi && git checkout -m le) &&\n' span_id:488) (Token id:Id.Lit_Chars val:'\techo resurrect the conflict &&\n' span_id:489) 
          (Token id:Id.Lit_Chars val:'\tgrep "^=======" fi/le &&\n' span_id:490) (Token id:Id.Lit_Chars val:'\techo reresolve the conflict &&\n' span_id:491) 
          (Token id:Id.Lit_Chars val:'\t(cd fi && git rerere) &&\n' span_id:492) (Token id:Id.Lit_Chars val:'\ttest "z$(cat fi/le)" = zdifferent &&\n' span_id:493) 
          (Token
            id: Id.Lit_Chars
            val: '\techo register the resolution again &&\n'
            span_id: 494
          ) (Token id:Id.Lit_Chars val:'\t(cd fi && git add le) &&\n' span_id:495) 
          (Token
            id: Id.Lit_Chars
            val: '\tcheck_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&\n'
            span_id: 496
          ) (Token id:Id.Lit_Chars val:'\ttest -z "$(git ls-files -u)" &&\n' span_id:497) 
          (Token id:Id.Lit_Chars val:'\t(cd fi && git rerere forget le) &&\n' span_id:498) (Token id:Id.Lit_Chars val:'\t! test -f .git/rr-cache/$rerere_id/postimage &&\n' span_id:499) 
          (Token
            id: Id.Lit_Chars
            val: '\ttr "\\0" "\\n" <.git/MERGE_RR >actual &&\n'
            span_id: 500
          ) (Token id:Id.Lit_Chars val:'\techo "$rerere_id\tfi/le" >expect &&\n' span_id:501) 
          (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:502)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'rerere forget (binary)' span_id:509))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:513) 
          (Token id:Id.Lit_Chars val:'\tgit checkout -f side &&\n' span_id:514) (Token id:Id.Lit_Chars val:'\tprintf "a\\0c" >binary &&\n' span_id:515) 
          (Token id:Id.Lit_Chars val:'\tgit commit -a -m binary &&\n' span_id:516) (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge second &&\n' span_id:517) 
          (Token id:Id.Lit_Chars val:'\tgit rerere forget binary\n' span_id:518)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'rerere forget (add-add conflict)' span_id:525))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:529) 
          (Token id:Id.Lit_Chars val:'\tgit checkout -f master &&\n' span_id:530) (Token id:Id.Lit_Chars val:'\techo master >add-differently &&\n' span_id:531) 
          (Token id:Id.Lit_Chars val:'\tgit add add-differently &&\n' span_id:532) (Token id:Id.Lit_Chars val:'\tgit commit -m "add differently" &&\n' span_id:533) 
          (Token id:Id.Lit_Chars val:'\ttest_must_fail git merge fifth &&\n' span_id:534) (Token id:Id.Lit_Chars val:'\tgit rerere forget add-differently 2>actual &&\n' span_id:535) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep "no remembered" actual\n'
            span_id: 536
          )
        )
      }
    )
    (C {(test_done)})
  ]
)