(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'git p4 filetype tests'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./lib-git-p4.sh)})
    (C {(test_expect_success)} {(SQ <'start p4d'>)} {(SQ <'\n'> <'\tstart_p4d\n'>)})
    (C {(test_expect_success)} {(SQ <'p4 client newlines, unix'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&\n'> <'\t\tprintf "unix\\ncrlf\\n" >f-unix &&\n'> 
          <'\t\tprintf "unix\\r\\ncrlf\\r\\n" >f-unix-as-crlf &&\n'> <'\t\tp4 add -t text f-unix &&\n'> <'\t\tp4 submit -d f-unix &&\n'> <'\n'> 
          <'\t\t# LineEnd: unix; should be no change after sync\n'> <'\t\tcp f-unix f-unix-orig &&\n'> <'\t\tp4 sync -f &&\n'> <'\t\ttest_cmp f-unix-orig f-unix &&\n'> 
          <'\n'> <'\t\t# make sure stored in repo as unix newlines\n'> 
          <'\t\t# use sed to eat python-appended newline\n'> <'\t\tp4 -G print //depot/f-unix | marshal_dump data 2 |\\\n'> 
          <'\t\t    sed \\$d >f-unix-p4-print &&\n'> <'\t\ttest_cmp f-unix-orig f-unix-p4-print &&\n'> <'\n'> 
          <'\t\t# switch to win, make sure lf -> crlf\n'> <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i &&\n'> <'\t\tp4 sync -f &&\n'> 
          <'\t\ttest_cmp f-unix-as-crlf f-unix\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'p4 client newlines, win'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i &&\n'> <'\t\tprintf "win\\r\\ncrlf\\r\\n" >f-win &&\n'> <'\t\tprintf "win\\ncrlf\\n" >f-win-as-lf &&\n'> 
          <'\t\tp4 add -t text f-win &&\n'> <'\t\tp4 submit -d f-win &&\n'> <'\n'> <'\t\t# LineEnd: win; should be no change after sync\n'> 
          <'\t\tcp f-win f-win-orig &&\n'> <'\t\tp4 sync -f &&\n'> <'\t\ttest_cmp f-win-orig f-win &&\n'> <'\n'> 
          <'\t\t# make sure stored in repo as unix newlines\n'> <'\t\t# use sed to eat python-appened newline\n'> 
          <'\t\tp4 -G print //depot/f-win | marshal_dump data 2 |\\\n'> <'\t\t    sed \\$d >f-win-p4-print &&\n'> <'\t\ttest_cmp f-win-as-lf f-win-p4-print &&\n'> <'\n'> 
          <'\t\t# switch to unix, make sure lf -> crlf\n'> <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&\n'> <'\t\tp4 sync -f &&\n'> 
          <'\t\ttest_cmp f-win-as-lf f-win\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'ensure blobs store only lf newlines'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit init &&\n'> <'\t\tgit p4 sync //depot@all &&\n'> <'\n'> 
          <'\t\t# verify the files in .git are stored only with newlines\n'> <'\t\to=$(git ls-tree p4/master -- f-unix | cut -f1 | cut -d\\  -f3) &&\n'> 
          <'\t\tgit cat-file blob $o >f-unix-blob &&\n'> <'\t\ttest_cmp "$cli"/f-unix-orig f-unix-blob &&\n'> <'\n'> 
          <'\t\to=$(git ls-tree p4/master -- f-win | cut -f1 | cut -d\\  -f3) &&\n'> <'\t\tgit cat-file blob $o >f-win-blob &&\n'> <'\t\ttest_cmp "$cli"/f-win-as-lf f-win-blob &&\n'> 
          <'\n'> <'\t\trm f-unix-blob f-win-blob\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'gitattributes setting eol=lf produces lf newlines'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> 
          <'\t\t# checkout the files and make sure core.eol works as planned\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit init &&\n'> <'\t\techo "* eol=lf" >.gitattributes &&\n'> 
          <'\t\tgit p4 sync //depot@all &&\n'> <'\t\tgit checkout -b master p4/master &&\n'> <'\t\ttest_cmp "$cli"/f-unix-orig f-unix &&\n'> 
          <'\t\ttest_cmp "$cli"/f-win-as-lf f-win\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'gitattributes setting eol=crlf produces crlf newlines'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> 
          <'\t\t# checkout the files and make sure core.eol works as planned\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit init &&\n'> <'\t\techo "* eol=crlf" >.gitattributes &&\n'> 
          <'\t\tgit p4 sync //depot@all &&\n'> <'\t\tgit checkout -b master p4/master &&\n'> <'\t\ttest_cmp "$cli"/f-unix-as-crlf f-unix &&\n'> 
          <'\t\ttest_cmp "$cli"/f-win-orig f-win\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'crlf cleanup'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\trm f-unix-orig f-unix-as-crlf &&\n'> 
          <'\t\trm f-win-orig f-win-as-lf &&\n'> <'\t\tp4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&\n'> <'\t\tp4 sync -f\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'utf-16 file create'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\n'> <'\t\t# p4 saves this verbatim\n'> 
          <'\t\tprintf "three\\nline\\ntext\\n" >f-ascii &&\n'> <'\t\tp4 add -t text f-ascii &&\n'> <'\n'> <'\t\t# p4 adds \\377\\376 header\n'> 
          <'\t\tcp f-ascii f-ascii-as-utf16 &&\n'> <'\t\tp4 add -t utf16 f-ascii-as-utf16 &&\n'> <'\n'> 
          <'\t\t# p4 saves this exactly as iconv produced it\n'> <'\t\tprintf "three\\nline\\ntext\\n" | iconv -f ascii -t utf-16 >f-utf16 &&\n'> 
          <'\t\tp4 add -t utf16 f-utf16 &&\n'> <'\n'> <'\t\t# this also is unchanged\n'> <'\t\tcp f-utf16 f-utf16-as-text &&\n'> 
          <'\t\tp4 add -t text f-utf16-as-text &&\n'> <'\n'> <'\t\tp4 submit -d "f files" &&\n'> <'\n'> <'\t\t# force update of client files\n'> 
          <'\t\tp4 sync -f\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'utf-16 file test'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\n'> <'\t\ttest_cmp "$cli/f-ascii" f-ascii &&\n'> 
          <'\t\ttest_cmp "$cli/f-ascii-as-utf16" f-ascii-as-utf16 &&\n'> <'\t\ttest_cmp "$cli/f-utf16" f-utf16 &&\n'> <'\t\ttest_cmp "$cli/f-utf16-as-text" f-utf16-as-text\n'> 
          <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'keyword file create'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\n'> 
          <'\t\tprintf "id\\n\\$Id\\$\\n\\$Author\\$\\ntext\\n" >k-text-k &&\n'> <'\t\tp4 add -t text+k k-text-k &&\n'> <'\n'> <'\t\tcp k-text-k k-text-ko &&\n'> 
          <'\t\tp4 add -t text+ko k-text-ko &&\n'> <'\n'> <'\t\tcat k-text-k | iconv -f ascii -t utf-16 >k-utf16-k &&\n'> 
          <'\t\tp4 add -t utf16+k k-utf16-k &&\n'> <'\n'> <'\t\tcp k-utf16-k k-utf16-ko &&\n'> <'\t\tp4 add -t utf16+ko k-utf16-ko &&\n'> <'\n'> 
          <'\t\tp4 submit -d "k files" &&\n'> <'\t\tp4 sync -f\n'> <'\t)\n'>
        )
      }
    )
    (FuncDef
      name: build_smush
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (SimpleCommand
                  words: [{(cat)}]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(k_smush.py)}
                      spids: [296]
                    )
                    (HereDoc
                      op_id: Redir_DLessDash
                      fd: 16777215
                      body: 
                        {('import re, sys\n') 
                          (
"sys.stdout.write(re.sub(r'(?i)\\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\\$', r'$\\1$', sys.stdin.read()))\n"
                          )
                        }
                      do_expansion: False
                      here_end: EOF
                      was_filled: T
                      spids: [299]
                    )
                  ]
                )
                (SimpleCommand
                  words: [{(cat)}]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(ko_smush.py)}
                      spids: [308]
                    )
                    (HereDoc
                      op_id: Redir_DLessDash
                      fd: 16777215
                      body: 
                        {('import re, sys\n') 
                          (
"sys.stdout.write(re.sub(r'(?i)\\$(Id|Header):[^$]*\\$', r'$\\1$', sys.stdin.read()))\n"
                          )
                        }
                      do_expansion: False
                      here_end: EOF
                      was_filled: T
                      spids: [311]
                    )
                  ]
                )
              ]
            )
          ]
          spids: [291]
        )
      spids: [287 290]
    )
    (C {(test_expect_success)} {(SQ <'keyword file test'>)} 
      {
        (SQ <'\n'> <'\tbuild_smush &&\n'> <'\ttest_when_finished rm -f k_smush.py ko_smush.py &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\n'> 
          <'\t\t# text, ensure unexpanded\n'> <'\t\t"$PYTHON_PATH" "$TRASH_DIRECTORY/k_smush.py" <"$cli/k-text-k" >cli-k-text-k-smush &&\n'> 
          <'\t\ttest_cmp cli-k-text-k-smush k-text-k &&\n'> <'\t\t"$PYTHON_PATH" "$TRASH_DIRECTORY/ko_smush.py" <"$cli/k-text-ko" >cli-k-text-ko-smush &&\n'> 
          <'\t\ttest_cmp cli-k-text-ko-smush k-text-ko &&\n'> <'\n'> <'\t\t# utf16, even though p4 expands keywords, git p4 does not\n'> <'\t\t# try to undo that\n'> 
          <'\t\ttest_cmp "$cli/k-utf16-k" k-utf16-k &&\n'> <'\t\ttest_cmp "$cli/k-utf16-ko" k-utf16-ko\n'> <'\t)\n'>
        )
      }
    )
    (FuncDef
      name: build_gendouble
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [{(cat)}]
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: 16777215
                  arg_word: {(gendouble.py)}
                  spids: [356]
                )
                (HereDoc
                  op_id: Redir_DLessDash
                  fd: 16777215
                  body: 
                    {('import sys\n') ('import struct\n') ('\n') ('s = struct.pack(b">LL18s",\n') 
                      ('0x00051607,  # AppleDouble\n') ('0x00020000,  # version 2\n') ('b""          # pad to 26 bytes\n') (')\n') 
                      ("getattr(sys.stdout, 'buffer', sys.stdout).write(s)\n")
                    }
                  do_expansion: False
                  here_end: EOF
                  was_filled: T
                  spids: [359]
                )
              ]
            )
          ]
          spids: [351]
        )
      spids: [347 350]
    )
    (C {(test_expect_success)} {(SQ <'ignore apple'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished rm -f gendouble.py &&\n'> <'\tbuild_gendouble &&\n'> <'\t(\n'> 
          <'\t\tcd "$cli" &&\n'> <'\t\ttest-genrandom apple 1024 >double.png &&\n'> 
          <'\t\t"$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png &&\n'> <'\t\tp4 add -t apple double.png &&\n'> <'\t\tp4 submit -d appledouble\n'> <'\t) &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\ttest ! -f double.png\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'create p4 symlink'>)} 
      {
        (SQ <'\n'> <'\tcd "$cli" &&\n'> <'\tln -s symlink-target symlink &&\n'> 
          <'\tp4 add symlink &&\n'> <'\tp4 submit -d "add symlink"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'ensure p4 symlink parsed correctly'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\ttest -L symlink &&\n'> 
          <'\t\ttest $(readlink symlink) = symlink-target\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <'empty symlink target'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\t# first create the file as a file\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\t>empty-symlink &&\n'> <'\t\tp4 add empty-symlink &&\n'> <'\t\tp4 submit -d "add empty-symlink as a file"\n'> <'\t) &&\n'> 
          <'\t(\n'> <'\t\t# now change it to be a symlink to "target1"\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 edit empty-symlink &&\n'> <'\t\tp4 reopen -t symlink empty-symlink &&\n'> <'\t\trm empty-symlink &&\n'> 
          <'\t\tln -s target1 empty-symlink &&\n'> <'\t\tp4 add empty-symlink &&\n'> <'\t\tp4 submit -d "make empty-symlink point to target1"\n'> 
          <'\t) &&\n'> <'\t(\n'> <'\t\t# Hack the p4 depot to make the symlink point to nothing;\n'> 
          <'\t\t# this should not happen in reality, but shows up\n'> <'\t\t# in p4 repos in the wild.\n'> <'\t\t#\n'> <'\t\t# The sed expression changes this:\n'> 
          <'\t\t#     @@\n'> <'\t\t#     text\n'> <'\t\t#     @target1\n'> <'\t\t#     @\n'> <'\t\t# to this:\n'> <'\t\t#     @@\n'> 
          <'\t\t#     text\n'> <'\t\t#     @@\n'> <'\t\t#\n'> <'\t\tcd "$db/depot" &&\n'> 
          <'\t\tsed "/@target1/{; s/target1/@/; n; d; }" \\\n'> <'\t\t    empty-symlink,v >empty-symlink,v.tmp &&\n'> <'\t\tmv empty-symlink,v.tmp empty-symlink,v\n'> 
          <'\t) &&\n'> <'\t(\n'> <'\t\t# Make sure symlink really is empty.  Asking\n'> 
          <'\t\t# p4 to sync here will make it generate errors.\n'> <'\t\tcd "$cli" &&\n'> <'\t\tp4 print -q //depot/empty-symlink#2 >out &&\n'> <'\t\ttest ! -s out\n'> 
          <'\t) &&\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\n'> <'\t# make sure git p4 handles it without error\n'> 
          <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\n'> <'\t# fix the symlink, make it point to "target2"\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> 
          <'\t\tp4 open empty-symlink &&\n'> <'\t\trm empty-symlink &&\n'> <'\t\tln -s target2 empty-symlink &&\n'> 
          <'\t\tp4 submit -d "make empty-symlink point to target2"\n'> <'\t) &&\n'> <'\tcleanup_git &&\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> <'\t(\n'> 
          <'\t\tcd "$git" &&\n'> <'\t\ttest $(readlink empty-symlink) = target2\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'kill p4d'>)} {(SQ <'\n'> <'\tkill_p4d\n'>)})
    (C {(test_done)})
  ]
)