(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 notes merging with manual conflict resolution'
                  span_id: 15
                )
              )
            }
          spids: [13]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup commits' span_id:30))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:34) 
          (Token id:Id.Lit_Chars val:'\ttest_commit 1st &&\n' span_id:35) (Token id:Id.Lit_Chars val:'\ttest_commit 2nd &&\n' span_id:36) 
          (Token id:Id.Lit_Chars val:'\ttest_commit 3rd &&\n' span_id:37) (Token id:Id.Lit_Chars val:'\ttest_commit 4th &&\n' span_id:38) 
          (Token id:Id.Lit_Chars val:'\ttest_commit 5th\n' span_id:39)
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha1)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:44)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(1st) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [43]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha2)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:57)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(2nd) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [56]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha3)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:70)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(3rd) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [69]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha4)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:83)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(4th) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [82]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha5)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:96)
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(5th) (Id.Lit_Other '^') (Id.Lit_LBrace '{') (commit) (Id.Lit_RBrace '}')}
                      )
                    ]
                  )
              )
            }
          spids: [95]
        )
      ]
    )
    (command.ShFunction
      name: verify_notes
      body: 
        (command.BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:notes_ref)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$1'))}
                  spids: [117]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {(git)} {(-c)} 
                      {(core.notesRef) (Id.Lit_Equals '=') 
                        (DQ (refs/notes/) ($ Id.VSub_DollarName '$notes_ref'))
                      } {(notes)}
                    )
                    (command.Simple
                      words: [{(sort)}]
                      redirects: [
                        (redir.Redir
                          op: (Token id:Id.Redir_Great val:'>' span_id:141)
                          fd: -1
                          arg_word: {(DQ (output_notes_) ($ Id.VSub_DollarName '$notes_ref'))}
                        )
                      ]
                    )
                  ]
                  negated: F
                )
                (C {(test_cmp)} {(DQ (expect_notes_) ($ Id.VSub_DollarName '$notes_ref'))} 
                  {(DQ (output_notes_) ($ Id.VSub_DollarName '$notes_ref'))}
                )
                (command.Simple
                  words: [
                    {(git)}
                    {(-c)}
                    {(core.notesRef) (Id.Lit_Equals '=') 
                      (DQ (refs/notes/) ($ Id.VSub_DollarName '$notes_ref'))
                    }
                    {(log)}
                    {(--format) (Id.Lit_Equals '=') (DQ ('%H %s%n%N'))}
                  ]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:186)
                      fd: -1
                      arg_word: {(DQ (output_log_) ($ Id.VSub_DollarName '$notes_ref'))}
                    )
                  ]
                )
                (C {(test_cmp)} {(DQ (expect_log_) ($ Id.VSub_DollarName '$notes_ref'))} 
                  {(DQ (output_log_) ($ Id.VSub_DollarName '$notes_ref'))}
                )
              ]
            )
          ]
        )
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:212)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 232
              stdin_parts: [
                ('6e8e3febca3c2bb896704335cc4d0c34cb2f8715 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('e5388c10860456ee60673025345fe2e153eb8cf8 ')
                ($ Id.VSub_DollarName '$commit_sha3')
                ('\n')
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:219)
              fd: -1
              arg_word: {(expect_notes_x)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:236)
          fd: -1
          arg_word: {(expect_log_x)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:239)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 261
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('x notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('x notes on 3rd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup merge base (x)' span_id:266))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:270) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit config core.notesRef refs/notes/x &&\n'
            span_id: 271
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -m "x notes on 2nd commit" 2nd &&\n' span_id:272) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -m "x notes on 3rd commit" 3rd &&\n'
            span_id: 273
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -m "x notes on 4th commit" 4th &&\n' span_id:274) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x\n' span_id:275)
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:281)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 301
              stdin_parts: [
                ('e2bfd06a37dd2031684a59a6e2b033e212239c78 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 ')
                ($ Id.VSub_DollarName '$commit_sha3')
                ('\n')
                ('b0a6021ec006d07e80e9b20ec9b444cbd9d560d3 ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:288)
              fd: -1
              arg_word: {(expect_notes_y)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:305)
          fd: -1
          arg_word: {(expect_log_y)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:308)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 330
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('y notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('y notes on 3rd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('y notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup local branch (y)' span_id:335))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:339) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/y refs/notes/x &&\n'
            span_id: 340
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/y &&\n' span_id:341) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -f -m "y notes on 1st commit" 1st &&\n'
            span_id: 342
          ) (Token id:Id.Lit_Chars val:'\tgit notes remove 2nd &&\n' span_id:343) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -f -m "y notes on 3rd commit" 3rd &&\n'
            span_id: 344
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -f -m "y notes on 4th commit" 4th &&\n' span_id:345) 
          (Token id:Id.Lit_Chars val:'\tverify_notes y\n' span_id:346)
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:352)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 372
              stdin_parts: [
                ('cff59c793c20bb49a4e01bc06fb06bad642e0d54 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('0a81da8956346e19bcb27a906f04af327e03e31b ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:359)
              fd: -1
              arg_word: {(expect_notes_z)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:376)
          fd: -1
          arg_word: {(expect_log_z)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:379)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 401
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('z notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'setup remote branch (z)' span_id:406))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:410) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/z refs/notes/x &&\n'
            span_id: 411
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/z &&\n' span_id:412) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -f -m "z notes on 1st commit" 1st &&\n'
            span_id: 413
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -f -m "z notes on 2nd commit" 2nd &&\n' span_id:414) 
          (Token id:Id.Lit_Chars val:'\tgit notes remove 3rd &&\n' span_id:415) (Token id:Id.Lit_Chars val:'\tgit notes add -f -m "z notes on 4th commit" 4th &&\n' span_id:416) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:417)
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:451)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 470
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ($ Id.VSub_DollarName '$commit_sha3')
                ('\n')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:458)
              fd: -1
              arg_word: {(expect_conflicts)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:474)
          fd: -1
          arg_word: {(expect_conflict_) ($ Id.VSub_DollarName '$commit_sha1')}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:478)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 487
          stdin_parts: [
            ('<<<<<<< refs/notes/m\n')
            ('y notes on 1st commit\n')
            ('=======\n')
            ('z notes on 1st commit\n')
            ('>>>>>>> refs/notes/z\n')
          ]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:491)
          fd: -1
          arg_word: {(expect_conflict_) ($ Id.VSub_DollarName '$commit_sha2')}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:495)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 500
          stdin_parts: [('z notes on 2nd commit\n')]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:504)
          fd: -1
          arg_word: {(expect_conflict_) ($ Id.VSub_DollarName '$commit_sha3')}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:508)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 513
          stdin_parts: [('y notes on 3rd commit\n')]
        )
      ]
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:517)
          fd: -1
          arg_word: {(expect_conflict_) ($ Id.VSub_DollarName '$commit_sha4')}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:521)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 530
          stdin_parts: [
            ('<<<<<<< refs/notes/m\n')
            ('y notes on 4th commit\n')
            ('=======\n')
            ('z notes on 4th commit\n')
            ('>>>>>>> refs/notes/z\n')
          ]
        )
      ]
    )
    (C {(cp)} {(expect_notes_y)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_y)} {(expect_log_m)})
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:551)
          fd: -1
          arg_word: {(pre_merge_y)}
        )
      ]
    )
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:561)
          fd: -1
          arg_word: {(pre_merge_z)}
        )
      ]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'merge z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
            span_id: 569
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:573) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/m refs/notes/y &&\n'
            span_id: 574
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/m &&\n' span_id:575) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge z >output &&\n'
            span_id: 576
          ) (Token id:Id.Lit_Chars val:'\t# Output should point to where to resolve conflicts\n' span_id:577) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'
            span_id: 578
          ) (Token id:Id.Lit_Chars val:'\t# Inspect merge conflicts\n' span_id:579) 
          (Token
            id: Id.Lit_Chars
            val: '\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'
            span_id: 580
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect_conflicts output_conflicts &&\n' span_id:581) 
          (Token
            id: Id.Lit_Chars
            val: '\t( for f in $(cat expect_conflicts); do\n'
            span_id: 582
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'
            span_id: 583
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:584) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:585) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'
            span_id: 586
          ) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:587) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:588) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'
            span_id: 589
          )
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:595)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 615
              stdin_parts: [
                ('00494adecf2d9635a02fa431308d67993f853968 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('0a81da8956346e19bcb27a906f04af327e03e31b ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:602)
              fd: -1
              arg_word: {(expect_notes_z)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:619)
          fd: -1
          arg_word: {(expect_log_z)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:622)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 646
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('z notes on 4th commit\n')
            ('\n')
            ('More z notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'change notes in z' span_id:651))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:655) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes --ref z append -m "More z notes on 4th commit" 4th &&\n'
            span_id: 656
          ) (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:657)
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'cannot do merge w/conflicts when previous merge is unfinished'
            span_id: 664
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:668) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -d .git/NOTES_MERGE_WORKTREE &&\n'
            span_id: 669
          ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git notes merge z >output 2>&1 &&\n' span_id:670) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Output should indicate what is wrong\n'
            span_id: 671
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep -q "\\\\.git/NOTES_MERGE_\\\\* exists" output\n'
            span_id: 672
          )
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:682)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 699
              stdin_parts: [
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('f75d1df88cbfe4258d49852f26cfc83f2ad4494b ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:689)
              fd: -1
              arg_word: {(expect_notes_w)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:703)
          fd: -1
          arg_word: {(expect_log_w)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:706)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 727
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('w notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'setup unrelated notes ref (w)' span_id:732))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:736) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit config core.notesRef refs/notes/w &&\n'
            span_id: 737
          ) (Token id:Id.Lit_Chars val:'\tgit notes add -m "w notes on 1st commit" 1st &&\n' span_id:738) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit notes add -m "x notes on 2nd commit" 2nd &&\n'
            span_id: 739
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w\n' span_id:740)
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:746)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 769
              stdin_parts: [
                ('6e8e3febca3c2bb896704335cc4d0c34cb2f8715 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('e5388c10860456ee60673025345fe2e153eb8cf8 ')
                ($ Id.VSub_DollarName '$commit_sha3')
                ('\n')
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('f75d1df88cbfe4258d49852f26cfc83f2ad4494b ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:753)
              fd: -1
              arg_word: {(expect_notes_w)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:773)
          fd: -1
          arg_word: {(expect_log_w)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:776)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 799
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('x notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('x notes on 3rd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('w notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'can do merge without conflicts even if previous merge is unfinished (x => w)'
            span_id: 804
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:808) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -d .git/NOTES_MERGE_WORKTREE &&\n'
            span_id: 809
          ) (Token id:Id.Lit_Chars val:'\tgit notes merge x &&\n' span_id:810) 
          (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:811) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (x and y)\n'
            span_id: 812
          ) (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:813) 
          (Token id:Id.Lit_Chars val:'\tverify_notes y\n' span_id:814)
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:820)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 843
              stdin_parts: [
                ('021faa20e931fb48986ffc6282b4bb05553ac946 ')
                ($ Id.VSub_DollarName '$commit_sha4')
                ('\n')
                ('5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 ')
                ($ Id.VSub_DollarName '$commit_sha3')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:827)
              fd: -1
              arg_word: {(expect_notes_m)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:847)
          fd: -1
          arg_word: {(expect_log_m)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:850)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 873
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('y and z notes on 4th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('y notes on 3rd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('y and z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'do not allow mixing --commit and --abort' span_id:878))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:882) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge --commit --abort\n'
            span_id: 883
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'do not allow mixing --commit and --strategy' span_id:890))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:894) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge --commit --strategy theirs\n'
            span_id: 895
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'do not allow mixing --abort and --strategy' span_id:902))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:906) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge --abort --strategy theirs\n'
            span_id: 907
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'finalize conflicting merge (z => m)' span_id:914))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:918) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Resolve conflicts and finalize merge\n'
            span_id: 919
          ) (Token id:Id.Lit_Chars val:'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n' span_id:920) 
          (Token id:Id.Lit_Chars val:'y and z notes on 1st commit\n' span_id:921) (Token id:Id.Lit_Chars val:'EOF\n' span_id:922) 
          (Token
            id: Id.Lit_Chars
            val: '\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha4 <<EOF &&\n'
            span_id: 923
          ) (Token id:Id.Lit_Chars val:'y and z notes on 4th commit\n' span_id:924) 
          (Token id:Id.Lit_Chars val:'EOF\n' span_id:925) (Token id:Id.Lit_Chars val:'\tgit notes merge --commit &&\n' span_id:926) 
          (Token id:Id.Lit_Chars val:'\t# No .git/NOTES_MERGE_* files left\n' span_id:927) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'
            span_id: 928
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp /dev/null output &&\n' span_id:929) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Merge commit has pre-merge y and pre-merge z as parents\n'
            span_id: 930
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&\n'
            span_id: 931
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&\n'
            span_id: 932
          ) (Token id:Id.Lit_Chars val:'\t# Merge commit mentions the notes refs merged\n' span_id:933) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit log -1 --format=%B refs/notes/m > merge_commit_msg &&\n'
            span_id: 934
          ) (Token id:Id.Lit_Chars val:'\tgrep -q refs/notes/m merge_commit_msg &&\n' span_id:935) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q refs/notes/z merge_commit_msg &&\n'
            span_id: 936
          ) (Token id:Id.Lit_Chars val:'\t# Merge commit mentions conflicting notes\n' span_id:937) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q "Conflicts" merge_commit_msg &&\n'
            span_id: 938
          ) (Token id:Id.Lit_Chars val:'\t( for sha1 in $(cat expect_conflicts); do\n' span_id:939) 
          (Token
            id: Id.Lit_Chars
            val: '\t\tgrep -q "$sha1" merge_commit_msg ||\n'
            span_id: 940
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:941) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:942) (Token id:Id.Lit_Chars val:'\t# Verify contents of merge result\n' span_id:943) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:944) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (w, x, y and z)\n'
            span_id: 945
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:946) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:947) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:948) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:949)
        )
      }
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:955)
          fd: -1
          arg_word: {(expect_conflict_) ($ Id.VSub_DollarName '$commit_sha4')}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:959)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 970
          stdin_parts: [
            ('<<<<<<< refs/notes/m\n')
            ('y notes on 4th commit\n')
            ('=======\n')
            ('z notes on 4th commit\n')
            ('\n')
            ('More z notes on 4th commit\n')
            ('>>>>>>> refs/notes/z\n')
          ]
        )
      ]
    )
    (C {(cp)} {(expect_notes_y)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_y)} {(expect_log_m)})
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:991)
          fd: -1
          arg_word: {(pre_merge_y)}
        )
      ]
    )
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:1001)
          fd: -1
          arg_word: {(pre_merge_z)}
        )
      ]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
            span_id: 1009
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1013) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/m refs/notes/y &&\n'
            span_id: 1014
          ) (Token id:Id.Lit_Chars val:'\tgit config core.notesRef refs/notes/m &&\n' span_id:1015) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge z >output &&\n'
            span_id: 1016
          ) (Token id:Id.Lit_Chars val:'\t# Output should point to where to resolve conflicts\n' span_id:1017) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'
            span_id: 1018
          ) (Token id:Id.Lit_Chars val:'\t# Inspect merge conflicts\n' span_id:1019) 
          (Token
            id: Id.Lit_Chars
            val: '\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'
            span_id: 1020
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect_conflicts output_conflicts &&\n' span_id:1021) 
          (Token
            id: Id.Lit_Chars
            val: '\t( for f in $(cat expect_conflicts); do\n'
            span_id: 1022
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'
            span_id: 1023
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:1024) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:1025) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'
            span_id: 1026
          ) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1027) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:1028) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'
            span_id: 1029
          )
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'abort notes merge' span_id:1036))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1040) 
          (Token id:Id.Lit_Chars val:'\tgit notes merge --abort &&\n' span_id:1041) (Token id:Id.Lit_Chars val:'\t# No .git/NOTES_MERGE_* files left\n' span_id:1042) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'
            span_id: 1043
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp /dev/null output &&\n' span_id:1044) 
          (Token id:Id.Lit_Chars val:'\t# m has not moved (still == y)\n' span_id:1045) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&\n'
            span_id: 1046
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (w, x, y and z)\n'
            span_id: 1047
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:1048) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:1049) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1050) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:1051)
        )
      }
    )
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:1061)
          fd: -1
          arg_word: {(pre_merge_y)}
        )
      ]
    )
    (command.Simple
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:1071)
          fd: -1
          arg_word: {(pre_merge_z)}
        )
      ]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
            span_id: 1079
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1083) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge z >output &&\n'
            span_id: 1084
          ) (Token id:Id.Lit_Chars val:'\t# Output should point to where to resolve conflicts\n' span_id:1085) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'
            span_id: 1086
          ) (Token id:Id.Lit_Chars val:'\t# Inspect merge conflicts\n' span_id:1087) 
          (Token
            id: Id.Lit_Chars
            val: '\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'
            span_id: 1088
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect_conflicts output_conflicts &&\n' span_id:1089) 
          (Token
            id: Id.Lit_Chars
            val: '\t( for f in $(cat expect_conflicts); do\n'
            span_id: 1090
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'
            span_id: 1091
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:1092) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:1093) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'
            span_id: 1094
          ) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1095) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:1096) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'
            span_id: 1097
          )
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: (Token id:Id.Redir_DLess val:'<<' span_id:1103)
              fd: -1
              here_begin: {(EOF)}
              here_end_span_id: 1123
              stdin_parts: [
                ('304dfb4325cf243025b9957486eb605a9b51c199 ')
                ($ Id.VSub_DollarName '$commit_sha5')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ Id.VSub_DollarName '$commit_sha2')
                ('\n')
                ('0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 ')
                ($ Id.VSub_DollarName '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.Simple
          words: [{(sort)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:1110)
              fd: -1
              arg_word: {(expect_notes_m)}
            )
          ]
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:1127)
          fd: -1
          arg_word: {(expect_log_m)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:1130)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 1152
          stdin_parts: [
            ($ Id.VSub_DollarName '$commit_sha5')
            (' 5th\n')
            ('new note on 5th commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha4')
            (' 4th\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ Id.VSub_DollarName '$commit_sha1')
            (' 1st\n')
            ('y and z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'add + remove notes in finalized merge (z => m)' span_id:1157))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1161) 
          (Token id:Id.Lit_Chars val:'\t# Resolve one conflict\n' span_id:1162) (Token id:Id.Lit_Chars val:'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n' span_id:1163) 
          (Token id:Id.Lit_Chars val:'y and z notes on 1st commit\n' span_id:1164) (Token id:Id.Lit_Chars val:'EOF\n' span_id:1165) 
          (Token id:Id.Lit_Chars val:'\t# Remove another conflict\n' span_id:1166) (Token id:Id.Lit_Chars val:'\trm .git/NOTES_MERGE_WORKTREE/$commit_sha4 &&\n' span_id:1167) 
          (Token id:Id.Lit_Chars val:'\t# Remove a D/F conflict\n' span_id:1168) (Token id:Id.Lit_Chars val:'\trm .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&\n' span_id:1169) 
          (Token id:Id.Lit_Chars val:'\t# Add a new note\n' span_id:1170) 
          (Token
            id: Id.Lit_Chars
            val: '\techo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 &&\n'
            span_id: 1171
          ) (Token id:Id.Lit_Chars val:'\t# Finalize merge\n' span_id:1172) 
          (Token id:Id.Lit_Chars val:'\tgit notes merge --commit &&\n' span_id:1173) (Token id:Id.Lit_Chars val:'\t# No .git/NOTES_MERGE_* files left\n' span_id:1174) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'
            span_id: 1175
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp /dev/null output &&\n' span_id:1176) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Merge commit has pre-merge y and pre-merge z as parents\n'
            span_id: 1177
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&\n'
            span_id: 1178
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&\n'
            span_id: 1179
          ) (Token id:Id.Lit_Chars val:'\t# Merge commit mentions the notes refs merged\n' span_id:1180) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit log -1 --format=%B refs/notes/m > merge_commit_msg &&\n'
            span_id: 1181
          ) (Token id:Id.Lit_Chars val:'\tgrep -q refs/notes/m merge_commit_msg &&\n' span_id:1182) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q refs/notes/z merge_commit_msg &&\n'
            span_id: 1183
          ) (Token id:Id.Lit_Chars val:'\t# Merge commit mentions conflicting notes\n' span_id:1184) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q "Conflicts" merge_commit_msg &&\n'
            span_id: 1185
          ) (Token id:Id.Lit_Chars val:'\t( for sha1 in $(cat expect_conflicts); do\n' span_id:1186) 
          (Token
            id: Id.Lit_Chars
            val: '\t\tgrep -q "$sha1" merge_commit_msg ||\n'
            span_id: 1187
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:1188) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:1189) (Token id:Id.Lit_Chars val:'\t# Verify contents of merge result\n' span_id:1190) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:1191) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (w, x, y and z)\n'
            span_id: 1192
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:1193) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:1194) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1195) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:1196)
        )
      }
    )
    (C {(cp)} {(expect_notes_y)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_y)} {(expect_log_m)})
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
            span_id: 1216
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1220) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/m refs/notes/y &&\n'
            span_id: 1221
          ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git notes merge z >output &&\n' span_id:1222) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Output should point to where to resolve conflicts\n'
            span_id: 1223
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'
            span_id: 1224
          ) (Token id:Id.Lit_Chars val:'\t# Inspect merge conflicts\n' span_id:1225) 
          (Token
            id: Id.Lit_Chars
            val: '\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'
            span_id: 1226
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect_conflicts output_conflicts &&\n' span_id:1227) 
          (Token
            id: Id.Lit_Chars
            val: '\t( for f in $(cat expect_conflicts); do\n'
            span_id: 1228
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'
            span_id: 1229
          ) (Token id:Id.Lit_Chars val:'\t\texit 1\n' span_id:1230) 
          (Token id:Id.Lit_Chars val:'\tdone ) &&\n' span_id:1231) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'
            span_id: 1232
          ) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1233) 
          (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:1234) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'
            span_id: 1235
          )
        )
      }
    )
    (C {(cp)} {(expect_notes_w)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_w)} {(expect_log_m)})
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'reset notes ref m to somewhere else (w)' span_id:1255))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1259) 
          (Token
            id: Id.Lit_Chars
            val: '\tgit update-ref refs/notes/m refs/notes/w &&\n'
            span_id: 1260
          ) (Token id:Id.Lit_Chars val:'\tverify_notes m &&\n' span_id:1261) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)"\n'
            span_id: 1262
          )
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 
'fail to finalize conflicting merge if underlying ref has moved in the meantime (m != NOTES_MERGE_PARTIAL^1)'
            span_id: 1269
          )
        )
      } 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1273) 
          (Token id:Id.Lit_Chars val:'\t# Resolve conflicts\n' span_id:1274) (Token id:Id.Lit_Chars val:'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n' span_id:1275) 
          (Token id:Id.Lit_Chars val:'y and z notes on 1st commit\n' span_id:1276) (Token id:Id.Lit_Chars val:'EOF\n' span_id:1277) 
          (Token
            id: Id.Lit_Chars
            val: '\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha4 <<EOF &&\n'
            span_id: 1278
          ) (Token id:Id.Lit_Chars val:'y and z notes on 4th commit\n' span_id:1279) 
          (Token id:Id.Lit_Chars val:'EOF\n' span_id:1280) (Token id:Id.Lit_Chars val:'\t# Fail to finalize merge\n' span_id:1281) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge --commit >output 2>&1 &&\n'
            span_id: 1282
          ) (Token id:Id.Lit_Chars val:'\t# .git/NOTES_MERGE_* must remain\n' span_id:1283) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -f .git/NOTES_MERGE_PARTIAL &&\n'
            span_id: 1284
          ) (Token id:Id.Lit_Chars val:'\ttest -f .git/NOTES_MERGE_REF &&\n' span_id:1285) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha1 &&\n'
            span_id: 1286
          ) (Token id:Id.Lit_Chars val:'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha2 &&\n' span_id:1287) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&\n'
            span_id: 1288
          ) (Token id:Id.Lit_Chars val:'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha4 &&\n' span_id:1289) 
          (Token id:Id.Lit_Chars val:'\t# Refs are unchanged\n' span_id:1290) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&\n'
            span_id: 1291
          ) 
          (Token
            id: Id.Lit_Chars
            val: 
'\ttest "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&\n'
            span_id: 1292
          ) 
          (Token
            id: Id.Lit_Chars
            val: 
'\ttest "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&\n'
            span_id: 1293
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Mention refs/notes/m, and its current and expected value in output\n'
            span_id: 1294
          ) (Token id:Id.Lit_Chars val:'\tgrep -q "refs/notes/m" output &&\n' span_id:1295) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q "$(git rev-parse refs/notes/m)" output &&\n'
            span_id: 1296
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\tgrep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output &&\n'
            span_id: 1297
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (w, x, y and z)\n'
            span_id: 1298
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:1299) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:1300) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1301) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:1302)
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'resolve situation by aborting the notes merge' span_id:1309))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1313) 
          (Token id:Id.Lit_Chars val:'\tgit notes merge --abort &&\n' span_id:1314) (Token id:Id.Lit_Chars val:'\t# No .git/NOTES_MERGE_* files left\n' span_id:1315) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'
            span_id: 1316
          ) (Token id:Id.Lit_Chars val:'\ttest_cmp /dev/null output &&\n' span_id:1317) 
          (Token id:Id.Lit_Chars val:'\t# m has not moved (still == w)\n' span_id:1318) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&\n'
            span_id: 1319
          ) 
          (Token
            id: Id.Lit_Chars
            val: '\t# Verify that other notes refs has not changed (w, x, y and z)\n'
            span_id: 1320
          ) (Token id:Id.Lit_Chars val:'\tverify_notes w &&\n' span_id:1321) 
          (Token id:Id.Lit_Chars val:'\tverify_notes x &&\n' span_id:1322) (Token id:Id.Lit_Chars val:'\tverify_notes y &&\n' span_id:1323) 
          (Token id:Id.Lit_Chars val:'\tverify_notes z\n' span_id:1324)
        )
      }
    )
    (command.Simple
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: (Token id:Id.Redir_Great val:'>' span_id:1330)
          fd: -1
          arg_word: {(expect_notes)}
        )
        (redir.HereDoc
          op: (Token id:Id.Redir_DLess val:'<<' span_id:1333)
          fd: -1
          here_begin: {(EOF)}
          here_end_span_id: 1339
          stdin_parts: [('foo\n') ('bar\n')]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'switch cwd before committing notes merge' span_id:1344))} 
      {
        (SQ (Token id:Id.Lit_Chars val:'\n' span_id:1348) 
          (Token id:Id.Lit_Chars val:'\tgit notes add -m foo HEAD &&\n' span_id:1349) (Token id:Id.Lit_Chars val:'\tgit notes --ref=other add -m bar HEAD &&\n' span_id:1350) 
          (Token
            id: Id.Lit_Chars
            val: '\ttest_must_fail git notes merge refs/notes/other &&\n'
            span_id: 1351
          ) (Token id:Id.Lit_Chars val:'\t(\n' span_id:1352) 
          (Token id:Id.Lit_Chars val:'\t\tcd .git/NOTES_MERGE_WORKTREE &&\n' span_id:1353) (Token id:Id.Lit_Chars val:'\t\techo "foo" > $(git rev-parse HEAD) &&\n' span_id:1354) 
          (Token
            id: Id.Lit_Chars
            val: '\t\techo "bar" >> $(git rev-parse HEAD) &&\n'
            span_id: 1355
          ) (Token id:Id.Lit_Chars val:'\t\tgit notes merge --commit\n' span_id:1356) 
          (Token id:Id.Lit_Chars val:'\t) &&\n' span_id:1357) (Token id:Id.Lit_Chars val:'\tgit notes show HEAD > actual_notes &&\n' span_id:1358) 
          (Token id:Id.Lit_Chars val:'\ttest_cmp expect_notes actual_notes\n' span_id:1359)
        )
      }
    )
    (C {(test_done)})
  ]
)