(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'Test git stash'>)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <'stash some dirty working directory'>)} 
      {
        (SQ <'\n'> <'\techo 1 > file &&\n'> <'\tgit add file &&\n'> 
          <'\techo unrelated >other-file &&\n'> <'\tgit add other-file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m initial &&\n'> 
          <'\techo 2 > file &&\n'> <'\tgit add file &&\n'> <'\techo 3 > file &&\n'> <'\ttest_tick &&\n'> <'\tgit stash &&\n'> 
          <'\tgit diff-files --quiet &&\n'> <'\tgit diff-index --cached --quiet HEAD\n'>
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[50])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('diff --git a/file b/file\n') ('index 0cfbf08..00750ed 100644\n') ('--- a/file\n') 
                ('+++ b/file\n') ('@@ -1 +1 @@\n') ('-2\n') ('+3\n')
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: T
          spids: [54]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'parents of stash'>)} 
      {
        (SQ <'\n'> <'\ttest $(git rev-parse stash^) = $(git rev-parse HEAD) &&\n'> 
          <'\tgit diff stash^2..stash > output &&\n'> <'\ttest_cmp output expect\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'applying bogus stash does nothing'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git stash apply stash@{1} &&\n'> <'\techo 1 >expect &&\n'> 
          <'\ttest_cmp expect file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply does not need clean working directory'>)} 
      {
        (SQ <'\n'> <'\techo 4 >other-file &&\n'> <'\tgit stash apply &&\n'> <'\techo 3 >expect &&\n'> 
          <'\ttest_cmp expect file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply does not clobber working directory changes'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\techo 4 >file &&\n'> 
          <'\ttest_must_fail git stash apply &&\n'> <'\techo 4 >expect &&\n'> <'\ttest_cmp expect file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply stashed changes'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\techo 5 >other-file &&\n'> 
          <'\tgit add other-file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m other-file &&\n'> <'\tgit stash apply &&\n'> 
          <'\ttest 3 = $(cat file) &&\n'> <'\ttest 1 = $(git show :file) &&\n'> <'\ttest 1 = $(git show HEAD:file)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply stashed changes (including index)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard HEAD^ &&\n'> <'\techo 6 > other-file &&\n'> 
          <'\tgit add other-file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m other-file &&\n'> <'\tgit stash apply --index &&\n'> 
          <'\ttest 3 = $(cat file) &&\n'> <'\ttest 2 = $(git show :file) &&\n'> <'\ttest 1 = $(git show HEAD:file)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unstashing in a subdirectory'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard HEAD &&\n'> <'\tmkdir subdir &&\n'> <'\t(\n'> 
          <'\t\tcd subdir &&\n'> <'\t\tgit stash apply\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash drop complains of extra options'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git stash drop --foo\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'drop top stash'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit stash list > stashlist1 &&\n'> 
          <'\techo 7 > file &&\n'> <'\tgit stash &&\n'> <'\tgit stash drop &&\n'> <'\tgit stash list > stashlist2 &&\n'> 
          <'\ttest_cmp stashlist1 stashlist2 &&\n'> <'\tgit stash apply &&\n'> <'\ttest 3 = $(cat file) &&\n'> <'\ttest 1 = $(git show :file) &&\n'> 
          <'\ttest 1 = $(git show HEAD:file)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'drop middle stash'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\techo 8 > file &&\n'> <'\tgit stash &&\n'> 
          <'\techo 9 > file &&\n'> <'\tgit stash &&\n'> <'\tgit stash drop stash@{1} &&\n'> <'\ttest 2 = $(git stash list | wc -l) &&\n'> 
          <'\tgit stash apply &&\n'> <'\ttest 9 = $(cat file) &&\n'> <'\ttest 1 = $(git show :file) &&\n'> 
          <'\ttest 1 = $(git show HEAD:file) &&\n'> <'\tgit reset --hard &&\n'> <'\tgit stash drop &&\n'> <'\tgit stash apply &&\n'> 
          <'\ttest 3 = $(cat file) &&\n'> <'\ttest 1 = $(git show :file) &&\n'> <'\ttest 1 = $(git show HEAD:file)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash pop'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit stash pop &&\n'> <'\ttest 3 = $(cat file) &&\n'> 
          <'\ttest 1 = $(git show :file) &&\n'> <'\ttest 1 = $(git show HEAD:file) &&\n'> <'\ttest 0 = $(git stash list | wc -l)\n'>
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[264])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('diff --git a/file2 b/file2\n') ('new file mode 100644\n') 
                ('index 0000000..1fe912c\n') ('--- /dev/null\n') ('+++ b/file2\n') ('@@ -0,0 +1 @@\n') ('+bar2\n')
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: T
          spids: [268]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect1)} spids:[283])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('diff --git a/file b/file\n') ('index 257cc56..5716ca5 100644\n') ('--- a/file\n') 
                ('+++ b/file\n') ('@@ -1 +1 @@\n') ('-foo\n') ('+bar\n')
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: T
          spids: [287]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect2)} spids:[302])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('diff --git a/file b/file\n') ('index 7601807..5716ca5 100644\n') ('--- a/file\n') 
                ('+++ b/file\n') ('@@ -1 +1 @@\n') ('-baz\n') ('+bar\n') ('diff --git a/file2 b/file2\n') ('new file mode 100644\n') 
                ('index 0000000..1fe912c\n') ('--- /dev/null\n') ('+++ b/file2\n') ('@@ -0,0 +1 @@\n') ('+bar2\n')
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: T
          spids: [306]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'stash branch'>)} 
      {
        (SQ <'\n'> <'\techo foo > file &&\n'> <'\tgit commit file -m first &&\n'> 
          <'\techo bar > file &&\n'> <'\techo bar2 > file2 &&\n'> <'\tgit add file2 &&\n'> <'\tgit stash &&\n'> <'\techo baz > file &&\n'> 
          <'\tgit commit file -m second &&\n'> <'\tgit stash branch stashbranch &&\n'> 
          <'\ttest refs/heads/stashbranch = $(git symbolic-ref HEAD) &&\n'> <'\ttest $(git rev-parse HEAD) = $(git rev-parse master^) &&\n'> <'\tgit diff --cached > output &&\n'> 
          <'\ttest_cmp output expect &&\n'> <'\tgit diff > output &&\n'> <'\ttest_cmp output expect1 &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m alternate\\ second &&\n'> <'\tgit diff master..stashbranch > output &&\n'> <'\ttest_cmp output expect2 &&\n'> 
          <'\ttest 0 = $(git stash list | wc -l)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply -q is quiet'>)} 
      {
        (SQ <'\n'> <'\techo foo > file &&\n'> <'\tgit stash &&\n'> 
          <'\tgit stash apply -q > output.out 2>&1 &&\n'> <'\ttest_must_be_empty output.out\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'save -q is quiet'>)} 
      {
        (SQ <'\n'> <'\tgit stash save --quiet > output.out 2>&1 &&\n'> 
          <'\ttest_must_be_empty output.out\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'pop -q is quiet'>)} 
      {
        (SQ <'\n'> <'\tgit stash pop -q > output.out 2>&1 &&\n'> <'\ttest_must_be_empty output.out\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'pop -q --index works and is quiet'>)} 
      {
        (SQ <'\n'> <'\techo foo > file &&\n'> <'\tgit add file &&\n'> <'\tgit stash save --quiet &&\n'> 
          <'\tgit stash pop -q --index > output.out 2>&1 &&\n'> <'\ttest foo = "$(git show :file)" &&\n'> <'\ttest_must_be_empty output.out\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'drop -q is quiet'>)} 
      {
        (SQ <'\n'> <'\tgit stash &&\n'> <'\tgit stash drop -q > output.out 2>&1 &&\n'> 
          <'\ttest_must_be_empty output.out\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash -k'>)} 
      {
        (SQ <'\n'> <'\techo bar3 > file &&\n'> <'\techo bar4 > file2 &&\n'> <'\tgit add file2 &&\n'> 
          <'\tgit stash -k &&\n'> <'\ttest bar,bar4 = $(cat file),$(cat file2)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash --no-keep-index'>)} 
      {
        (SQ <'\n'> <'\techo bar33 > file &&\n'> <'\techo bar44 > file2 &&\n'> <'\tgit add file2 &&\n'> 
          <'\tgit stash --no-keep-index &&\n'> <'\ttest bar,bar2 = $(cat file),$(cat file2)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash --invalid-option'>)} 
      {
        (SQ <'\n'> <'\techo bar5 > file &&\n'> <'\techo bar6 > file2 &&\n'> <'\tgit add file2 &&\n'> 
          <'\ttest_must_fail git stash --invalid-option &&\n'> <'\ttest_must_fail git stash save --invalid-option &&\n'> 
          <'\ttest bar5,bar6 = $(cat file),$(cat file2) &&\n'> <'\tgit stash -- -message-starting-with-dash &&\n'> <'\ttest bar,bar2 = $(cat file),$(cat file2)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash an added file'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\techo new >file3 &&\n'> <'\tgit add file3 &&\n'> 
          <'\tgit stash save "added file" &&\n'> <'\t! test -r file3 &&\n'> <'\tgit stash apply &&\n'> <'\ttest new = "$(cat file3)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash rm then recreate'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit rm file &&\n'> <'\techo bar7 >file &&\n'> 
          <'\tgit stash save "rm then recreate" &&\n'> <'\ttest bar = "$(cat file)" &&\n'> <'\tgit stash apply &&\n'> <'\ttest bar7 = "$(cat file)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash rm and ignore'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit rm file &&\n'> <'\techo file >.gitignore &&\n'> 
          <'\tgit stash save "rm and ignore" &&\n'> <'\ttest bar = "$(cat file)" &&\n'> <'\ttest file = "$(cat .gitignore)" &&\n'> 
          <'\tgit stash apply &&\n'> <'\t! test -r file &&\n'> <'\ttest file = "$(cat .gitignore)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash rm and ignore (stage .gitignore)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit rm file &&\n'> <'\techo file >.gitignore &&\n'> 
          <'\tgit add .gitignore &&\n'> <'\tgit stash save "rm and ignore (stage .gitignore)" &&\n'> <'\ttest bar = "$(cat file)" &&\n'> 
          <'\t! test -r .gitignore &&\n'> <'\tgit stash apply &&\n'> <'\t! test -r file &&\n'> <'\ttest file = "$(cat .gitignore)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'stash file to symlink'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\trm file &&\n'> <'\tln -s file2 file &&\n'> 
          <'\tgit stash save "file to symlink" &&\n'> <'\ttest -f file &&\n'> <'\ttest bar = "$(cat file)" &&\n'> <'\tgit stash apply &&\n'> 
          <'\tcase "$(ls -l file)" in *" file -> file2") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'stash file to symlink (stage rm)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit rm file &&\n'> <'\tln -s file2 file &&\n'> 
          <'\tgit stash save "file to symlink (stage rm)" &&\n'> <'\ttest -f file &&\n'> <'\ttest bar = "$(cat file)" &&\n'> <'\tgit stash apply &&\n'> 
          <'\tcase "$(ls -l file)" in *" file -> file2") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'stash file to symlink (full stage)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\trm file &&\n'> <'\tln -s file2 file &&\n'> 
          <'\tgit add file &&\n'> <'\tgit stash save "file to symlink (full stage)" &&\n'> <'\ttest -f file &&\n'> 
          <'\ttest bar = "$(cat file)" &&\n'> <'\tgit stash apply &&\n'> <'\tcase "$(ls -l file)" in *" file -> file2") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash symlink to file'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\ttest_ln_s_add file filelink &&\n'> 
          <'\tgit commit -m "Add symlink" &&\n'> <'\trm filelink &&\n'> <'\tcp file filelink &&\n'> <'\tgit stash save "symlink to file"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'this must have re-created the symlink'>)} 
      {
        (SQ <'\n'> <'\ttest -h filelink &&\n'> 
          <'\tcase "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unstash must re-create the file'>)} 
      {
        (SQ <'\n'> <'\tgit stash apply &&\n'> <'\t! test -h filelink &&\n'> 
          <'\ttest bar = "$(cat file)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash symlink to file (stage rm)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit rm filelink &&\n'> <'\tcp file filelink &&\n'> 
          <'\tgit stash save "symlink to file (stage rm)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'this must have re-created the symlink'>)} 
      {
        (SQ <'\n'> <'\ttest -h filelink &&\n'> 
          <'\tcase "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unstash must re-create the file'>)} 
      {
        (SQ <'\n'> <'\tgit stash apply &&\n'> <'\t! test -h filelink &&\n'> 
          <'\ttest bar = "$(cat file)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash symlink to file (full stage)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\trm filelink &&\n'> <'\tcp file filelink &&\n'> 
          <'\tgit add filelink &&\n'> <'\tgit stash save "symlink to file (full stage)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'this must have re-created the symlink'>)} 
      {
        (SQ <'\n'> <'\ttest -h filelink &&\n'> 
          <'\tcase "$(ls -l filelink)" in *" filelink -> file") :;; *) false;; esac\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unstash must re-create the file'>)} 
      {
        (SQ <'\n'> <'\tgit stash apply &&\n'> <'\t! test -h filelink &&\n'> 
          <'\ttest bar = "$(cat file)"\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'stash directory to file'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tmkdir dir &&\n'> <'\techo foo >dir/file &&\n'> 
          <'\tgit add dir/file &&\n'> <'\tgit commit -m "Add file in dir" &&\n'> <'\trm -fr dir &&\n'> <'\techo bar >dir &&\n'> 
          <'\tgit stash save "directory to file" &&\n'> <'\ttest -d dir &&\n'> <'\ttest foo = "$(cat dir/file)" &&\n'> 
          <'\ttest_must_fail git stash apply &&\n'> <'\ttest bar = "$(cat dir)" &&\n'> <'\tgit reset --soft HEAD^\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'stash file to directory'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\trm file &&\n'> <'\tmkdir file &&\n'> 
          <'\techo foo >file/file &&\n'> <'\tgit stash save "file to directory" &&\n'> <'\ttest -f file &&\n'> 
          <'\ttest bar = "$(cat file)" &&\n'> <'\tgit stash apply &&\n'> <'\ttest -f file/file &&\n'> <'\ttest foo = "$(cat file/file)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash branch - no stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit stash branch stash-branch ${STASH_ID} &&\n'> 
          <
'\ttest_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&\n'
          > <'\ttest $(git ls-files --modified | wc -l) -eq 1\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash branch - stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tgit stash &&\n'> <'\ttest_when_finished "git stash drop" &&\n'> 
          <'\techo bar >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit stash branch stash-branch ${STASH_ID} &&\n'> 
          <
'\ttest_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&\n'
          > <'\ttest $(git ls-files --modified | wc -l) -eq 1\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash show format defaults to --stat'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tgit stash &&\n'> <'\ttest_when_finished "git stash drop" &&\n'> 
          <'\techo bar >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> <'\tcat >expected <<-EOF &&\n'> 
          <'\t file | 1 +\n'> <'\t 1 file changed, 1 insertion(+)\n'> <'\tEOF\n'> <'\tgit stash show ${STASH_ID} >actual &&\n'> 
          <'\ttest_i18ncmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash show - stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tgit stash &&\n'> <'\ttest_when_finished "git stash drop" &&\n'> 
          <'\techo bar >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> 
          <'\techo "1\t0\tfile" >expected &&\n'> <'\tgit stash show --numstat ${STASH_ID} >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash show -p - stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tgit stash &&\n'> <'\ttest_when_finished "git stash drop" &&\n'> 
          <'\techo bar >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> <'\tcat >expected <<-EOF &&\n'> 
          <'\tdiff --git a/file b/file\n'> <'\tindex 7601807..935fbd3 100644\n'> <'\t--- a/file\n'> <'\t+++ b/file\n'> <'\t@@ -1 +1,2 @@\n'> 
          <'\t baz\n'> <'\t+bar\n'> <'\tEOF\n'> <'\tgit stash show -p ${STASH_ID} >actual &&\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash show - no stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> 
          <'\techo "1\t0\tfile" >expected &&\n'> <'\tgit stash show --numstat ${STASH_ID} >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash show -p - no stashes on stack, stash-like argument'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_when_finished "git reset --hard HEAD" &&\n'> 
          <'\tgit reset --hard &&\n'> <'\techo foo >> file &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tcat >expected <<-EOF &&\n'> <'\tdiff --git a/file b/file\n'> <'\tindex 7601807..71b52c4 100644\n'> <'\t--- a/file\n'> 
          <'\t+++ b/file\n'> <'\t@@ -1 +1,2 @@\n'> <'\t baz\n'> <'\t+foo\n'> <'\tEOF\n'> 
          <'\tgit stash show -p ${STASH_ID} >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'stash drop - fail early if specified stash is not a stash reference'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD && git stash clear" &&\n'> <'\tgit reset --hard &&\n'> <'\techo foo > file &&\n'> <'\tgit stash &&\n'> <'\techo bar > file &&\n'> 
          <'\tgit stash &&\n'> <'\ttest_must_fail git stash drop $(git rev-parse stash@{0}) &&\n'> <'\tgit stash pop &&\n'> 
          <'\ttest bar = "$(cat file)" &&\n'> <'\tgit reset --hard HEAD\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'stash pop - fail early if specified stash is not a stash reference'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD && git stash clear" &&\n'> <'\tgit reset --hard &&\n'> <'\techo foo > file &&\n'> <'\tgit stash &&\n'> <'\techo bar > file &&\n'> 
          <'\tgit stash &&\n'> <'\ttest_must_fail git stash pop $(git rev-parse stash@{0}) &&\n'> <'\tgit stash pop &&\n'> 
          <'\ttest bar = "$(cat file)" &&\n'> <'\tgit reset --hard HEAD\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'ref with non-existent reflog'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\techo bar5 > file &&\n'> <'\techo bar6 > file2 &&\n'> 
          <'\tgit add file2 &&\n'> <'\tgit stash &&\n'> <'\ttest_must_fail git rev-parse --quiet --verify does-not-exist &&\n'> 
          <'\ttest_must_fail git stash drop does-not-exist &&\n'> <'\ttest_must_fail git stash drop does-not-exist@{0} &&\n'> 
          <'\ttest_must_fail git stash pop does-not-exist &&\n'> <'\ttest_must_fail git stash pop does-not-exist@{0} &&\n'> 
          <'\ttest_must_fail git stash apply does-not-exist &&\n'> <'\ttest_must_fail git stash apply does-not-exist@{0} &&\n'> 
          <'\ttest_must_fail git stash show does-not-exist &&\n'> <'\ttest_must_fail git stash show does-not-exist@{0} &&\n'> 
          <'\ttest_must_fail git stash branch tmp does-not-exist &&\n'> <'\ttest_must_fail git stash branch tmp does-not-exist@{0} &&\n'> <'\tgit stash drop\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'invalid ref of the form stash@{n}, n >= N'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\ttest_must_fail git stash drop stash@{0} &&\n'> 
          <'\techo bar5 > file &&\n'> <'\techo bar6 > file2 &&\n'> <'\tgit add file2 &&\n'> <'\tgit stash &&\n'> 
          <'\ttest_must_fail git stash drop stash@{1} &&\n'> <'\ttest_must_fail git stash pop stash@{1} &&\n'> <'\ttest_must_fail git stash apply stash@{1} &&\n'> 
          <'\ttest_must_fail git stash show stash@{1} &&\n'> <'\ttest_must_fail git stash branch tmp stash@{1} &&\n'> <'\tgit stash drop\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash branch should not drop the stash if the branch exists'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\techo foo >file &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m initial &&\n'> <'\techo bar >file &&\n'> <'\tgit stash &&\n'> 
          <'\ttest_must_fail git stash branch master stash@{0} &&\n'> <'\tgit rev-parse stash@{0} --\n'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'stash apply shows status same as git status (relative to current directory)'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\techo 1 >subdir/subfile1 &&\n'> 
          <'\techo 2 >subdir/subfile2 &&\n'> <'\tgit add subdir/subfile1 &&\n'> <'\tgit commit -m subdir &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\techo x >subfile1 &&\n'> <'\t\techo x >../file &&\n'> <'\t\tgit status >../expect &&\n'> <'\t\tgit stash &&\n'> 
          <'\t\tsane_unset GIT_MERGE_VERBOSITY &&\n'> <'\t\tgit stash apply\n'> <'\t) |\n'> 
          <'\tsed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..."\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[1119])
        (HereDoc
          op_id: Redir_DLess
          fd: 16777215
          body: 
            {
              (DQ ('diff --git a/HEAD b/HEAD\n') ('new file mode 100644\n') 
                ('index 0000000..fe0cbee\n') ('--- /dev/null\n') ('+++ b/HEAD\n') ('@@ -0,0 +1 @@\n') ('+file-not-a-ref\n')
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: T
          spids: [1123]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'stash where working directory contains "HEAD" file'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\tgit reset --hard &&\n'> 
          <'\techo file-not-a-ref > HEAD &&\n'> <'\tgit add HEAD &&\n'> <'\ttest_tick &&\n'> <'\tgit stash &&\n'> <'\tgit diff-files --quiet &&\n'> 
          <'\tgit diff-index --cached --quiet HEAD &&\n'> <'\ttest "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&\n'> 
          <'\tgit diff stash^..stash > output &&\n'> <'\ttest_cmp output expect\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'store called with invalid commit'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git stash store foo\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'store updates stash ref and reflog'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\tgit reset --hard &&\n'> <'\techo quux >bazzy &&\n'> 
          <'\tgit add bazzy &&\n'> <'\tSTASH_ID=$(git stash create) &&\n'> <'\tgit reset --hard &&\n'> <'\t! grep quux bazzy &&\n'> 
          <'\tgit stash store -m quuxery $STASH_ID &&\n'> <'\ttest $(cat .git/refs/stash) = $STASH_ID &&\n'> 
          <'\tgit reflog --format=%H stash| grep $STASH_ID &&\n'> <'\tgit stash pop &&\n'> <'\tgrep quux bazzy\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'handle stash specification with spaces'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\techo pig >file &&\n'> <'\tgit stash &&\n'> 
          <'\tstamp=$(git log -g --format="%cd" -1 refs/stash) &&\n'> <'\ttest_tick &&\n'> <'\techo cow >file &&\n'> <'\tgit stash &&\n'> 
          <'\tgit stash apply "stash@{$stamp}" &&\n'> <'\tgrep pig file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup stash with index and worktree changes'>)} 
      {
        (SQ <'\n'> <'\tgit stash clear &&\n'> <'\tgit reset --hard &&\n'> <'\techo index >file &&\n'> 
          <'\tgit add file &&\n'> <'\techo working >file &&\n'> <'\tgit stash\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash list implies --first-parent -m'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-EOF &&\n'> <'\tstash@{0}\n'> <'\n'> 
          <'\tdiff --git a/file b/file\n'> <'\tindex 257cc56..d26b33d 100644\n'> <'\t--- a/file\n'> <'\t+++ b/file\n'> <'\t@@ -1 +1 @@\n'> 
          <'\t-foo\n'> <'\t+working\n'> <'\tEOF\n'> <'\tgit stash list --format=%gd -p >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'stash list --cc shows combined diff'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tstash@{0}\n'> <'\n'> <'\tdiff --cc file\n'> 
          <'\tindex 257cc56,9015a7a..d26b33d\n'> <'\t--- a/file\n'> <'\t+++ b/file\n'> <'\t@@@ -1,1 -1,1 +1,1 @@@\n'> <'\t- foo\n'> <'\t -index\n'> 
          <'\t++working\n'> <'\tEOF\n'> <'\tgit stash list --format=%gd -p --cc >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)