(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'Test notes merging at various fanout levels'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (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: [32]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:commit)
                  op: assign_op.Equal
                  rhs: {(DQ ($ Id.VSub_Number '$2'))}
                  spids: [38]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.If
                  arms: [
                    (if_arm
                      cond: 
                        (condition.Shell
                          commands: [
                            (C {<test>} {<-f>} {(DQ <expect_notes_> ($ Id.VSub_DollarName '$notes_ref'))})
                          ]
                        )
                      action: [
                        (command.AndOr
                          ops: [Id.Op_DAmp Id.Op_DPipe]
                          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.ControlFlow
                              token: <Id.ControlFlow_Return return>
                              arg_word: {<1>}
                            )
                          ]
                        )
                      ]
                      spids: [44 56]
                    )
                  ]
                )
                (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'>)}
                    {(DQ ($ Id.VSub_DollarName '$commit'))}
                  ]
                  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.ShFunction
      name: verify_fanout
      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: [168]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [
                    {<git>}
                    {<rev-parse>}
                    {<--quiet>}
                    {<--verify>}
                    {(DQ <'refs/notes/'> ($ Id.VSub_DollarName '$notes_ref'))}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<'/dev/null'>}
                    )
                  ]
                  do_fork: T
                )
                (command.Pipeline
                  children: [
                    (C {<git>} {<ls-tree>} {<-r>} {<--name-only>} 
                      {(DQ <'refs/notes/'> ($ Id.VSub_DollarName '$notes_ref'))}
                    )
                    (command.WhileUntil
                      keyword: <Id.KW_While while>
                      cond: (condition.Shell commands:[(C {<read>} {<path>})])
                      body: 
                        (command.DoGroup
                          children: [
                            (command.Case
                              to_match: {(DQ ($ Id.VSub_DollarName '$path'))}
                              arms: [
                                (case_arm
                                  pat_list: [
                                    {<Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <'/'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'>
                                    }
                                  ]
                                  action: [(C {<Id.Lit_Colon ':'>} {<true>})]
                                  spids: [232 273 281 -1]
                                )
                                (case_arm
                                  pat_list: [{<Id.Lit_Star '*'>}]
                                  action: [
                                    (command.AndOr
                                      ops: [Id.Op_DAmp]
                                      children: [
                                        (C {<echo>} 
                                          {
                                            (DQ <'Invalid path '> 
                                              (word_part.EscapedLiteral
                                                token: <Id.Lit_EscapedChar '\\"'>
                                              ) ($ Id.VSub_DollarName '$path') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>)
                                            )
                                          }
                                        )
                                        (command.ControlFlow
                                          token: <Id.ControlFlow_Return return>
                                          arg_word: {<1>}
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [284 285 305 -1]
                                )
                              ]
                            )
                          ]
                        )
                    )
                  ]
                  negated: F
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: verify_no_fanout
      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: [324]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [
                    {<git>}
                    {<rev-parse>}
                    {<--quiet>}
                    {<--verify>}
                    {(DQ <'refs/notes/'> ($ Id.VSub_DollarName '$notes_ref'))}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<'/dev/null'>}
                    )
                  ]
                  do_fork: T
                )
                (command.Pipeline
                  children: [
                    (C {<git>} {<ls-tree>} {<-r>} {<--name-only>} 
                      {(DQ <'refs/notes/'> ($ Id.VSub_DollarName '$notes_ref'))}
                    )
                    (command.WhileUntil
                      keyword: <Id.KW_While while>
                      cond: (condition.Shell commands:[(C {<read>} {<path>})])
                      body: 
                        (command.DoGroup
                          children: [
                            (command.Case
                              to_match: {(DQ ($ Id.VSub_DollarName '$path'))}
                              arms: [
                                (case_arm
                                  pat_list: [
                                    {<Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> <Id.Lit_QMark '?'> 
                                      <Id.Lit_QMark '?'>
                                    }
                                  ]
                                  action: [(C {<Id.Lit_Colon ':'>} {<true>})]
                                  spids: [388 428 436 -1]
                                )
                                (case_arm
                                  pat_list: [{<Id.Lit_Star '*'>}]
                                  action: [
                                    (command.AndOr
                                      ops: [Id.Op_DAmp]
                                      children: [
                                        (C {<echo>} 
                                          {
                                            (DQ <'Invalid path '> 
                                              (word_part.EscapedLiteral
                                                token: <Id.Lit_EscapedChar '\\"'>
                                              ) ($ Id.VSub_DollarName '$path') (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>)
                                            )
                                          }
                                        )
                                        (command.ControlFlow
                                          token: <Id.ControlFlow_Return return>
                                          arg_word: {<1>}
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [439 440 460 -1]
                                )
                              ]
                            )
                          ]
                        )
                    )
                  ]
                  negated: F
                )
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'setup a few initial commits with notes (notes ref: x)'>)} 
      {
        (SQ <'\n'> <'\tgit config core.notesRef refs/notes/x &&\n'> <'\tfor i in 1 2 3 4 5\n'> 
          <'\tdo\n'> <'\t\ttest_commit "commit$i" >/dev/null &&\n'> 
          <'\t\tgit notes add -m "notes for commit$i" || return 1\n'> <'\tdone\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>} 
                    {<commit1> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [491]
        )
      ]
    )
    (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>} 
                    {<commit2> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [504]
        )
      ]
    )
    (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>} 
                    {<commit3> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [517]
        )
      ]
    )
    (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>} 
                    {<commit4> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [530]
        )
      ]
    )
    (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>} 
                    {<commit5> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <commit> <Id.Lit_RBrace '}'>}
                  )
              )
            }
          spids: [543]
        )
      ]
    )
    (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: 585
                  stdin_parts: [
                    <'aed91155c7a72c2188e781fdf40e0f3761b299db '>
                    ($ Id.VSub_DollarName '$commit_sha5')
                    <'\n'>
                    <'99fab268f9d7ee7b011e091a436c78def8eeee69 '>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                    <'953c20ae26c7aa0b428c20693fe38bc687f9d1a9 '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'6358796131b8916eaa2dde6902642942a1cb37e1 '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'b02d459c32f0e68f2fe0981033bb34f38776ba47 '>
                    ($ 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: 616
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'notes for commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'sanity check (x)'>)} 
      {(SQ <'\n'> <'\tverify_notes x commit5 &&\n'> <'\tverify_no_fanout x\n'>)}
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:num)
          op: assign_op.Equal
          rhs: {<300>}
          spids: [631]
        )
      ]
    )
    (C {<cp>} {<expect_log_x>} {<expect_log_y>})
    (C {<test_expect_success>} {(SQ <'Add a few hundred commits w/notes to trigger fanout (x -> y)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/y refs/notes/x &&\n'> 
          <'\tgit config core.notesRef refs/notes/y &&\n'> <'\ti=5 &&\n'> <'\twhile test $i -lt $num\n'> <'\tdo\n'> <'\t\ti=$(($i + 1)) &&\n'> 
          <'\t\ttest_commit "commit$i" >/dev/null &&\n'> <'\t\tgit notes add -m "notes for commit$i" || return 1\n'> <'\tdone &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/y)" != "$(git rev-parse refs/notes/x)" &&\n'> <'\t# Expected number of commits and notes\n'> <'\ttest $(git rev-list HEAD | wc -l) = $num &&\n'> 
          <'\ttest $(git notes list | wc -l) = $num &&\n'> <'\t# 5 first notes unchanged\n'> <'\tverify_notes y commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree has fanout (y)'>)} {(SQ <'verify_fanout y'>)})
    (C {<test_expect_success>} {(SQ <'No-op merge (already included) (x => y)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/y &&\n'> 
          <'\tgit config core.notesRef refs/notes/m &&\n'> <'\tgit notes merge x &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/y)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Fast-forward merge (y => x)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/x &&\n'> <'\tgit notes merge y &&\n'> 
          <'\ttest "$(git rev-parse refs/notes/m)" = "$(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: 730
                  stdin_parts: [
                    <'9f506ee70e20379d7f78204c77b334f43d77410d '>
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    <'23a47d6ea7d589895faf800752054818e1e7627b '>
                    ($ Id.VSub_DollarName '$commit_sha2')
                    <'\n'>
                    <'b02d459c32f0e68f2fe0981033bb34f38776ba47 '>
                    ($ 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_z>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_z>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 761
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'notes for commit3\n'>
                <'\n'>
                <'appended notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'change some of the initial 5 notes (x -> 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 "new notes for commit2" commit2 &&\n'> 
          <'\tgit notes append -m "appended notes for commit3" commit3 &&\n'> <'\tgit notes remove commit4 &&\n'> <'\tgit notes remove commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree has no fanout (z)'>)} {(SQ <'verify_no_fanout z'>)})
    (C {<cp>} {<expect_log_z>} {<expect_log_m>})
    (C {<test_expect_success>} {(SQ <'successful merge without conflicts (y => z)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/z &&\n'> 
          <'\tgit config core.notesRef refs/notes/m &&\n'> <'\tgit notes merge y &&\n'> <'\tverify_notes m commit5 &&\n'> <'\t# x/y/z unchanged\n'> 
          <'\tverify_notes x commit5 &&\n'> <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (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: 857
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'other notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'other notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'introduce conflicting changes (y -> w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/w refs/notes/y &&\n'> 
          <'\tgit config core.notesRef refs/notes/w &&\n'> <'\tgit notes add -f -m "other notes for commit1" commit1 &&\n'> 
          <'\tgit notes add -f -m "other notes for commit3" commit3 &&\n'> <'\tgit notes add -f -m "other notes for commit4" commit4 &&\n'> <'\tgit notes remove commit5 &&\n'> 
          <'\tverify_notes w commit5\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_m>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 905
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'other notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'other notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'successful merge using "ours" strategy (z => w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> 
          <'\tgit config core.notesRef refs/notes/m &&\n'> <'\tgit notes merge -s ours z &&\n'> <'\tverify_notes m commit5 &&\n'> <'\t# w/x/y/z unchanged\n'> 
          <'\tverify_notes w commit5 &&\n'> <'\tverify_notes x commit5 &&\n'> <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_m>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 967
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'notes for commit3\n'>
                <'\n'>
                <'appended notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'successful merge using "theirs" strategy (z => w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> 
          <'\tgit notes merge -s theirs z &&\n'> <'\tverify_notes m commit5 &&\n'> <'\t# w/x/y/z unchanged\n'> <'\tverify_notes w commit5 &&\n'> 
          <'\tverify_notes x commit5 &&\n'> <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_m>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 1031
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'other notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'other notes for commit3\n'>
                <'\n'>
                <'notes for commit3\n'>
                <'\n'>
                <'appended notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'successful merge using "union" strategy (z => w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> 
          <'\tgit notes merge -s union z &&\n'> <'\tverify_notes m commit5 &&\n'> <'\t# w/x/y/z unchanged\n'> <'\tverify_notes w commit5 &&\n'> 
          <'\tverify_notes x commit5 &&\n'> <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_m>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 1093
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'other notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'appended notes for commit3\n'>
                <'notes for commit3\n'>
                <'other notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'successful merge using "cat_sort_uniq" strategy (z => w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> 
          <'\tgit notes merge -s cat_sort_uniq z &&\n'> <'\tverify_notes m commit5 &&\n'> <'\t# w/x/y/z unchanged\n'> <'\tverify_notes w commit5 &&\n'> 
          <'\tverify_notes x commit5 &&\n'> <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (C {<test_expect_success>} {(SQ <'fails to merge using "manual" strategy (z => w)'>)} 
      {
        (SQ <'\n'> <'\tgit update-ref refs/notes/m refs/notes/w &&\n'> 
          <'\ttest_must_fail git notes merge z\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (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: 1194
                  stdin_parts: [
                    ($ Id.VSub_DollarName '$commit_sha3')
                    <'\n'>
                    ($ Id.VSub_DollarName '$commit_sha4')
                    <'\n'>
                  ]
                )
            )
          ]
          do_fork: T
        )
        (command.Simple
          words: [{<sort>}]
          redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_conflicts>})]
          do_fork: T
        )
      ]
      negated: F
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir
          op: <Id.Redir_Great '>'>
          loc: (redir_loc.Fd fd:1)
          arg: {<expect_conflict_> ($ Id.VSub_DollarName '$commit_sha3')}
        )
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 1213
              stdin_parts: [
                <'<<<<<<< refs/notes/m\n'>
                <'other notes for commit3\n'>
                <'=======\n'>
                <'notes for commit3\n'>
                <'\n'>
                <'appended notes for commit3\n'>
                <'>>>>>>> refs/notes/z\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir
          op: <Id.Redir_Great '>'>
          loc: (redir_loc.Fd fd:1)
          arg: {<expect_conflict_> ($ Id.VSub_DollarName '$commit_sha4')}
        )
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 1226
              stdin_parts: [<'other notes for commit4\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'verify conflict entries (with no fanout)'>)} 
      {
        (SQ <'\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 == w)\n'> <'\ttest "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)"\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect_log_m>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 1277
              stdin_parts: [
                ($ Id.VSub_DollarName '$commit_sha5')
                <' commit5\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha4')
                <' commit4\n'>
                <'other notes for commit4\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha3')
                <' commit3\n'>
                <'other notes for commit3\n'>
                <'\n'>
                <'appended notes for commit3\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha2')
                <' commit2\n'>
                <'new notes for commit2\n'>
                <'\n'>
                ($ Id.VSub_DollarName '$commit_sha1')
                <' commit1\n'>
                <'other notes for commit1\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'resolve and finalize merge (z => w)'>)} 
      {
        (SQ <'\n'> <'\tcat >.git/NOTES_MERGE_WORKTREE/$commit_sha3 <<EOF &&\n'> 
          <'other notes for commit3\n'> <'\n'> <'appended notes for commit3\n'> <'EOF\n'> <'\tgit notes merge --commit &&\n'> 
          <'\tverify_notes m commit5 &&\n'> <'\t# w/x/y/z unchanged\n'> <'\tverify_notes w commit5 &&\n'> <'\tverify_notes x commit5 &&\n'> 
          <'\tverify_notes y commit5 &&\n'> <'\tverify_notes z commit5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'notes tree still has fanout after merge (m)'>)} 
      {(SQ <'verify_fanout m'>)}
    )
    (C {<test_done>})
  ]
)