(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[21])
          op: Equal
          rhs: {(SQ <'Test notes merging with manual conflict resolution'>)}
          spids: [21]
        )
      ]
      spids: [21]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <'setup commits'>)} 
      {
        (SQ <'\n'> <'\ttest_commit 1st &&\n'> <'\ttest_commit 2nd &&\n'> <'\ttest_commit 3rd &&\n'> 
          <'\ttest_commit 4th &&\n'> <'\ttest_commit 5th\n'>
        )
      }
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha1 spids:[51])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(1st) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [52 62]
              )
            }
          spids: [51]
        )
      ]
      spids: [51]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha2 spids:[64])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(2nd) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [65 75]
              )
            }
          spids: [64]
        )
      ]
      spids: [64]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha3 spids:[77])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(3rd) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [78 88]
              )
            }
          spids: [77]
        )
      ]
      spids: [77]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha4 spids:[90])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(4th) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [91 101]
              )
            }
          spids: [90]
        )
      ]
      spids: [90]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha5 spids:[103])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(5th) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [104 114]
              )
            }
          spids: [103]
        )
      ]
      spids: [103]
    )
    (command.FuncDef
      name: verify_notes
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:notes_ref spids:[125])
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                  spids: [125]
                )
              ]
              spids: [125]
            )
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {(git)} {(-c)} 
                      {(core.notesRef) (Lit_Other '=') (DQ (refs/notes/) ($ VSub_Name '$notes_ref'))} {(notes)}
                    )
                    (command.SimpleCommand
                      words: [{(sort)}]
                      redirects: [
                        (redir.Redir
                          op: <Redir_Great '>'>
                          fd: 16777215
                          arg_word: {(DQ (output_notes_) ($ VSub_Name '$notes_ref'))}
                        )
                      ]
                    )
                  ]
                  negated: F
                )
                (C {(test_cmp)} {(DQ (expect_notes_) ($ VSub_Name '$notes_ref'))} 
                  {(DQ (output_notes_) ($ VSub_Name '$notes_ref'))}
                )
                (command.SimpleCommand
                  words: [
                    {(git)}
                    {(-c)}
                    {(core.notesRef) (Lit_Other '=') (DQ (refs/notes/) ($ VSub_Name '$notes_ref'))}
                    {(log)}
                    {(--format) (Lit_Other '=') (DQ ('%H %s%n%N'))}
                  ]
                  redirects: [
                    (redir.Redir
                      op: <Redir_Great '>'>
                      fd: 16777215
                      arg_word: {(DQ (output_log_) ($ VSub_Name '$notes_ref'))}
                    )
                  ]
                )
                (C {(test_cmp)} {(DQ (expect_log_) ($ VSub_Name '$notes_ref'))} 
                  {(DQ (output_log_) ($ VSub_Name '$notes_ref'))}
                )
              ]
            )
          ]
          spids: [122]
        )
      spids: [117 121]
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 240
              stdin_parts: [
                ('6e8e3febca3c2bb896704335cc4d0c34cb2f8715 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('e5388c10860456ee60673025345fe2e153eb8cf8 ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_x)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_x)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 269
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('x notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('x notes on 3rd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'setup merge base (x)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/x &&\n'> 
          <'\tgit notes add -m "x notes on 2nd commit" 2nd &&\n'> <'\tgit notes add -m "x notes on 3rd commit" 3rd &&\n'> 
          <'\tgit notes add -m "x notes on 4th commit" 4th &&\n'> <'\tverify_notes x\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 309
              stdin_parts: [
                ('e2bfd06a37dd2031684a59a6e2b033e212239c78 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('b0a6021ec006d07e80e9b20ec9b444cbd9d560d3 ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_y)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_y)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 338
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('y notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('y notes on 3rd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('y notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'setup local branch (y)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/y refs/notes/x &&\n'> 
          <'\tgit config core.notesRef refs/notes/y &&\n'> <'\tgit notes add -f -m "y notes on 1st commit" 1st &&\n'> <'\tgit notes remove 2nd &&\n'> 
          <'\tgit notes add -f -m "y notes on 3rd commit" 3rd &&\n'> <'\tgit notes add -f -m "y notes on 4th commit" 4th &&\n'> <'\tverify_notes y\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 380
              stdin_parts: [
                ('cff59c793c20bb49a4e01bc06fb06bad642e0d54 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('0a81da8956346e19bcb27a906f04af327e03e31b ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_z)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_z)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 409
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('z notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'setup remote branch (z)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/z refs/notes/x &&\n'> 
          <'\tgit config core.notesRef refs/notes/z &&\n'> <'\tgit notes add -f -m "z notes on 1st commit" 1st &&\n'> 
          <'\tgit notes add -f -m "z notes on 2nd commit" 2nd &&\n'> <'\tgit notes remove 3rd &&\n'> <'\tgit notes add -f -m "z notes on 4th commit" 4th &&\n'> 
          <'\tverify_notes z\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 478
              stdin_parts: [
                ($ VSub_Name '$commit_sha1')
                ('\n')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ($ VSub_Name '$commit_sha4')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_conflicts)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: <Redir_Great '>'>
          fd: 16777215
          arg_word: {(expect_conflict_) ($ VSub_Name '$commit_sha1')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 495
          stdin_parts: [
            ('<<<<<<< refs/notes/m\n')
            ('y notes on 1st commit\n')
            ('=======\n')
            ('z notes on 1st commit\n')
            ('>>>>>>> refs/notes/z\n')
          ]
        )
      ]
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: <Redir_Great '>'>
          fd: 16777215
          arg_word: {(expect_conflict_) ($ VSub_Name '$commit_sha2')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 508
          stdin_parts: [('z notes on 2nd commit\n')]
        )
      ]
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: <Redir_Great '>'>
          fd: 16777215
          arg_word: {(expect_conflict_) ($ VSub_Name '$commit_sha3')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 521
          stdin_parts: [('y notes on 3rd commit\n')]
        )
      ]
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: <Redir_Great '>'>
          fd: 16777215
          arg_word: {(expect_conflict_) ($ VSub_Name '$commit_sha4')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 538
          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.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_y)})]
    )
    (command.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_z)})]
    )
    (C {(test_expect_success)} 
      {(SQ <'merge z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/y &&\n'> 
          <'\tgit config core.notesRef refs/notes/m &&\n'> <'\ttest_must_fail git notes merge z >output &&\n'> 
          <'\t# Output should point to where to resolve conflicts\n'> <'\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'> <'\t# Inspect merge conflicts\n'> 
          <'\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'> <'\ttest_cmp expect_conflicts output_conflicts &&\n'> <'\t( for f in $(cat expect_conflicts); do\n'> 
          <'\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'> <'\t\texit 1\n'> <'\tdone ) &&\n'> 
          <'\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'> <'\tverify_notes y &&\n'> <'\tverify_notes m &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 623
              stdin_parts: [
                ('00494adecf2d9635a02fa431308d67993f853968 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('0a81da8956346e19bcb27a906f04af327e03e31b ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_z)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_z)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 654
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('z notes on 4th commit\n')
            ('\n')
            ('More z notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'change notes in z'>)} 
      {
        (SQ <'\n'> <'\tgit notes --ref z append -m "More z notes on 4th commit" 4th &&\n'> 
          <'\tverify_notes z\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'cannot do merge w/conflicts when previous merge is unfinished'>)} 
      {
        (SQ <'\n'> <'\ttest -d .git/NOTES_MERGE_WORKTREE &&\n'> 
          <'\ttest_must_fail git notes merge z >output 2>&1 &&\n'> <'\t# Output should indicate what is wrong\n'> 
          <'\ttest_i18ngrep -q "\\\\.git/NOTES_MERGE_\\\\* exists" output\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 707
              stdin_parts: [
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('f75d1df88cbfe4258d49852f26cfc83f2ad4494b ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_w)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_w)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 735
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('w notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'setup unrelated notes ref (w)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/w &&\n'> 
          <'\tgit notes add -m "w notes on 1st commit" 1st &&\n'> <'\tgit notes add -m "x notes on 2nd commit" 2nd &&\n'> <'\tverify_notes w\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 777
              stdin_parts: [
                ('6e8e3febca3c2bb896704335cc4d0c34cb2f8715 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('e5388c10860456ee60673025345fe2e153eb8cf8 ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('ceefa674873670e7ecd131814d909723cce2b669 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('f75d1df88cbfe4258d49852f26cfc83f2ad4494b ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_w)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_w)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 807
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('x notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('x notes on 3rd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('x notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('w notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ <'can do merge without conflicts even if previous merge is unfinished (x => w)'>)} 
      {
        (SQ <'\n'> <'\ttest -d .git/NOTES_MERGE_WORKTREE &&\n'> <'\tgit notes merge x &&\n'> 
          <'\tverify_notes w &&\n'> <'\t# Verify that other notes refs has not changed (x and y)\n'> <'\tverify_notes x &&\n'> 
          <'\tverify_notes y\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 851
              stdin_parts: [
                ('021faa20e931fb48986ffc6282b4bb05553ac946 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('5772f42408c0dd6f097a7ca2d24de0e78d1c46b1 ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_m)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_m)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 881
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('y and z notes on 4th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('y notes on 3rd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('y and z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'do not allow mixing --commit and --abort'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git notes merge --commit --abort\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'do not allow mixing --commit and --strategy'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git notes merge --commit --strategy theirs\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'do not allow mixing --abort and --strategy'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git notes merge --abort --strategy theirs\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'finalize conflicting merge (z => m)'>)} 
      {
        (SQ <'\n'> <'\t# Resolve conflicts and finalize merge\n'> 
          <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n'> <'y and z notes on 1st commit\n'> <'EOF\n'> 
          <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha4 <<EOF &&\n'> <'y and z notes on 4th commit\n'> <'EOF\n'> <'\tgit notes merge --commit &&\n'> 
          <'\t# No .git/NOTES_MERGE_* files left\n'> <'\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'> 
          <'\ttest_cmp /dev/null output &&\n'> <'\t# Merge commit has pre-merge y and pre-merge z as parents\n'> 
          <'\ttest "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&\n'> <'\ttest "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&\n'> 
          <'\t# Merge commit mentions the notes refs merged\n'> <'\tgit log -1 --format=%B refs/notes/m > merge_commit_msg &&\n'> 
          <'\tgrep -q refs/notes/m merge_commit_msg &&\n'> <'\tgrep -q refs/notes/z merge_commit_msg &&\n'> <'\t# Merge commit mentions conflicting notes\n'> 
          <'\tgrep -q "Conflicts" merge_commit_msg &&\n'> <'\t( for sha1 in $(cat expect_conflicts); do\n'> <'\t\tgrep -q "$sha1" merge_commit_msg ||\n'> 
          <'\t\texit 1\n'> <'\tdone ) &&\n'> <'\t# Verify contents of merge result\n'> <'\tverify_notes m &&\n'> 
          <'\t# Verify that other notes refs has not changed (w, x, y and z)\n'> <'\tverify_notes w &&\n'> <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes z\n'>
        )
      }
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir
          op: <Redir_Great '>'>
          fd: 16777215
          arg_word: {(expect_conflict_) ($ VSub_Name '$commit_sha4')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 978
          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.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_y)})]
    )
    (command.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_z)})]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          <
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
          >
        )
      } 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/y &&\n'> 
          <'\tgit config core.notesRef refs/notes/m &&\n'> <'\ttest_must_fail git notes merge z >output &&\n'> 
          <'\t# Output should point to where to resolve conflicts\n'> <'\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'> <'\t# Inspect merge conflicts\n'> 
          <'\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'> <'\ttest_cmp expect_conflicts output_conflicts &&\n'> <'\t( for f in $(cat expect_conflicts); do\n'> 
          <'\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'> <'\t\texit 1\n'> <'\tdone ) &&\n'> 
          <'\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'> <'\tverify_notes y &&\n'> <'\tverify_notes m &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'abort notes merge'>)} 
      {
        (SQ <'\n'> <'\tgit notes merge --abort &&\n'> <'\t# No .git/NOTES_MERGE_* files left\n'> 
          <'\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'> <'\ttest_cmp /dev/null output &&\n'> <'\t# m has not moved (still == y)\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&\n'> <'\t# Verify that other notes refs has not changed (w, x, y and z)\n'> <'\tverify_notes w &&\n'> 
          <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes z\n'>
        )
      }
    )
    (command.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/y)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_y)})]
    )
    (command.SimpleCommand
      words: [{(git)} {(rev-parse)} {(refs/notes/z)}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(pre_merge_z)})]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          <
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
          >
        )
      } 
      {
        (SQ <'\n'> <'\ttest_must_fail git notes merge z >output &&\n'> 
          <'\t# Output should point to where to resolve conflicts\n'> <'\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'> <'\t# Inspect merge conflicts\n'> 
          <'\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'> <'\ttest_cmp expect_conflicts output_conflicts &&\n'> <'\t( for f in $(cat expect_conflicts); do\n'> 
          <'\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'> <'\t\texit 1\n'> <'\tdone ) &&\n'> 
          <'\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'> <'\tverify_notes y &&\n'> <'\tverify_notes m &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 1131
              stdin_parts: [
                ('304dfb4325cf243025b9957486eb605a9b51c199 ')
                ($ VSub_Name '$commit_sha5')
                ('\n')
                ('283b48219aee9a4105f6cab337e789065c82c2b9 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('0a59e787e6d688aa6309e56e8c1b89431a0fc1c1 ')
                ($ VSub_Name '$commit_sha1')
                ('\n')
              ]
            )
          ]
        )
        (command.SimpleCommand
          words: [{(sort)}]
          redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes_m)})]
        )
      ]
      negated: F
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_log_m)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 1160
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' 5th\n')
            ('new note on 5th commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' 4th\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' 3rd\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' 2nd\n')
            ('z notes on 2nd commit\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' 1st\n')
            ('y and z notes on 1st commit\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'add + remove notes in finalized merge (z => m)'>)} 
      {
        (SQ <'\n'> <'\t# Resolve one conflict\n'> 
          <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n'> <'y and z notes on 1st commit\n'> <'EOF\n'> <'\t# Remove another conflict\n'> 
          <'\trm .git/NOTES_MERGE_WORKTREE/$commit_sha4 &&\n'> <'\t# Remove a D/F conflict\n'> <'\trm .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&\n'> 
          <'\t# Add a new note\n'> <'\techo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 &&\n'> 
          <'\t# Finalize merge\n'> <'\tgit notes merge --commit &&\n'> <'\t# No .git/NOTES_MERGE_* files left\n'> 
          <'\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'> <'\ttest_cmp /dev/null output &&\n'> <'\t# Merge commit has pre-merge y and pre-merge z as parents\n'> 
          <'\ttest "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&\n'> <'\ttest "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&\n'> 
          <'\t# Merge commit mentions the notes refs merged\n'> <'\tgit log -1 --format=%B refs/notes/m > merge_commit_msg &&\n'> 
          <'\tgrep -q refs/notes/m merge_commit_msg &&\n'> <'\tgrep -q refs/notes/z merge_commit_msg &&\n'> <'\t# Merge commit mentions conflicting notes\n'> 
          <'\tgrep -q "Conflicts" merge_commit_msg &&\n'> <'\t( for sha1 in $(cat expect_conflicts); do\n'> <'\t\tgrep -q "$sha1" merge_commit_msg ||\n'> 
          <'\t\texit 1\n'> <'\tdone ) &&\n'> <'\t# Verify contents of merge result\n'> <'\tverify_notes m &&\n'> 
          <'\t# Verify that other notes refs has not changed (w, x, y and z)\n'> <'\tverify_notes w &&\n'> <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes z\n'>
        )
      }
    )
    (C {(cp)} {(expect_notes_y)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_y)} {(expect_log_m)})
    (C {(test_expect_success)} 
      {
        (SQ 
          <
'redo merge of z into m (== y) with default ("manual") resolver => Conflicting 3-way merge'
          >
        )
      } 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/y &&\n'> 
          <'\ttest_must_fail git notes merge z >output &&\n'> <'\t# Output should point to where to resolve conflicts\n'> 
          <'\ttest_i18ngrep "\\\\.git/NOTES_MERGE_WORKTREE" output &&\n'> <'\t# Inspect merge conflicts\n'> <'\tls .git/NOTES_MERGE_WORKTREE >output_conflicts &&\n'> 
          <'\ttest_cmp expect_conflicts output_conflicts &&\n'> <'\t( for f in $(cat expect_conflicts); do\n'> 
          <'\t\ttest_cmp "expect_conflict_$f" ".git/NOTES_MERGE_WORKTREE/$f" ||\n'> <'\t\texit 1\n'> <'\tdone ) &&\n'> 
          <'\t# Verify that current notes tree (pre-merge) has not changed (m == y)\n'> <'\tverify_notes y &&\n'> <'\tverify_notes m &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)"\n'>
        )
      }
    )
    (C {(cp)} {(expect_notes_w)} {(expect_notes_m)})
    (C {(cp)} {(expect_log_w)} {(expect_log_m)})
    (C {(test_expect_success)} {(SQ <'reset notes ref m to somewhere else (w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> <'\tverify_notes m &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)"\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          <
'fail to finalize conflicting merge if underlying ref has moved in the meantime (m != NOTES_MERGE_PARTIAL^1)'
          >
        )
      } 
      {
        (SQ <'\n'> <'\t# Resolve conflicts\n'> 
          <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha1 <<EOF &&\n'> <'y and z notes on 1st commit\n'> <'EOF\n'> 
          <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha4 <<EOF &&\n'> <'y and z notes on 4th commit\n'> <'EOF\n'> <'\t# Fail to finalize merge\n'> 
          <'\ttest_must_fail git notes merge --commit >output 2>&1 &&\n'> <'\t# .git/NOTES_MERGE_* must remain\n'> <'\ttest -f .git/NOTES_MERGE_PARTIAL &&\n'> 
          <'\ttest -f .git/NOTES_MERGE_REF &&\n'> <'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha1 &&\n'> 
          <'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha2 &&\n'> <'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 &&\n'> 
          <'\ttest -f .git/NOTES_MERGE_WORKTREE/$commit_sha4 &&\n'> <'\t# Refs are unchanged\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&\n'> <'\ttest "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&\n'> 
          <
'\ttest "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" &&\n'
          > <'\t# Mention refs/notes/m, and its current and expected value in output\n'> 
          <'\tgrep -q "refs/notes/m" output &&\n'> <'\tgrep -q "$(git rev-parse refs/notes/m)" output &&\n'> 
          <'\tgrep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output &&\n'> <'\t# Verify that other notes refs has not changed (w, x, y and z)\n'> <'\tverify_notes w &&\n'> 
          <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes z\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'resolve situation by aborting the notes merge'>)} 
      {
        (SQ <'\n'> <'\tgit notes merge --abort &&\n'> <'\t# No .git/NOTES_MERGE_* files left\n'> 
          <'\ttest_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&\n'> <'\ttest_cmp /dev/null output &&\n'> <'\t# m has not moved (still == w)\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&\n'> <'\t# Verify that other notes refs has not changed (w, x, y and z)\n'> <'\tverify_notes w &&\n'> 
          <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes z\n'>
        )
      }
    )
    (command.SimpleCommand
      words: [{(cat)}]
      redirects: [
        (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect_notes)})
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 1347
          stdin_parts: [('foo\n') ('bar\n')]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'switch cwd before committing notes merge'>)} 
      {
        (SQ <'\n'> <'\tgit notes add -m foo HEAD &&\n'> 
          <'\tgit notes --ref=other add -m bar HEAD &&\n'> <'\ttest_must_fail git notes merge refs/notes/other &&\n'> <'\t(\n'> 
          <'\t\tcd .git/NOTES_MERGE_WORKTREE &&\n'> <'\t\techo "foo" > $(git rev-parse HEAD) &&\n'> <'\t\techo "bar" >> $(git rev-parse HEAD) &&\n'> 
          <'\t\tgit notes merge --commit\n'> <'\t) &&\n'> <'\tgit notes show HEAD > actual_notes &&\n'> <'\ttest_cmp expect_notes actual_notes\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)