(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'Test merging of notes trees'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\ttest_commit 1st &&\n'> <'\ttest_commit 2nd &&\n'> <'\ttest_commit 3rd &&\n'> 
          <'\ttest_commit 4th &&\n'> <'\ttest_commit 5th &&\n'> <'\t# Create notes on 4 first commits\n'> 
          <'\tgit config core.notesRef refs/notes/x &&\n'> <'\tgit notes add -m "Notes on 1st commit" 1st &&\n'> 
          <'\tgit notes add -m "Notes on 2nd commit" 2nd &&\n'> <'\tgit notes add -m "Notes on 3rd commit" 3rd &&\n'> 
          <'\tgit notes add -m "Notes on 4th commit" 4th &&\n'> <'\t# Copy notes to remote-notes\n'> <'\tgit fetch . refs/notes/*:refs/remote-notes/origin/*\n'>
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha1)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<git>} {<rev-parse>} 
                    {<1st> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [46]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha2)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<git>} {<rev-parse>} 
                    {<2nd> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [59]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha3)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<git>} {<rev-parse>} 
                    {<3rd> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [72]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha4)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<git>} {<rev-parse>} 
                    {<4th> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [85]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:commit_sha5)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (C {<git>} {<rev-parse>} 
                    {<5th> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [98]
        )
      ]
    )
    (command.ShFunction
      name: verify_notes
      body: 
        (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: [120]
                )
              ]
            )
            (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
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {(DQ <output_notes_> ($ Id.VSub_DollarName '$notes_ref'))}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                  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
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ <output_log_> ($ Id.VSub_DollarName '$notes_ref'))}
                    )
                  ]
                  do_fork: T
                )
                (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
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 238
                  stdin_parts: [
                    <'5e93d24084d32e1cb61f7070505b9d2530cca987 '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'8366731eeee53787d2bdf8fc1eff7d94757e8da0 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'eede89064cd42441590d6afec6c37b321ada3389 '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_x>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_x>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 268
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'Notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'Notes on 3rd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'Notes on 2nd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'verify initial notes (x)'>)} {(SQ <'\n'> <'\tverify_notes x\n'>)})
    (C {<cp>} {<expect_notes_x>} {<expect_notes_y>})
    (C {<cp>} {<expect_notes_x>} {<expect_notes_v>})
    (C {<cp>} {<expect_log_x>} {<expect_log_y>})
    (C {<cp>} {<expect_log_x>} {<expect_log_v>})
    (C {<test_expect_success>} {(SQ <'fail to merge empty notes ref into empty notes ref (z => y)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git -c "core.notesRef=refs/notes/y" notes merge z\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'fail to merge into various non-notes refs'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git -c "core.notesRef=refs/notes" notes merge x &&\n'> 
          <'\ttest_must_fail git -c "core.notesRef=refs/notes/" notes merge x &&\n'> <'\tmkdir -p .git/refs/notes/dir &&\n'> 
          <'\ttest_must_fail git -c "core.notesRef=refs/notes/dir" notes merge x &&\n'> <'\ttest_must_fail git -c "core.notesRef=refs/notes/dir/" notes merge x &&\n'> 
          <'\ttest_must_fail git -c "core.notesRef=refs/heads/master" notes merge x &&\n'> <'\ttest_must_fail git -c "core.notesRef=refs/notes/y:" notes merge x &&\n'> 
          <'\ttest_must_fail git -c "core.notesRef=refs/notes/y:foo" notes merge x &&\n'> <'\ttest_must_fail git -c "core.notesRef=refs/notes/foo^{bar" notes merge x\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'merge non-notes ref into empty notes ref (remote-notes/origin/x => v)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/v &&\n'> 
          <'\tgit notes merge refs/remote-notes/origin/x &&\n'> <'\tverify_notes v &&\n'> 
          <'\t# refs/remote-notes/origin/x and v should point to the same notes commit\n'> <'\ttest "$(git rev-parse refs/remote-notes/origin/x)" = "$(git rev-parse refs/notes/v)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'merge notes into empty notes ref (x => y)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/y &&\n'> <'\tgit notes merge x &&\n'> 
          <'\tverify_notes y &&\n'> <'\t# x and y should point to the same notes commit\n'> 
          <'\ttest "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'merge empty notes ref (z => y)'>)} 
      {
        (SQ <'\n'> <'\tgit notes merge z &&\n'> <'\t# y should not change (still == x)\n'> 
          <'\ttest "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'change notes on other notes ref (y)'>)} 
      {
        (SQ <'\n'> <'\t# Not touching notes to 1st commit\n'> <'\tgit notes remove 2nd &&\n'> 
          <'\tgit notes append -m "More notes on 3rd commit" 3rd &&\n'> <'\tgit notes add -f -m "New notes on 4th commit" 4th &&\n'> 
          <'\tgit notes add -m "Notes on 5th commit" 5th\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'merge previous notes commit (y^ => y) => No-op'>)} 
      {
        (SQ <'\n'> <'\tpre_state="$(git rev-parse refs/notes/y)" &&\n'> <'\tgit notes merge y^ &&\n'> 
          <'\t# y should not move\n'> <'\ttest "$pre_state" = "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 441
                  stdin_parts: [
                    <'0f2efbd00262f2fd41dfae33df8765618eeacd99 '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'dec2502dac3ea161543f71930044deff93fa945c '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'4069cdb399fd45463ec6eef8e051a16a03592d91 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_y>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_y>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 473
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'Notes on 5th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'New notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'Notes on 3rd commit\n'>
                <'\n'>
                <'More notes on 3rd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'verify changed notes on other notes ref (y)'>)} 
      {(SQ <'\n'> <'\tverify_notes y\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'verify unchanged notes on original notes ref (x)'>)} 
      {(SQ <'\n'> <'\tverify_notes x\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'merge original notes (x) into changed notes (y) => No-op'>)} 
      {(SQ <'\n'> <'\tgit notes merge -vvv x &&\n'> <'\tverify_notes y &&\n'> <'\tverify_notes x\n'>)}
    )
    (C {<cp>} {<expect_notes_y>} {<expect_notes_x>})
    (C {<cp>} {<expect_log_y>} {<expect_log_x>})
    (C {<test_expect_success>} {(SQ <'merge changed (y) into original (x) => Fast-forward'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/x &&\n'> <'\tgit notes merge y &&\n'> 
          <'\tverify_notes x &&\n'> <'\tverify_notes y &&\n'> <'\t# x and y should point to same the notes commit\n'> 
          <'\ttest "$(git rev-parse refs/notes/x)" = "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'merge empty notes ref (z => y)'>)} 
      {
        (SQ <'\n'> <'\t# Prepare empty (but valid) notes ref (z)\n'> 
          <'\tgit config core.notesRef refs/notes/z &&\n'> <'\tgit notes add -m "foo" &&\n'> <'\tgit notes remove &&\n'> <'\tgit notes >output_notes_z &&\n'> 
          <'\ttest_cmp /dev/null output_notes_z &&\n'> <'\t# Do the merge (z => y)\n'> <'\tgit config core.notesRef refs/notes/y &&\n'> 
          <'\tgit notes merge z &&\n'> <'\tverify_notes y &&\n'> <'\t# y should no longer point to the same notes commit as x\n'> 
          <'\ttest "$(git rev-parse refs/notes/x)" != "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 594
                  stdin_parts: [
                    <'0f2efbd00262f2fd41dfae33df8765618eeacd99 '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'dec2502dac3ea161543f71930044deff93fa945c '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'4069cdb399fd45463ec6eef8e051a16a03592d91 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'d000d30e6ddcfce3a8122c403226a2ce2fd04d9d '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'43add6bd0c8c0bc871ac7991e0f5573cfba27804 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_y>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_y>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 629
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'Notes on 5th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'New notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'Notes on 3rd commit\n'>
                <'\n'>
                <'More notes on 3rd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'New notes on 2nd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
                <'More notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'change notes on other notes ref (y)'>)} 
      {
        (SQ <'\n'> <'\t# Append to 1st commit notes\n'> 
          <'\tgit notes append -m "More notes on 1st commit" 1st &&\n'> <'\t# Add new notes to 2nd commit\n'> <'\tgit notes add -m "New notes on 2nd commit" 2nd &&\n'> 
          <'\tverify_notes y\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 669
                  stdin_parts: [
                    <'0f2efbd00262f2fd41dfae33df8765618eeacd99 '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'1f257a3a90328557c452f0817d6cc50c89d315d4 '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'daa55ffad6cb99bf64226532147ffcaf5ce8bdd1 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_x>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_x>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 700
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'Notes on 5th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'New notes on 4th commit\n'>
                <'\n'>
                <'More notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'change notes on notes ref (x)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/x &&\n'> <'\tgit notes remove 3rd &&\n'> 
          <'\tgit notes append -m "More notes on 4th commit" 4th &&\n'> <'\tverify_notes x\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 742
                  stdin_parts: [
                    <'0f2efbd00262f2fd41dfae33df8765618eeacd99 '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'1f257a3a90328557c452f0817d6cc50c89d315d4 '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'d000d30e6ddcfce3a8122c403226a2ce2fd04d9d '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'43add6bd0c8c0bc871ac7991e0f5573cfba27804 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_x>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_x>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 776
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'Notes on 5th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'New notes on 4th commit\n'>
                <'\n'>
                <'More notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'New notes on 2nd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
                <'More notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'merge y into x => Non-conflicting 3-way merge'>)} 
      {(SQ <'\n'> <'\tgit notes merge y &&\n'> <'\tverify_notes x &&\n'> <'\tverify_notes y\n'>)}
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 811
                  stdin_parts: [
                    <'05a4927951bcef347f51486575b878b2b60137f2 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'d000d30e6ddcfce3a8122c403226a2ce2fd04d9d '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_w>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_w>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 839
              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'>
                <'New notes on 3rd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'New notes on 2nd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'create notes on new, separate notes ref (w)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/w &&\n'> 
          <'\t# Add same note as refs/notes/y on 2nd commit\n'> <'\tgit notes add -m "New notes on 2nd commit" 2nd &&\n'> 
          <'\t# Add new note on 3rd commit (non-conflicting)\n'> <'\tgit notes add -m "New notes on 3rd commit" 3rd &&\n'> 
          <'\t# Verify state of notes on new, separate notes ref (w)\n'> <'\tverify_notes w\n'>
        )
      }
    )
    (command.Pipeline
      children: [
        (command.Simple
          words: [{<cat>}]
          redirects: [
            (redir
              op: <Id.Redir_DLess '<<'>
              loc: (redir_loc.Fd fd:0)
              arg: 
                (redir_param.HereDoc
                  here_begin: {<EOF>}
                  here_end_span_id: 887
                  stdin_parts: [
                    <'0f2efbd00262f2fd41dfae33df8765618eeacd99 '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'1f257a3a90328557c452f0817d6cc50c89d315d4 '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'05a4927951bcef347f51486575b878b2b60137f2 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'d000d30e6ddcfce3a8122c403226a2ce2fd04d9d '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'43add6bd0c8c0bc871ac7991e0f5573cfba27804 '>
                    ($ Id.VSub_DollarName '$commit_sha1')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_notes_x>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_x>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 922
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' 5th\n'>
                <'Notes on 5th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' 4th\n'>
                <'New notes on 4th commit\n'>
                <'\n'>
                <'More notes on 4th commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' 3rd\n'>
                <'New notes on 3rd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' 2nd\n'>
                <'New notes on 2nd commit\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' 1st\n'>
                <'Notes on 1st commit\n'>
                <'\n'>
                <'More notes on 1st commit\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'merge w into x => Non-conflicting history-less merge'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/x &&\n'> <'\tgit notes merge w &&\n'> 
          <'\t# Verify new state of notes on other notes ref (x)\n'> <'\tverify_notes x &&\n'> <'\t# Also verify that nothing changed on other notes refs (y and w)\n'> 
          <'\tverify_notes y &&\n'> <'\tverify_notes w\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)