(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 at various fanout levels'>)}
          spids: [21]
        )
      ]
      spids: [21]
    )
    (C {(.)} {(./test-lib.sh)})
    (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:[40])
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                  spids: [40]
                )
              ]
              spids: [40]
            )
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:commit spids:[46])
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$2'))}
                  spids: [46]
                )
              ]
              spids: [46]
            )
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (command.If
                  arms: [
                    (if_arm
                      cond: [(C {(test)} {(-f)} {(DQ (expect_notes_) ($ VSub_Name '$notes_ref'))})]
                      action: [
                        (command.AndOr
                          ops: [Op_DAmp Op_DPipe]
                          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.ControlFlow
                              token: <ControlFlow_Return return>
                              arg_word: {(1)}
                            )
                          ]
                        )
                      ]
                      spids: [16777215 64]
                    )
                  ]
                  spids: [16777215 114]
                )
                (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'))}
                    {(DQ ($ VSub_Name '$commit'))}
                  ]
                  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: [37]
        )
      spids: [32 36]
    )
    (command.FuncDef
      name: verify_fanout
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:notes_ref spids:[176])
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                  spids: [176]
                )
              ]
              spids: [176]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [
                    {(git)}
                    {(rev-parse)}
                    {(--quiet)}
                    {(--verify)}
                    {(DQ (refs/notes/) ($ VSub_Name '$notes_ref'))}
                  ]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
                )
                (command.Pipeline
                  children: [
                    (C {(git)} {(ls-tree)} {(-r)} {(--name-only)} 
                      {(DQ (refs/notes/) ($ VSub_Name '$notes_ref'))}
                    )
                    (command.WhileUntil
                      keyword: <KW_While while>
                      cond: [(C {(read)} {(path)})]
                      body: 
                        (command.DoGroup
                          children: [
                            (command.Case
                              to_match: {(DQ ($ VSub_Name '$path'))}
                              arms: [
                                (case_arm
                                  pat_list: [
                                    {(Lit_Other '?') (Lit_Other '?') (/) (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?')
                                    }
                                  ]
                                  action: [(C {(Lit_Other ':')} {(true)})]
                                  spids: [240 281 289 16777215]
                                )
                                (case_arm
                                  pat_list: [{(Lit_Other '*')}]
                                  action: [
                                    (command.AndOr
                                      ops: [Op_DAmp]
                                      children: [
                                        (C {(echo)} 
                                          {
                                            (DQ ('Invalid path ') 
                                              (word_part.EscapedLiteralPart
                                                token: <Lit_EscapedChar '\\"'>
                                              ) ($ VSub_Name '$path') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>)
                                            )
                                          }
                                        )
                                        (command.ControlFlow
                                          token: <ControlFlow_Return return>
                                          arg_word: {(1)}
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [292 293 313 16777215]
                                )
                              ]
                              spids: [231 237 316]
                            )
                          ]
                          spids: [228 319]
                        )
                    )
                  ]
                  negated: F
                )
              ]
            )
          ]
          spids: [173]
        )
      spids: [168 172]
    )
    (command.FuncDef
      name: verify_no_fanout
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:notes_ref spids:[332])
                  op: Equal
                  rhs: {(DQ ($ VSub_Number '$1'))}
                  spids: [332]
                )
              ]
              spids: [332]
            )
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [
                    {(git)}
                    {(rev-parse)}
                    {(--quiet)}
                    {(--verify)}
                    {(DQ (refs/notes/) ($ VSub_Name '$notes_ref'))}
                  ]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
                )
                (command.Pipeline
                  children: [
                    (C {(git)} {(ls-tree)} {(-r)} {(--name-only)} 
                      {(DQ (refs/notes/) ($ VSub_Name '$notes_ref'))}
                    )
                    (command.WhileUntil
                      keyword: <KW_While while>
                      cond: [(C {(read)} {(path)})]
                      body: 
                        (command.DoGroup
                          children: [
                            (command.Case
                              to_match: {(DQ ($ VSub_Name '$path'))}
                              arms: [
                                (case_arm
                                  pat_list: [
                                    {(Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') (Lit_Other '?') 
                                      (Lit_Other '?')
                                    }
                                  ]
                                  action: [(C {(Lit_Other ':')} {(true)})]
                                  spids: [396 436 444 16777215]
                                )
                                (case_arm
                                  pat_list: [{(Lit_Other '*')}]
                                  action: [
                                    (command.AndOr
                                      ops: [Op_DAmp]
                                      children: [
                                        (C {(echo)} 
                                          {
                                            (DQ ('Invalid path ') 
                                              (word_part.EscapedLiteralPart
                                                token: <Lit_EscapedChar '\\"'>
                                              ) ($ VSub_Name '$path') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\"'>)
                                            )
                                          }
                                        )
                                        (command.ControlFlow
                                          token: <ControlFlow_Return return>
                                          arg_word: {(1)}
                                        )
                                      ]
                                    )
                                  ]
                                  spids: [447 448 468 16777215]
                                )
                              ]
                              spids: [387 393 471]
                            )
                          ]
                          spids: [384 474]
                        )
                    )
                  ]
                  negated: F
                )
              ]
            )
          ]
          spids: [329]
        )
      spids: [324 328]
    )
    (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.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha1 spids:[499])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit1) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [500 510]
              )
            }
          spids: [499]
        )
      ]
      spids: [499]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha2 spids:[512])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit2) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [513 523]
              )
            }
          spids: [512]
        )
      ]
      spids: [512]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha3 spids:[525])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit3) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [526 536]
              )
            }
          spids: [525]
        )
      ]
      spids: [525]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha4 spids:[538])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit4) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [539 549]
              )
            }
          spids: [538]
        )
      ]
      spids: [538]
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:commit_sha5 spids:[551])
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: 
                  (command.CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit5) (Lit_Other '^') (Lit_LBrace '{') (commit) (Lit_RBrace '}')}
                      )
                    ]
                  )
                left_token: <Left_CommandSub '$('>
                spids: [552 562]
              )
            }
          spids: [551]
        )
      ]
      spids: [551]
    )
    (command.Pipeline
      children: [
        (command.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 593
              stdin_parts: [
                ('aed91155c7a72c2188e781fdf40e0f3761b299db ')
                ($ VSub_Name '$commit_sha5')
                ('\n')
                ('99fab268f9d7ee7b011e091a436c78def8eeee69 ')
                ($ VSub_Name '$commit_sha4')
                ('\n')
                ('953c20ae26c7aa0b428c20693fe38bc687f9d1a9 ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('6358796131b8916eaa2dde6902642942a1cb37e1 ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('b02d459c32f0e68f2fe0981033bb34f38776ba47 ')
                ($ VSub_Name '$commit_sha1')
                ('\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: 624
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('notes for commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'sanity check (x)'>)} 
      {(SQ <'\n'> <'\tverify_notes x commit5 &&\n'> <'\tverify_no_fanout x\n'>)}
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:num spids:[639])
          op: Equal
          rhs: {(300)}
          spids: [639]
        )
      ]
      spids: [639]
    )
    (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.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 738
              stdin_parts: [
                ('9f506ee70e20379d7f78204c77b334f43d77410d ')
                ($ VSub_Name '$commit_sha3')
                ('\n')
                ('23a47d6ea7d589895faf800752054818e1e7627b ')
                ($ VSub_Name '$commit_sha2')
                ('\n')
                ('b02d459c32f0e68f2fe0981033bb34f38776ba47 ')
                ($ 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: 769
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('notes for commit3\n')
            ('\n')
            ('appended notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.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: 865
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('other notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('other notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.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: 913
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('other notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('other notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.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: 975
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('notes for commit3\n')
            ('\n')
            ('appended notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.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: 1039
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('other notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('other notes for commit3\n')
            ('\n')
            ('notes for commit3\n')
            ('\n')
            ('appended notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.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: 1101
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('other notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('appended notes for commit3\n')
            ('notes for commit3\n')
            ('other notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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.SimpleCommand
          words: [{(cat)}]
          redirects: [
            (redir.HereDoc
              op: <Redir_DLess '<<'>
              fd: 16777215
              here_begin: {(EOF)}
              here_end_span_id: 1202
              stdin_parts: [($ 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_sha3')}
        )
        (redir.HereDoc
          op: <Redir_DLess '<<'>
          fd: 16777215
          here_begin: {(EOF)}
          here_end_span_id: 1221
          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')
          ]
        )
      ]
    )
    (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: 1234
          stdin_parts: [('other notes for commit4\n')]
        )
      ]
    )
    (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.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: 1285
          stdin_parts: [
            ($ VSub_Name '$commit_sha5')
            (' commit5\n')
            ('\n')
            ($ VSub_Name '$commit_sha4')
            (' commit4\n')
            ('other notes for commit4\n')
            ('\n')
            ($ VSub_Name '$commit_sha3')
            (' commit3\n')
            ('other notes for commit3\n')
            ('\n')
            ('appended notes for commit3\n')
            ('\n')
            ($ VSub_Name '$commit_sha2')
            (' commit2\n')
            ('new notes for commit2\n')
            ('\n')
            ($ VSub_Name '$commit_sha1')
            (' commit1\n')
            ('other notes for commit1\n')
            ('\n')
          ]
        )
      ]
    )
    (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)})
  ]
)