(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"Test notes merging at various fanout levels">)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: verify_notes
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:notes_ref)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$1"))}
                  spids: [32]
                )
              ]
              spids: [32]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:commit)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$2"))}
                  spids: [38]
                )
              ]
              spids: [38]
            )
            (AndOr
              children: [
                (If
                  arms: [
                    (if_arm
                      cond: [(C {(test)} {(-f)} {(DQ (expect_notes_) ($ VSub_Name "$notes_ref"))})]
                      action: [
                        (AndOr
                          children: [
                            (Pipeline
                              children: [
                                (C {(git)} {(-c)} 
                                  {(core.notesRef) (Lit_Other "=") 
                                    (DQ (refs/notes/) ($ VSub_Name "$notes_ref"))
                                  } {(notes)}
                                )
                                (SimpleCommand
                                  words: [{(sort)}]
                                  redirects: [
                                    (Redir
                                      op_id: Redir_Great
                                      fd: -1
                                      arg_word: {(DQ (output_notes_) ($ VSub_Name "$notes_ref"))}
                                      spids: [77]
                                    )
                                  ]
                                )
                              ]
                              negated: False
                            )
                            (AndOr
                              children: [
                                (C {(test_cmp)} {(DQ (expect_notes_) ($ VSub_Name "$notes_ref"))} 
                                  {(DQ (output_notes_) ($ VSub_Name "$notes_ref"))}
                                )
                                (ControlFlow
                                  token: <ControlFlow_Return return>
                                  arg_word: {(1)}
                                )
                              ]
                              op_id: Op_DPipe
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      spids: [-1 56]
                    )
                  ]
                  spids: [-1 106]
                )
                (AndOr
                  children: [
                    (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
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(DQ (output_log_) ($ VSub_Name "$notes_ref"))}
                          spids: [136]
                        )
                      ]
                    )
                    (C {(test_cmp)} {(DQ (expect_log_) ($ VSub_Name "$notes_ref"))} 
                      {(DQ (output_log_) ($ VSub_Name "$notes_ref"))}
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [29]
        )
      spids: [24 28]
    )
    (FuncDef
      name: verify_fanout
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:notes_ref)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$1"))}
                  spids: [168]
                )
              ]
              spids: [168]
            )
            (AndOr
              children: [
                (SimpleCommand
                  words: [
                    {(git)}
                    {(rev-parse)}
                    {(--quiet)}
                    {(--verify)}
                    {(DQ (refs/notes/) ($ VSub_Name "$notes_ref"))}
                  ]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[191])]
                )
                (Pipeline
                  children: [
                    (C {(git)} {(ls-tree)} {(-r)} {(--name-only)} 
                      {(DQ (refs/notes/) ($ VSub_Name "$notes_ref"))}
                    )
                    (While
                      cond: [(C {(read)} {(path)})]
                      body: 
                        (DoGroup
                          children: [
                            (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: [232 273 281 -1]
                                )
                                (case_arm
                                  pat_list: [{(Lit_Other "*")}]
                                  action: [
                                    (AndOr
                                      children: [
                                        (C {(echo)} 
                                          {
                                            (DQ ("Invalid path ") 
                                              (EscapedLiteralPart
                                                token: <Lit_EscapedChar "\\\"">
                                              ) ($ VSub_Name "$path") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">)
                                            )
                                          }
                                        )
                                        (ControlFlow
                                          token: <ControlFlow_Return return>
                                          arg_word: {(1)}
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  ]
                                  spids: [284 285 305 -1]
                                )
                              ]
                              spids: [223 229 308]
                            )
                          ]
                          spids: [220 311]
                        )
                    )
                  ]
                  negated: False
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [165]
        )
      spids: [160 164]
    )
    (FuncDef
      name: verify_no_fanout
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:notes_ref)
                  op: Equal
                  rhs: {(DQ ($ VSub_Number "$1"))}
                  spids: [324]
                )
              ]
              spids: [324]
            )
            (AndOr
              children: [
                (SimpleCommand
                  words: [
                    {(git)}
                    {(rev-parse)}
                    {(--quiet)}
                    {(--verify)}
                    {(DQ (refs/notes/) ($ VSub_Name "$notes_ref"))}
                  ]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[347])]
                )
                (Pipeline
                  children: [
                    (C {(git)} {(ls-tree)} {(-r)} {(--name-only)} 
                      {(DQ (refs/notes/) ($ VSub_Name "$notes_ref"))}
                    )
                    (While
                      cond: [(C {(read)} {(path)})]
                      body: 
                        (DoGroup
                          children: [
                            (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: [388 428 436 -1]
                                )
                                (case_arm
                                  pat_list: [{(Lit_Other "*")}]
                                  action: [
                                    (AndOr
                                      children: [
                                        (C {(echo)} 
                                          {
                                            (DQ ("Invalid path ") 
                                              (EscapedLiteralPart
                                                token: <Lit_EscapedChar "\\\"">
                                              ) ($ VSub_Name "$path") (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">)
                                            )
                                          }
                                        )
                                        (ControlFlow
                                          token: <ControlFlow_Return return>
                                          arg_word: {(1)}
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  ]
                                  spids: [439 440 460 -1]
                                )
                              ]
                              spids: [379 385 463]
                            )
                          ]
                          spids: [376 466]
                        )
                    )
                  ]
                  negated: False
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [321]
        )
      spids: [316 320]
    )
    (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">
        )
      }
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:commit_sha1)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit1) (Lit_Other "^") (Lit_LBrace "{") (commit) (Lit_RBrace "}")}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [492 502]
              )
            }
          spids: [491]
        )
      ]
      spids: [491]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:commit_sha2)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit2) (Lit_Other "^") (Lit_LBrace "{") (commit) (Lit_RBrace "}")}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [505 515]
              )
            }
          spids: [504]
        )
      ]
      spids: [504]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:commit_sha3)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit3) (Lit_Other "^") (Lit_LBrace "{") (commit) (Lit_RBrace "}")}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [518 528]
              )
            }
          spids: [517]
        )
      ]
      spids: [517]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:commit_sha4)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit4) (Lit_Other "^") (Lit_LBrace "{") (commit) (Lit_RBrace "}")}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [531 541]
              )
            }
          spids: [530]
        )
      ]
      spids: [530]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:commit_sha5)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: 
                  (CommandList
                    children: [
                      (C {(git)} {(rev-parse)} 
                        {(commit5) (Lit_Other "^") (Lit_LBrace "{") (commit) (Lit_RBrace "}")}
                      )
                    ]
                  )
                left_token: <Left_CommandSub "$(">
                spids: [544 554]
              )
            }
          spids: [543]
        )
      ]
      spids: [543]
    )
    (Pipeline
      children: [
        (SimpleCommand
          words: [{(cat)}]
          redirects: [
            (HereDoc
              op_id: Redir_DLess
              fd: -1
              body: 
                {
                  (DQ ("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")
                  )
                }
              do_expansion: True
              here_end: EOF
              was_filled: True
              spids: [559]
            )
          ]
        )
        (SimpleCommand
          words: [{(sort)}]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect_notes_x)} spids:[566])]
        )
      ]
      negated: False
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_x)} spids:[587])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [590]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"sanity check (x)">)} 
      {(SQ <"\n"> <"\tverify_notes x commit5 &&\n"> <"\tverify_no_fanout x\n">)}
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:num) op:Equal rhs:{(300)} spids:[627])]
      spids: [627]
    )
    (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">
        )
      }
    )
    (Pipeline
      children: [
        (SimpleCommand
          words: [{(cat)}]
          redirects: [
            (HereDoc
              op_id: Redir_DLess
              fd: -1
              body: 
                {
                  (DQ ("9f506ee70e20379d7f78204c77b334f43d77410d ") ($ VSub_Name "$commit_sha3") ("\n") 
                    ("23a47d6ea7d589895faf800752054818e1e7627b ") ($ VSub_Name "$commit_sha2") ("\n") ("b02d459c32f0e68f2fe0981033bb34f38776ba47 ") 
                    ($ VSub_Name "$commit_sha1") ("\n")
                  )
                }
              do_expansion: True
              here_end: EOF
              was_filled: True
              spids: [706]
            )
          ]
        )
        (SimpleCommand
          words: [{(sort)}]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect_notes_z)} spids:[713])]
        )
      ]
      negated: False
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_z)} spids:[728])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [731]
        )
      ]
    )
    (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">)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_w)} spids:[823])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [826]
        )
      ]
    )
    (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">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_m)} spids:[869])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [872]
        )
      ]
    )
    (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">)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_m)} spids:[928])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [931]
        )
      ]
    )
    (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">)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_m)} spids:[987])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [990]
        )
      ]
    )
    (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">)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_m)} spids:[1049])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [1052]
        )
      ]
    )
    (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">)}
    )
    (Pipeline
      children: [
        (SimpleCommand
          words: [{(cat)}]
          redirects: [
            (HereDoc
              op_id: Redir_DLess
              fd: -1
              body: {(DQ ($ VSub_Name "$commit_sha3") ("\n") ($ VSub_Name "$commit_sha4") ("\n"))}
              do_expansion: True
              here_end: EOF
              was_filled: True
              spids: [1161]
            )
          ]
        )
        (SimpleCommand
          words: [{(sort)}]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect_conflicts)} spids:[1168])]
        )
      ]
      negated: False
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir
          op_id: Redir_Great
          fd: -1
          arg_word: {(expect_conflict_) ($ VSub_Name "$commit_sha3")}
          spids: [1178]
        )
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ("<<<<<<< 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_expansion: True
          here_end: EOF
          was_filled: True
          spids: [1182]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir
          op_id: Redir_Great
          fd: -1
          arg_word: {(expect_conflict_) ($ VSub_Name "$commit_sha4")}
          spids: [1195]
        )
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ("other notes for commit4\n"))}
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [1199]
        )
      ]
    )
    (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">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_log_m)} spids:[1225])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ 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")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [1228]
        )
      ]
    )
    (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)})
  ]
)