(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
              children: [
                (C {(test_tick)})
                (SimpleCommand
                  words: [{(cat)}]
                  redirects: [
                    (HereDoc
                      op_id: Redir_DLess
                      fd: -1
                      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: True
                      spids: [34]
                    )
                  ]
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [24]
        )
      spids: [19 23]
    )
    (FuncDef
      name: verify_notes
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (Pipeline
                  children: [
                    (C {(git)} {(log)})
                    (SimpleCommand
                      words: [{(grep)} {(DQ ('^    '))}]
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(output)} spids:[75])]
                    )
                  ]
                  negated: False
                )
                (AndOr
                  children: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:i)
                          op: Equal
                          rhs: {($ VSub_Name '$number_of_commits')}
                          spids: [82]
                        )
                      ]
                      spids: [82]
                    )
                    (AndOr
                      children: [
                        (While
                          cond: [
                            (Sentence
                              child: 
                                (C {(Lit_Other '[')} {($ VSub_Name '$i')} {(-gt)} {(0)} {(Lit_Other ']')})
                              terminator: <Op_Semi ';'>
                            )
                          ]
                          body: 
                            (DoGroup
                              children: [
                                (Sentence
                                  child: 
                                    (AndOr
                                      children: [
                                        (C {(echo)} {(DQ ('    commit #') ($ VSub_Name '$i'))})
                                        (AndOr
                                          children: [
                                            (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: [125 130]
                                                      )
                                                    }
                                                  spids: [124]
                                                )
                                              ]
                                              spids: [124]
                                            )
                                          ]
                                          op_id: Op_DAmp
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  terminator: <Op_Semi ';'>
                                )
                              ]
                              spids: [101 134]
                            )
                          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[136])]
                        )
                        (C {(test_cmp)} {(expect)} {(output)})
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [60]
        )
      spids: [55 59]
    )
    (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:-1 arg_word:{(expect)} spids:[285])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          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: True
          spids: [288]
        )
      ]
    )
    (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:-1 arg_word:{(expect_nn1)} spids:[312])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ('A non-note in a notes tree\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: True
          spids: [315]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_nn2)} spids:[321])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ('non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: True
          spids: [324]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_nn3)} spids:[330])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ('another non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: True
          spids: [333]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_nn4)} spids:[339])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ('yet another non-note with SHA1-like name\n'))}
          do_expansion: True
          here_end: EXPECT_END
          was_filled: True
          spids: [342]
        )
      ]
    )
    (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)})
  ]
)