(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'Test notes trees that also contain non-notes'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:number_of_commits) op:Equal rhs:{(100)} spids:[15])]
      spids: [15]
    )
    (FuncDef
      name: start_note_commit
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (C {(test_tick)})
                (SimpleCommand
                  words: [{(cat)}]
                  redirects: [
                    (HereDoc
                      op_id: Redir_DLess
                      fd: 16777215
                      body: 
                        {
                          (DQ ('commit refs/notes/commits\n') ('committer ') 
                            ($ VSub_Name '$GIT_COMMITTER_NAME') (' <') ($ VSub_Name '$GIT_COMMITTER_EMAIL') ('> ') ($ VSub_Name '$GIT_COMMITTER_DATE') ('\n') 
                            ('data <<COMMIT\n') ('notes\n') ('COMMIT\n') ('\n') ('from refs/notes/commits^0\n') ('deleteall\n')
                          )
                        }
                      do_expansion: True
                      here_end: INPUT_END
                      was_filled: T
                      spids: [34]
                    )
                  ]
                )
              ]
            )
          ]
          spids: [24]
        )
      spids: [19 23]
    )
    (FuncDef
      name: verify_notes
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (Pipeline
                  children: [
                    (C {(git)} {(log)})
                    (SimpleCommand
                      words: [{(grep)} {(DQ ('^    '))}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: 16777215
                          arg_word: {(output)}
                          spids: [76]
                        )
                      ]
                    )
                  ]
                  negated: F
                )
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:i)
                      op: Equal
                      rhs: {($ VSub_Name '$number_of_commits')}
                      spids: [83]
                    )
                  ]
                  spids: [83]
                )
                (While
                  cond: [
                    (Sentence
                      child: (C {(Lit_Other '[')} {($ VSub_Name '$i')} {(-gt)} {(0)} {(Lit_Other ']')})
                      terminator: <Op_Semi ';'>
                    )
                  ]
                  body: 
                    (DoGroup
                      children: [
                        (Sentence
                          child: 
                            (AndOr
                              ops: [Op_DAmp Op_DAmp]
                              children: [
                                (C {(echo)} {(DQ ('    commit #') ($ VSub_Name '$i'))})
                                (C {(echo)} {(DQ ('    note for commit #') ($ VSub_Name '$i'))})
                                (Assignment
                                  keyword: Assign_None
                                  pairs: [
                                    (assign_pair
                                      lhs: (LhsName name:i)
                                      op: Equal
                                      rhs: 
                                        {
                                          (ArithSubPart
                                            anode: 
                                              (ArithBinary
                                                op_id: Arith_Minus
                                                left: (ArithWord w:{($ VSub_Name '$i')})
                                                right: (ArithWord w:{(Lit_Digits 1)})
                                              )
                                            spids: [126 131]
                                          )
                                        }
                                      spids: [125]
                                    )
                                  ]
                                  spids: [125]
                                )
                              ]
                            )
                          terminator: <Op_Semi ';'>
                        )
                      ]
                      spids: [102 135]
                    )
                  redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[137])]
                )
                (C {(test_cmp)} {(expect)} {(output)})
              ]
            )
          ]
          spids: [61]
        )
      spids: [56 60]
    )
    (C {(test_expect_success)} {(DQ ('setup: create a couple of commits'))} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_tick &&\n'> <'\tcat <<INPUT_END >input &&\n'> 
          <'commit refs/heads/master\n'> <'committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n'> <'data <<COMMIT\n'> 
          <'commit #1\n'> <'COMMIT\n'> <'\n'> <'M 644 inline file\n'> <'data <<EOF\n'> <'file in commit #1\n'> <'EOF\n'> <'\n'> 
          <'INPUT_END\n'> <'\n'> <'\ttest_tick &&\n'> <'\tcat <<INPUT_END >>input &&\n'> <'commit refs/heads/master\n'> 
          <'committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n'> <'data <<COMMIT\n'> <'commit #2\n'> <'COMMIT\n'> <'\n'> <'M 644 inline file\n'> <'data <<EOF\n'> 
          <'file in commit #2\n'> <'EOF\n'> <'\n'> <'INPUT_END\n'> <'\tgit fast-import --quiet <input\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('create a notes tree with both notes and non-notes'))} 
      {
        (SQ <'\n'> <'\n'> <'\tcommit1=$(git rev-parse refs/heads/master^) &&\n'> 
          <'\tcommit2=$(git rev-parse refs/heads/master) &&\n'> <'\ttest_tick &&\n'> <'\tcat <<INPUT_END >input &&\n'> <'commit refs/notes/commits\n'> 
          <'committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n'> <'data <<COMMIT\n'> <'notes commit #1\n'> <'COMMIT\n'> <'\n'> <'N inline $commit1\n'> <'data <<EOF\n'> 
          <'note for commit #1\n'> <'EOF\n'> <'\n'> <'N inline $commit2\n'> <'data <<EOF\n'> <'note for commit #2\n'> <'EOF\n'> <'\n'> 
          <'INPUT_END\n'> <'\ttest_tick &&\n'> <'\tcat <<INPUT_END >>input &&\n'> <'commit refs/notes/commits\n'> 
          <'committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n'> <'data <<COMMIT\n'> <'notes commit #2\n'> <'COMMIT\n'> <'\n'> <'M 644 inline foobar/non-note.txt\n'> 
          <'data <<EOF\n'> <'A non-note in a notes tree\n'> <'EOF\n'> <'\n'> <'N inline $commit2\n'> <'data <<EOF\n'> 
          <'edited note for commit #2\n'> <'EOF\n'> <'\n'> <'INPUT_END\n'> <'\ttest_tick &&\n'> <'\tcat <<INPUT_END >>input &&\n'> 
          <'commit refs/notes/commits\n'> <'committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n'> <'data <<COMMIT\n'> 
          <'notes commit #3\n'> <'COMMIT\n'> <'\n'> <'N inline $commit1\n'> <'data <<EOF\n'> <'edited note for commit #1\n'> <'EOF\n'> 
          <'\n'> <'M 644 inline deadbeef\n'> <'data <<EOF\n'> <'non-note with SHA1-like name\n'> <'EOF\n'> <'\n'> 
          <'M 644 inline de/adbeef\n'> <'data <<EOF\n'> <'another non-note with SHA1-like name\n'> <'EOF\n'> <'\n'> 
          <'M 644 inline de/adbeefdeadbeefdeadbeefdeadbeefdeadbeef\n'> <'data <<EOF\n'> <'This is actually a valid note, albeit to a non-existing object.\n'> 
          <'It is needed in order to trigger the "mishandling" of the dead/beef non-note.\n'> <'EOF\n'> <'\n'> <'M 644 inline dead/beef\n'> <'data <<EOF\n'> 
          <'yet another non-note with SHA1-like name\n'> <'EOF\n'> <'\n'> <'INPUT_END\n'> <'\tgit fast-import --quiet <input &&\n'> 
          <'\tgit config core.notesRef refs/notes/commits\n'>
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[286])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('    commit #2\n') ('    edited note for commit #2\n') ('    commit #1\n') 
                ('    edited note for commit #1\n')
              )
            }
          do_expansion: True
          here_end: EXPECT_END
          was_filled: T
          spids: [289]
        )
      ]
    )
    (C {(test_expect_success)} {(DQ ('verify contents of notes'))} 
      {(SQ <'\n'> <'\n'> <'\tgit log | grep "^    " > actual &&\n'> <'\ttest_cmp expect actual\n'>)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect_nn1)} spids:[314])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: {(DQ ('A non-note in a notes tree\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: T
          spids: [317]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect_nn2)} spids:[324])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: {(DQ ('non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: T
          spids: [327]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect_nn3)} spids:[334])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: {(DQ ('another non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: T
          spids: [337]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect_nn4)} spids:[344])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: {(DQ ('yet another non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: T
          spids: [347]
        )
      ]
    )
    (C {(test_expect_success)} {(DQ ('verify contents of non-notes'))} 
      {
        (SQ <'\n'> <'\n'> 
          <'\tgit cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&\n'> <'\ttest_cmp expect_nn1 actual_nn1 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&\n'> <'\ttest_cmp expect_nn2 actual_nn2 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&\n'> <'\ttest_cmp expect_nn3 actual_nn3 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&\n'> <'\ttest_cmp expect_nn4 actual_nn4\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('git-notes preserves non-notes'))} 
      {(SQ <'\n'> <'\n'> <'\ttest_tick &&\n'> <'\tgit notes add -f -m "foo bar"\n'>)}
    )
    (C {(test_expect_success)} {(DQ ('verify contents of non-notes after git-notes'))} 
      {
        (SQ <'\n'> <'\n'> 
          <'\tgit cat-file -p refs/notes/commits:foobar/non-note.txt > actual_nn1 &&\n'> <'\ttest_cmp expect_nn1 actual_nn1 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:deadbeef > actual_nn2 &&\n'> <'\ttest_cmp expect_nn2 actual_nn2 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:de/adbeef > actual_nn3 &&\n'> <'\ttest_cmp expect_nn3 actual_nn3 &&\n'> 
          <'\tgit cat-file -p refs/notes/commits:dead/beef > actual_nn4 &&\n'> <'\ttest_cmp expect_nn4 actual_nn4\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)