(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: 
            {
              (SQ <'Summary support for submodules\n'> <'\n'> 
                <'This test tries to verify the sanity of summary subcommand of git submodule.\n'>
              )
            }
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: add_file
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:sm)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [34]
                )
              ]
              spids: [34]
            )
            (C {(shift)})
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:owd)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: (CommandList children:[(C {(pwd)})])
                        left_token: <Left_CommandSub '$('>
                        spids: [42 44]
                      )
                    }
                  spids: [41]
                )
              ]
              spids: [41]
            )
            (C {(cd)} {(DQ ($ VSub_Name '$sm'))})
            (ForEach
              iter_name: name
              do_arg_iter: T
              body: 
                (DoGroup
                  children: [
                    (AndOr
                      ops: [Op_DAmp Op_DAmp Op_DAmp]
                      children: [
                        (SimpleCommand
                          words: [{(echo)} {(DQ ($ VSub_Name '$name'))}]
                          redirects: [
                            (Redir
                              op: <Redir_Great '>'>
                              fd: 16777215
                              arg_word: {(DQ ($ VSub_Name '$name'))}
                            )
                          ]
                        )
                        (C {(git)} {(add)} {(DQ ($ VSub_Name '$name'))})
                        (C {(test_tick)})
                        (C {(git)} {(commit)} {(-m)} {(DQ ('Add ') ($ VSub_Name '$name'))})
                      ]
                    )
                  ]
                  spids: [59 105]
                )
              redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
              spids: [16777215 16777215]
            )
            (Pipeline
              children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD)}) (C {(cut)} {(-c1-7)})]
              negated: F
            )
            (C {(cd)} {(DQ ($ VSub_Name '$owd'))})
          ]
          spids: [31]
        )
      spids: [26 30]
    )
    (FuncDef
      name: commit_file
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (C {(test_tick)})
                (SimpleCommand
                  words: [
                    {(git)}
                    {(commit)}
                    {(DQ ($ VSub_At '$@'))}
                    {(-m)}
                    {(DQ ('Commit ') ($ VSub_Star '$*'))}
                  ]
                  redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
                )
              ]
            )
          ]
          spids: [139]
        )
      spids: [134 138]
    )
    (AndOr
      ops: [Op_DAmp]
      children: [
        (C {(test_create_repo)} {(sm1)})
        (SimpleCommand
          words: [{(add_file)} {(.)} {(foo)}]
          redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})]
        )
      ]
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:head1)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(add_file)} {(sm1)} {(foo1)} {(foo2)})])
                left_token: <Left_CommandSub '$('>
                spids: [185 193]
              )
            }
          spids: [184]
        )
      ]
      spids: [184]
    )
    (C {(test_expect_success)} {(SQ <'added submodule'>)} 
      {
        (DQ ('\n') ('\tgit add sm1 &&\n') ('\tgit submodule summary >actual &&\n') 
          ('\tcat >expected <<-EOF &&\n') ('* sm1 0000000...') ($ VSub_Name '$head1') (' (2):\n') ('  > Add foo2\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'added submodule (subdirectory)'>)} 
      {
        (DQ ('\n') ('\tmkdir sub &&\n') ('\t(\n') ('\t\tcd sub &&\n') 
          ('\t\tgit submodule summary >../actual\n') ('\t) &&\n') ('\tcat >expected <<-EOF &&\n') ('* ../sm1 0000000...') ($ VSub_Name '$head1') (' (2):\n') 
          ('  > Add foo2\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'added submodule (subdirectory only)'>)} 
      {
        (DQ ('\n') ('\t(\n') ('\t\tcd sub &&\n') ('\t\tgit submodule summary . >../actual\n') 
          ('\t) &&\n') ('\t>expected &&\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'added submodule (subdirectory with explicit path)'>)} 
      {
        (DQ ('\n') ('\t(\n') ('\t\tcd sub &&\n') ('\t\tgit submodule summary ../sm1 >../actual\n') 
          ('\t) &&\n') ('\tcat >expected <<-EOF &&\n') ('* ../sm1 0000000...') ($ VSub_Name '$head1') (' (2):\n') 
          ('  > Add foo2\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head2)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(add_file)} {(sm1)} {(foo3)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [288 294]
                  )
                }
              spids: [287]
            )
          ]
          spids: [287]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'modified submodule(forward)'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head1') (...) ($ VSub_Name '$head2') (' (1):\n') ('  > Add foo3\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'modified submodule(forward), --files'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary --files >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ VSub_Name '$head1') (...) ($ VSub_Name '$head2') (' (1):\n') ('  > Add foo3\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'no ignore=all setting has any effect'>)} 
      {
        (DQ ('\n') ('\tgit config -f .gitmodules submodule.sm1.path sm1 &&\n') 
          ('\tgit config -f .gitmodules submodule.sm1.ignore all &&\n') ('\tgit config submodule.sm1.ignore all &&\n') ('\tgit config diff.ignoreSubmodules all &&\n') 
          ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') ($ VSub_Name '$head1') (...) ($ VSub_Name '$head2') (' (1):\n') 
          ('  > Add foo3\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual &&\n') ('\tgit config --unset diff.ignoreSubmodules &&\n') 
          ('\tgit config --remove-section submodule.sm1 &&\n') ('\tgit config -f .gitmodules --remove-section submodule.sm1\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head3)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [
                          (AndOr
                            ops: [Op_DAmp Op_DAmp]
                            children: [
                              (C {(cd)} {(sm1)})
                              (SimpleCommand
                                words: [{(git)} {(reset)} {(--hard)} {(HEAD) (Lit_TildeLike '~2')}]
                                redirects: [
                                  (Redir
                                    op: <Redir_Great '>'>
                                    fd: 16777215
                                    arg_word: {(/dev/null)}
                                  )
                                ]
                              )
                              (Pipeline
                                children: [
                                  (C {(git)} {(rev-parse)} {(--verify)} {(HEAD)})
                                  (C {(cut)} {(-c1-7)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        ]
                      )
                    left_token: <Left_CommandSub '$('>
                    spids: [378 417]
                  )
                }
              spids: [377]
            )
          ]
          spids: [377]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'modified submodule(backward)'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head2') (...) ($ VSub_Name '$head3') (' (2):\n') ('  < Add foo3\n') ('  < Add foo2\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp]
      children: [
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head4)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(add_file)} {(sm1)} {(foo4)} {(foo5)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [444 452]
                  )
                }
              spids: [443]
            )
          ]
          spids: [443]
        )
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head4_full)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [
                          (SimpleCommand
                            words: [{(git)} {(rev-parse)} {(--verify)} {(HEAD)}]
                            more_env: [(env_pair name:GIT_DIR val:{(sm1/.git)} spids:[458])]
                          )
                        ]
                      )
                    left_token: <Left_CommandSub '$('>
                    spids: [457 468]
                  )
                }
              spids: [456]
            )
          ]
          spids: [456]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'modified submodule(backward and forward)'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head2') (...) ($ VSub_Name '$head4') (' (4):\n') ('  > Add foo5\n') ('  > Add foo4\n') ('  < Add foo3\n') 
          ('  < Add foo2\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <--summary-limit>)} 
      {
        (DQ ('\n') ('\tgit submodule summary -n 3 >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ VSub_Name '$head2') (...) ($ VSub_Name '$head4') (' (4):\n') ('  > Add foo5\n') ('  > Add foo4\n') 
          ('  < Add foo3\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (C {(mv)} {(sm1)} {(sm1-bak)})
        (SimpleCommand
          words: [{(echo)} {(sm1)}]
          redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(sm1)})]
        )
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head5)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: 
                      (CommandList
                        children: [
                          (Pipeline
                            children: [(C {(git)} {(hash-object)} {(sm1)}) (C {(cut)} {(-c1-7)})]
                            negated: F
                          )
                        ]
                      )
                    left_token: <Left_CommandSub '$('>
                    spids: [543 555]
                  )
                }
              spids: [542]
            )
          ]
          spids: [542]
        )
        (C {(git)} {(add)} {(sm1)})
        (C {(rm)} {(-f)} {(sm1)})
        (C {(mv)} {(sm1-bak)} {(sm1)})
      ]
    )
    (C {(test_expect_success)} {(SQ <'typechanged submodule(submodule->blob), --cached'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary --cached >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ VSub_Name '$head4') ('(submodule)->') ($ VSub_Name '$head5') ('(blob) (3):\n') ('  < Add foo5\n') 
          ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'typechanged submodule(submodule->blob), --files'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary --files >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ VSub_Name '$head5') ('(blob)->') ($ VSub_Name '$head4') ('(submodule) (3):\n') ('  > Add foo5\n') 
          ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp]
      children: [(C {(rm)} {(-rf)} {(sm1)}) (C {(git)} {(checkout-index)} {(sm1)})]
    )
    (C {(test_expect_success)} {(SQ <'typechanged submodule(submodule->blob)'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head4') ('(submodule)->') ($ VSub_Name '$head5') ('(blob):\n') ('\n') ('EOF\n') 
          ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp Op_DAmp]
      children: [
        (C {(rm)} {(-f)} {(sm1)})
        (C {(test_create_repo)} {(sm1)})
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head6)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(add_file)} {(sm1)} {(foo6)} {(foo7)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [676 684]
                  )
                }
              spids: [675]
            )
          ]
          spids: [675]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'nonexistent commit'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head4') (...) ($ VSub_Name '$head6') (':\n') ("  Warn: sm1 doesn't contain commit ") ($ VSub_Name '$head4_full') 
          ('\n') ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (C {(commit_file)})
    (C {(test_expect_success)} {(SQ <'typechanged submodule(blob->submodule)'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head5') ('(blob)->') ($ VSub_Name '$head6') ('(submodule) (2):\n') ('  > Add foo7\n') ('\n') ('EOF\n') 
          ('\ttest_i18ncmp expected actual\n')
        )
      }
    )
    (AndOr ops:[Op_DAmp] children:[(C {(commit_file)} {(sm1)}) (C {(rm)} {(-rf)} {(sm1)})])
    (C {(test_expect_success)} {(SQ <'deleted submodule'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head6') ('...0000000:\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (AndOr
      ops: [Op_DAmp Op_DAmp]
      children: [
        (C {(test_create_repo)} {(sm2)})
        (Assignment
          keyword: Assign_None
          pairs: [
            (assign_pair
              lhs: (LhsName name:head7)
              op: Equal
              rhs: 
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(add_file)} {(sm2)} {(foo8)} {(foo9)})])
                    left_token: <Left_CommandSub '$('>
                    spids: [772 780]
                  )
                }
              spids: [771]
            )
          ]
          spids: [771]
        )
        (C {(git)} {(add)} {(sm2)})
      ]
    )
    (C {(test_expect_success)} {(SQ <'multiple submodules'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ VSub_Name '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') ($ VSub_Name '$head7') (' (2):\n') ('  > Add foo9\n') ('\n') 
          ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'path filter'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary sm2 >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm2 0000000...') ($ VSub_Name '$head7') (' (2):\n') ('  > Add foo9\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(commit_file)} {(sm2)})
    (C {(test_expect_success)} {(SQ <'given commit'>)} 
      {
        (DQ ('\n') ('\tgit submodule summary HEAD^ >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ VSub_Name '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') ($ VSub_Name '$head7') (' (2):\n') 
          ('  > Add foo9\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <--for-status>)} 
      {
        (DQ ('\n') ('\tgit submodule summary --for-status HEAD^ >actual &&\n') 
          ('\ttest_i18ncmp actual - <<EOF\n') ('* sm1 ') ($ VSub_Name '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') ($ VSub_Name '$head7') 
          (' (2):\n') ('  > Add foo9\n') ('\n') ('EOF\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fail when using --files together with --cached'>)} 
      {(DQ ('\n') ('\ttest_must_fail git submodule summary --files --cached\n'))}
    )
    (C {(test_expect_success)} {(SQ <'should not fail in an empty repo'>)} 
      {
        (DQ ('\n') ('\tgit init xyzzy &&\n') ('\tcd xyzzy &&\n') 
          ('\tgit submodule summary >output 2>&1 &&\n') ('\ttest_cmp output /dev/null\n')
        )
      }
    )
    (C {(test_done)})
  ]
)