(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: 
            {
              (SQ (Token id:Id.Lit_Chars val:'Summary support for submodules\n' span_id:15) 
                (Token id:Id.Lit_Chars val:'\n' span_id:16) 
                (Token
                  id: Id.Lit_Chars
                  val: 
'This test tries to verify the sanity of summary subcommand of git submodule.\n'
                  span_id: 17
                )
              )
            }
          spids: [13]
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.ShFunction
      name: add_file
      body: 
        (command.BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:sm)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$1')}
                  spids: [34]
                )
              ]
            )
            (C {(shift)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:owd)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:42)
                        command_list: (command.CommandList children:[(C {(pwd)})])
                      )
                    }
                  spids: [41]
                )
              ]
            )
            (C {(cd)} {(DQ ($ Id.VSub_DollarName '$sm'))})
            (command.ForEach
              iter_name: name
              do_arg_iter: T
              body: 
                (command.DoGroup
                  children: [
                    (command.AndOr
                      ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
                      children: [
                        (command.Simple
                          words: [{(echo)} {(DQ ($ Id.VSub_DollarName '$name'))}]
                          redirects: [
                            (redir.Redir
                              op: (Token id:Id.Redir_Great val:'>' span_id:68)
                              fd: -1
                              arg_word: {(DQ ($ Id.VSub_DollarName '$name'))}
                            )
                          ]
                        )
                        (C {(git)} {(add)} {(DQ ($ Id.VSub_DollarName '$name'))})
                        (C {(test_tick)})
                        (C {(git)} {(commit)} {(-m)} {(DQ ('Add ') ($ Id.VSub_DollarName '$name'))})
                      ]
                    )
                  ]
                )
              redirects: [
                (redir.Redir
                  op: (Token id:Id.Redir_Great val:'>' span_id:107)
                  fd: -1
                  arg_word: {(/dev/null)}
                )
              ]
            )
            (command.Pipeline
              children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD)}) (C {(cut)} {(-c1-7)})]
              negated: F
            )
            (C {(cd)} {(DQ ($ Id.VSub_DollarName '$owd'))})
          ]
        )
    )
    (command.ShFunction
      name: commit_file
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {(test_tick)})
                (command.Simple
                  words: [
                    {(git)}
                    {(commit)}
                    {(DQ ($ Id.VSub_At '$@'))}
                    {(-m)}
                    {(DQ ('Commit ') ($ Id.VSub_Star '$*'))}
                  ]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:162)
                      fd: -1
                      arg_word: {(/dev/null)}
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (C {(test_create_repo)} {(sm1)})
        (command.Simple
          words: [{(add_file)} {(.)} {(foo)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:180)
              fd: -1
              arg_word: {(/dev/null)}
            )
          ]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:head1)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:185)
                command_list: 
                  (command.CommandList
                    children: [(C {(add_file)} {(sm1)} {(foo1)} {(foo2)})]
                  )
              )
            }
          spids: [184]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'added submodule' span_id:199))} 
      {
        (DQ ('\n') ('\tgit add sm1 &&\n') ('\tgit submodule summary >actual &&\n') 
          ('\tcat >expected <<-EOF &&\n') ('* sm1 0000000...') ($ Id.VSub_DollarName '$head1') (' (2):\n') ('  > Add foo2\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'added submodule (subdirectory)' span_id:220))} 
      {
        (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...') ($ Id.VSub_DollarName '$head1') 
          (' (2):\n') ('  > Add foo2\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'added submodule (subdirectory only)' span_id:244))} 
      {
        (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 
          (Token
            id: Id.Lit_Chars
            val: 'added submodule (subdirectory with explicit path)'
            span_id: 261
          )
        )
      } 
      {
        (DQ ('\n') ('\t(\n') ('\t\tcd sub &&\n') ('\t\tgit submodule summary ../sm1 >../actual\n') 
          ('\t) &&\n') ('\tcat >expected <<-EOF &&\n') ('* ../sm1 0000000...') ($ Id.VSub_DollarName '$head1') (' (2):\n') 
          ('  > Add foo2\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head2)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:288)
                    command_list: (command.CommandList children:[(C {(add_file)} {(sm1)} {(foo3)})])
                  )
                }
              spids: [287]
            )
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'modified submodule(forward)' span_id:300))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head1') (...) ($ Id.VSub_DollarName '$head2') (' (1):\n') ('  > Add foo3\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'modified submodule(forward), --files' span_id:322))} 
      {
        (DQ ('\n') ('\tgit submodule summary --files >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ Id.VSub_DollarName '$head1') (...) ($ Id.VSub_DollarName '$head2') (' (1):\n') ('  > Add foo3\n') 
          ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'no ignore=all setting has any effect' span_id:344))} 
      {
        (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 ') ($ Id.VSub_DollarName '$head1') (...) 
          ($ Id.VSub_DollarName '$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')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head3)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:378)
                    command_list: 
                      (command.CommandList
                        children: [
                          (command.AndOr
                            ops: [Id.Op_DAmp Id.Op_DAmp]
                            children: [
                              (C {(cd)} {(sm1)})
                              (command.Simple
                                words: [{(git)} {(reset)} {(--hard)} {(HEAD) (Id.Lit_TildeLike '~2')}]
                                redirects: [
                                  (redir.Redir
                                    op: (Token id:Id.Redir_Great val:'>' span_id:397)
                                    fd: -1
                                    arg_word: {(/dev/null)}
                                  )
                                ]
                              )
                              (command.Pipeline
                                children: [
                                  (C {(git)} {(rev-parse)} {(--verify)} {(HEAD)})
                                  (C {(cut)} {(-c1-7)})
                                ]
                                negated: F
                              )
                            ]
                          )
                        ]
                      )
                  )
                }
              spids: [377]
            )
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'modified submodule(backward)' span_id:423))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head2') (...) ($ Id.VSub_DollarName '$head3') (' (2):\n') ('  < Add foo3\n') ('  < Add foo2\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head4)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:444)
                    command_list: 
                      (command.CommandList
                        children: [(C {(add_file)} {(sm1)} {(foo4)} {(foo5)})]
                      )
                  )
                }
              spids: [443]
            )
          ]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head4_full)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:457)
                    command_list: 
                      (command.CommandList
                        children: [
                          (command.Simple
                            words: [{(git)} {(rev-parse)} {(--verify)} {(HEAD)}]
                            more_env: [(env_pair name:GIT_DIR val:{(sm1/.git)} spids:[458])]
                          )
                        ]
                      )
                  )
                }
              spids: [456]
            )
          ]
        )
      ]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'modified submodule(backward and forward)' span_id:473))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head2') (...) ($ Id.VSub_DollarName '$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 (Token id:Id.Lit_Chars val:--summary-limit span_id:498))} 
      {
        (DQ ('\n') ('\tgit submodule summary -n 3 >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ Id.VSub_DollarName '$head2') (...) ($ Id.VSub_DollarName '$head4') (' (4):\n') ('  > Add foo5\n') 
          ('  > Add foo4\n') ('  < Add foo3\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
      children: [
        (C {(commit_file)} {(sm1)})
        (C {(mv)} {(sm1)} {(sm1-bak)})
        (command.Simple
          words: [{(echo)} {(sm1)}]
          redirects: [
            (redir.Redir
              op: (Token id:Id.Redir_Great val:'>' span_id:537)
              fd: -1
              arg_word: {(sm1)}
            )
          ]
        )
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head5)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:543)
                    command_list: 
                      (command.CommandList
                        children: [
                          (command.Pipeline
                            children: [(C {(git)} {(hash-object)} {(sm1)}) (C {(cut)} {(-c1-7)})]
                            negated: F
                          )
                        ]
                      )
                  )
                }
              spids: [542]
            )
          ]
        )
        (C {(git)} {(add)} {(sm1)})
        (C {(rm)} {(-f)} {(sm1)})
        (C {(mv)} {(sm1-bak)} {(sm1)})
      ]
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          (Token
            id: Id.Lit_Chars
            val: 'typechanged submodule(submodule->blob), --cached'
            span_id: 585
          )
        )
      } 
      {
        (DQ ('\n') ('\tgit submodule summary --cached >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ Id.VSub_DollarName '$head4') ('(submodule)->') ($ Id.VSub_DollarName '$head5') ('(blob) (3):\n') 
          ('  < Add foo5\n') ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'typechanged submodule(submodule->blob), --files' span_id:607))} 
      {
        (DQ ('\n') ('\tgit submodule summary --files >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ Id.VSub_DollarName '$head5') ('(blob)->') ($ Id.VSub_DollarName '$head4') ('(submodule) (3):\n') 
          ('  > Add foo5\n') ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [(C {(rm)} {(-rf)} {(sm1)}) (C {(git)} {(checkout-index)} {(sm1)})]
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'typechanged submodule(submodule->blob)' span_id:643))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head4') ('(submodule)->') ($ Id.VSub_DollarName '$head5') ('(blob):\n') ('\n') ('EOF\n') 
          ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp Id.Op_DAmp]
      children: [
        (C {(rm)} {(-f)} {(sm1)})
        (C {(test_create_repo)} {(sm1)})
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head6)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:676)
                    command_list: 
                      (command.CommandList
                        children: [(C {(add_file)} {(sm1)} {(foo6)} {(foo7)})]
                      )
                  )
                }
              spids: [675]
            )
          ]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'nonexistent commit' span_id:689))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head4') (...) ($ Id.VSub_DollarName '$head6') (':\n') ("  Warn: sm1 doesn't contain commit ") 
          ($ Id.VSub_DollarName '$head4_full') ('\n') ('\n') ('EOF\n') ('\ttest_i18ncmp actual expected\n')
        )
      }
    )
    (C {(commit_file)})
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'typechanged submodule(blob->submodule)' span_id:715))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head5') ('(blob)->') ($ Id.VSub_DollarName '$head6') ('(submodule) (2):\n') ('  > Add foo7\n') ('\n') ('EOF\n') 
          ('\ttest_i18ncmp expected actual\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp]
      children: [(C {(commit_file)} {(sm1)}) (C {(rm)} {(-rf)} {(sm1)})]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'deleted submodule' span_id:749))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head6') ('...0000000:\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (command.AndOr
      ops: [Id.Op_DAmp Id.Op_DAmp]
      children: [
        (C {(test_create_repo)} {(sm2)})
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:head7)
              op: assign_op.Equal
              rhs: 
                {
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:772)
                    command_list: 
                      (command.CommandList
                        children: [(C {(add_file)} {(sm2)} {(foo8)} {(foo9)})]
                      )
                  )
                }
              spids: [771]
            )
          ]
        )
        (C {(git)} {(add)} {(sm2)})
      ]
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'multiple submodules' span_id:794))} 
      {
        (DQ ('\n') ('\tgit submodule summary >actual &&\n') ('\tcat >expected <<-EOF &&\n') ('* sm1 ') 
          ($ Id.VSub_DollarName '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') ($ Id.VSub_DollarName '$head7') (' (2):\n') 
          ('  > Add foo9\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'path filter' span_id:818))} 
      {
        (DQ ('\n') ('\tgit submodule summary sm2 >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm2 0000000...') ($ Id.VSub_DollarName '$head7') (' (2):\n') ('  > Add foo9\n') ('\n') ('EOF\n') 
          ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(commit_file)} {(sm2)})
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'given commit' span_id:842))} 
      {
        (DQ ('\n') ('\tgit submodule summary HEAD^ >actual &&\n') ('\tcat >expected <<-EOF &&\n') 
          ('* sm1 ') ($ Id.VSub_DollarName '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') 
          ($ Id.VSub_DollarName '$head7') (' (2):\n') ('  > Add foo9\n') ('\n') ('EOF\n') ('\ttest_cmp expected actual\n')
        )
      }
    )
    (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:--for-status span_id:866))} 
      {
        (DQ ('\n') ('\tgit submodule summary --for-status HEAD^ >actual &&\n') 
          ('\ttest_i18ncmp actual - <<EOF\n') ('* sm1 ') ($ Id.VSub_DollarName '$head6') ('...0000000:\n') ('\n') ('* sm2 0000000...') 
          ($ Id.VSub_DollarName '$head7') (' (2):\n') ('  > Add foo9\n') ('\n') ('EOF\n')
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'fail when using --files together with --cached' span_id:889))} {(DQ ('\n') ('\ttest_must_fail git submodule summary --files --cached\n'))}
    )
    (C {(test_expect_success)} 
      {(SQ (Token id:Id.Lit_Chars val:'should not fail in an empty repo' span_id:901))} 
      {
        (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)})
  ]
)