(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: 'Test merging of notes trees in multiple worktrees'
                  span_id: 15
                )
              )
            }
          spids: [13]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup commit' span_id:27))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:31) 
          (Token id:Id.Lit_Chars val:'\ttest_commit tantrum\n' span_id:32)
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_tantrum)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:37)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(tantrum) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [36]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup notes ref (x)' span_id:53))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:57) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit config core.notesRef refs/notes/x &&\n'
            span_id: 58
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -m "x notes on tantrum" tantrum\n' span_id:59)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup local branch (y)' span_id:66))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:70) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/y refs/notes/x &&\n'
            span_id: 71
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/y &&\n' span_id:72) 
          (Token id:Id.Lit_Chars val:'\tgit notes remove tantrum\n' span_id:73)
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup remote branch (z)' span_id:80))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:84) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/z refs/notes/x &&\n'
            span_id: 85
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/z &&\n' span_id:86) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -f -m "conflicting notes on tantrum" tantrum\n'
            span_id: 87
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'modify notes ref ourselves (x)' span_id:94))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:98) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit config core.notesRef refs/notes/x &&\n'
            span_id: 99
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -f -m "more conflicting notes on tantrum" tantrum\n'
            span_id: 100
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'create some new worktrees' span_id:107))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:111) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit worktree add -b newbranch worktree master &&\n'
            span_id: 112
          ) (Token id:Id.Lit_Chars val:'\tgit worktree add -b newbranch2 worktree2 master\n' span_id:113)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'merge z into y fails and sets NOTES_MERGE_REF' span_id:120))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:124) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit config core.notesRef refs/notes/y &&\n'
            span_id: 125
          ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git notes merge z &&\n' span_id:126) 
          (Token id:Id.Lit_Chars val:'\techo "ref: refs/notes/y" >expect &&\n' span_id:127) (Token id:Id.Lit_Chars val:'\ttest_cmp .git/NOTES_MERGE_REF expect\n' span_id:128)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'merge z into y while mid-merge in another workdir fails'
            span_id: 135
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:139) 
          (Token id:Id.Lit_Chars val:'\t(\n' span_id:140) (Token id:Id.Lit_Chars val:'\t\tcd worktree &&\n' span_id:141) 
          (Token
            id: Id.Lit_Chars
            val: '\t\tgit config core.notesRef refs/notes/y &&\n'
            span_id: 142
          ) (Token id:Id.Lit_Chars val:'\t\ttest_must_fail git notes merge z 2>err &&\n' span_id:143) 
          (Token
            id: Id.Lit_Chars
            val: 
'\t\ttest_i18ngrep "a notes merge into refs/notes/y is already in-progress at" err\n'
            span_id: 144
          ) (Token id:Id.Lit_Chars val:'\t) &&\n' span_id:145) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF\n'
            span_id: 146
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'merge z into x while mid-merge on y succeeds' span_id:153))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:157) 
          (Token id:Id.Lit_Chars val:'\t(\n' span_id:158) (Token id:Id.Lit_Chars val:'\t\tcd worktree2 &&\n' span_id:159) 
          (Token
            id: Id.Lit_Chars
            val: '\t\tgit config core.notesRef refs/notes/x &&\n'
            span_id: 160
          ) (Token id:Id.Lit_Chars val:'\t\ttest_must_fail git notes merge z 2>&1 >out &&\n' span_id:161) 
          (Token
            id: Id.Lit_Chars
            val: '\t\ttest_i18ngrep "Automatic notes merge failed" out &&\n'
            span_id: 162
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t\tgrep -v "A notes merge into refs/notes/x is already in-progress in" out\n'
            span_id: 163
          ) (Token id:Id.Lit_Chars val:'\t) &&\n' span_id:164) 
          (Token id:Id.Lit_Chars val:'\techo "ref: refs/notes/x" >expect &&\n' span_id:165) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect\n'
            span_id: 166
          )
        )
      }
    )
    (C {(test_done)})
  ]
)