(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"external diff interface test">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <"\n"> <"\n"> <"\ttest_tick &&\n"> <"\techo initial >file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m initial &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\techo second >file &&\n"> <"\tgit add file &&\n"> 
          <"\tgit commit -m second &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\techo third >file\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF environment">)} 
      {
        (SQ <"\n"> <"\n"> <"\tGIT_EXTERNAL_DIFF=echo git diff | {\n"> 
          <"\t\tread path oldfile oldhex oldmode newfile newhex newmode &&\n"> <"\t\ttest \"z$path\" = zfile &&\n"> <"\t\ttest \"z$oldmode\" = z100644 &&\n"> 
          <"\t\ttest \"z$newhex\" = \"z$_z40\" &&\n"> <"\t\ttest \"z$newmode\" = z100644 &&\n"> <"\t\toh=$(git rev-parse --verify HEAD:file) &&\n"> 
          <"\t\ttest \"z$oh\" = \"z$oldhex\"\n"> <"\t}\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF environment should apply only to diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tGIT_EXTERNAL_DIFF=echo git log -p -1 HEAD |\n"> 
          <"\tgrep \"^diff --git a/file b/file\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF environment and --no-ext-diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tGIT_EXTERNAL_DIFF=echo git diff --no-ext-diff |\n"> 
          <"\tgrep \"^diff --git a/file b/file\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"typechange diff">)} 
      {
        (SQ <"\n"> <"\trm -f file &&\n"> <"\tln -s elif file &&\n"> 
          <"\tGIT_EXTERNAL_DIFF=echo git diff  | {\n"> <"\t\tread path oldfile oldhex oldmode newfile newhex newmode &&\n"> 
          <"\t\ttest \"z$path\" = zfile &&\n"> <"\t\ttest \"z$oldmode\" = z100644 &&\n"> <"\t\ttest \"z$newhex\" = \"z$_z40\" &&\n"> 
          <"\t\ttest \"z$newmode\" = z120000 &&\n"> <"\t\toh=$(git rev-parse --verify HEAD:file) &&\n"> <"\t\ttest \"z$oh\" = \"z$oldhex\"\n"> <"\t} &&\n"> 
          <"\tGIT_EXTERNAL_DIFF=echo git diff --no-ext-diff >actual &&\n"> <"\tgit diff >expect &&\n"> <"\ttest_cmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <diff.external>)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\techo third >file &&\n"> 
          <"\ttest_config diff.external echo &&\n"> <"\tgit diff | {\n"> <"\t\tread path oldfile oldhex oldmode newfile newhex newmode &&\n"> 
          <"\t\ttest \"z$path\" = zfile &&\n"> <"\t\ttest \"z$oldmode\" = z100644 &&\n"> <"\t\ttest \"z$newhex\" = \"z$_z40\" &&\n"> 
          <"\t\ttest \"z$newmode\" = z100644 &&\n"> <"\t\toh=$(git rev-parse --verify HEAD:file) &&\n"> <"\t\ttest \"z$oh\" = \"z$oldhex\"\n"> <"\t}\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff.external should apply only to diff">)} 
      {
        (SQ <"\n"> <"\ttest_config diff.external echo &&\n"> <"\tgit log -p -1 HEAD |\n"> 
          <"\tgrep \"^diff --git a/file b/file\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff.external and --no-ext-diff">)} 
      {
        (SQ <"\n"> <"\ttest_config diff.external echo &&\n"> <"\tgit diff --no-ext-diff |\n"> 
          <"\tgrep \"^diff --git a/file b/file\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\techo third >file &&\n"> <"\n"> 
          <"\tgit config diff.parrot.command echo &&\n"> <"\n"> <"\techo >.gitattributes \"file diff=parrot\" &&\n"> <"\n"> <"\tgit diff | {\n"> 
          <"\t\tread path oldfile oldhex oldmode newfile newhex newmode &&\n"> <"\t\ttest \"z$path\" = zfile &&\n"> <"\t\ttest \"z$oldmode\" = z100644 &&\n"> 
          <"\t\ttest \"z$newhex\" = \"z$_z40\" &&\n"> <"\t\ttest \"z$newmode\" = z100644 &&\n"> <"\t\toh=$(git rev-parse --verify HEAD:file) &&\n"> 
          <"\t\ttest \"z$oh\" = \"z$oldhex\"\n"> <"\t}\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute should apply only to diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tgit log -p -1 HEAD |\n"> <"\tgrep \"^diff --git a/file b/file\"\n"> <"\n">)
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute and --no-ext-diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tgit diff --no-ext-diff |\n"> <"\tgrep \"^diff --git a/file b/file\"\n"> 
          <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute">)} 
      {
        (SQ <"\n"> <"\n"> <"\tgit config --unset diff.parrot.command &&\n"> 
          <"\tgit config diff.color.command echo &&\n"> <"\n"> <"\techo >.gitattributes \"file diff=color\" &&\n"> <"\n"> <"\tgit diff | {\n"> 
          <"\t\tread path oldfile oldhex oldmode newfile newhex newmode &&\n"> <"\t\ttest \"z$path\" = zfile &&\n"> <"\t\ttest \"z$oldmode\" = z100644 &&\n"> 
          <"\t\ttest \"z$newhex\" = \"z$_z40\" &&\n"> <"\t\ttest \"z$newmode\" = z100644 &&\n"> <"\t\toh=$(git rev-parse --verify HEAD:file) &&\n"> 
          <"\t\ttest \"z$oh\" = \"z$oldhex\"\n"> <"\t}\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute should apply only to diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tgit log -p -1 HEAD |\n"> <"\tgrep \"^diff --git a/file b/file\"\n"> <"\n">)
      }
    )
    (C {(test_expect_success)} {(SQ <"diff attribute and --no-ext-diff">)} 
      {
        (SQ <"\n"> <"\n"> <"\tgit diff --no-ext-diff |\n"> <"\tgrep \"^diff --git a/file b/file\"\n"> 
          <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF trumps diff.external">)} 
      {
        (SQ <"\n"> <"\t>.gitattributes &&\n"> <"\ttest_config diff.external \"echo ext-global\" &&\n"> 
          <"\tGIT_EXTERNAL_DIFF=\"echo ext-env\" git diff | grep ext-env\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"attributes trump GIT_EXTERNAL_DIFF and diff.external">)} 
      {
        (SQ <"\n"> <"\ttest_config diff.foo.command \"echo ext-attribute\" &&\n"> 
          <"\ttest_config diff.external \"echo ext-global\" &&\n"> <"\techo \"file diff=foo\" >.gitattributes &&\n"> 
          <"\tGIT_EXTERNAL_DIFF=\"echo ext-env\" git diff | grep ext-attribute\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"no diff with -diff">)} 
      {(SQ <"\n"> <"\techo >.gitattributes \"file -diff\" &&\n"> <"\tgit diff | grep Binary\n">)}
    )
    (Pipeline
      children: [
        (C {(echo)} {(NULZbetweenZwords)})
        (SimpleCommand
          words: [{(perl)} {(-pe)} {(SQ <"y/Z/\\000/">)}]
          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(file)} spids:[338])]
        )
      ]
      negated: False
    )
    (C {(test_expect_success)} {(SQ <"force diff with \"diff\"">)} 
      {
        (SQ <"\n"> <"\techo >.gitattributes \"file diff\" &&\n"> <"\tgit diff >actual &&\n"> 
          <"\ttest_cmp \"$TEST_DIRECTORY\"/t4020/diff.NUL actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF with more than one changed files">)} 
      {
        (SQ <"\n"> <"\techo anotherfile > file2 &&\n"> <"\tgit add file2 &&\n"> 
          <"\tgit commit -m \"added 2nd file\" &&\n"> <"\techo modified >file2 &&\n"> <"\tGIT_EXTERNAL_DIFF=echo git diff\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF path counter/total">)} 
      {
        (SQ <"\n"> <"\twrite_script external-diff.sh <<-\\EOF &&\n"> 
          <"\techo $GIT_DIFF_PATH_COUNTER of $GIT_DIFF_PATH_TOTAL >>counter.txt\n"> <"\tEOF\n"> <"\t>counter.txt &&\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t1 of 2\n"> <"\t2 of 2\n"> 
          <"\tEOF\n"> <"\tGIT_EXTERNAL_DIFF=./external-diff.sh git diff &&\n"> <"\ttest_cmp expect counter.txt\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_EXTERNAL_DIFF generates pretty paths">)} 
      {
        (SQ <"\n"> <"\ttouch file.ext &&\n"> <"\tgit add file.ext &&\n"> 
          <"\techo with extension > file.ext &&\n"> <"\tGIT_EXTERNAL_DIFF=echo git diff file.ext | grep ......_file\\.ext &&\n"> 
          <"\tgit update-index --force-remove file.ext &&\n"> <"\trm file.ext\n">
        )
      }
    )
    (SimpleCommand
      words: [{(echo)} {(DQ ("#!") ($ VSub_Name "$SHELL_PATH"))}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(fake-diff.sh)} spids:[418])]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_DGreat fd:-1 arg_word:{(fake-diff.sh)} spids:[423])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {("cat $2 >> crlfed.txt\n")}
          do_expansion: False
          here_end: EOF
          was_filled: True
          spids: [427]
        )
      ]
    )
    (C {(chmod)} {(a) (Lit_Other "+") (x)} {(fake-diff.sh)})
    (FuncDef
      name: keep_only_cr
      body: (BraceGroup children:[(C {(tr)} {(-dc)} {(SQ <"\\015">)})] spids:[445])
      spids: [440 444]
    )
    (C {(test_expect_success)} {(SQ <"external diff with autocrlf = true">)} 
      {
        (SQ <"\n"> <"\ttest_config core.autocrlf true &&\n"> 
          <"\tGIT_EXTERNAL_DIFF=./fake-diff.sh git diff &&\n"> <"\ttest $(wc -l < crlfed.txt) = $(cat crlfed.txt | keep_only_cr | wc -c)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"diff --cached">)} 
      {
        (SQ <"\n"> <"\ttest_config core.autocrlf true &&\n"> <"\tgit add file &&\n"> 
          <"\tgit update-index --assume-unchanged file &&\n"> <"\techo second >file &&\n"> <"\tgit diff --cached >actual &&\n"> 
          <"\ttest_cmp \"$TEST_DIRECTORY\"/t4020/diff.NUL actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"clean up crlf leftovers">)} 
      {
        (SQ <"\n"> <"\tgit update-index --no-assume-unchanged file &&\n"> <"\trm -f file* &&\n"> 
          <"\tgit reset --hard\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"submodule diff">)} 
      {
        (SQ <"\n"> <"\tgit init sub &&\n"> <"\t( cd sub && test_commit sub1 ) &&\n"> 
          <"\tgit add sub &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m \"add submodule\" &&\n"> 
          <"\t( cd sub && test_commit sub2 ) &&\n"> <"\twrite_script gather_pre_post.sh <<-\\EOF &&\n"> <"\techo \"$1 $4\" # path, mode\n"> 
          <"\tcat \"$2\" # old file\n"> <"\tcat \"$5\" # new file\n"> <"\tEOF\n"> 
          <"\tGIT_EXTERNAL_DIFF=./gather_pre_post.sh git diff >actual &&\n"> <"\tcat >expected <<-EOF &&\n"> <"\tsub 160000\n"> <"\tSubproject commit $(git rev-parse HEAD:sub)\n"> 
          <"\tSubproject commit $(cd sub && git rev-parse HEAD)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n">
        )
      }
    )
    (C {(test_done)})
  ]
)