(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"applying patch that has broken whitespaces in context">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <"\n"> <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\n"> 
          <"\t# file-0 is full of whitespace breakages\n"> <"\tfor l in a bb c d eeee f ggg h\n"> <"\tdo\n"> <"\t\techo \"$l \"\n"> <"\tdone >file-0 &&\n"> <"\n"> 
          <"\t# patch-0 creates a whitespace broken file\n"> <"\tcat file-0 >file &&\n"> <"\tgit diff >patch-0 &&\n"> <"\tgit add file &&\n"> <"\n"> 
          <"\t# file-1 is still full of whitespace breakages,\n"> <"\t# but has one line updated, without fixing any\n"> <"\t# whitespaces.\n"> 
          <"\t# patch-1 records that change.\n"> <"\tsed -e \"s/d/D/\" file-0 >file-1 &&\n"> <"\tcat file-1 >file &&\n"> <"\tgit diff >patch-1 &&\n"> 
          <"\n"> <"\t# patch-all is the effect of both patch-0 and patch-1\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> 
          <"\tcat file-1 >file &&\n"> <"\tgit diff >patch-all &&\n"> <"\n"> <"\t# patch-2 is the same as patch-1 but is based\n"> 
          <"\t# on a version that already has whitespace fixed,\n"> <"\t# and does not introduce whitespace breakages.\n"> <"\tsed -e \"s/ \\$//\" patch-1 >patch-2 &&\n"> 
          <"\n"> <"\t# If all whitespace breakages are fixed the contents\n"> <"\t# should look like file-fixed\n"> 
          <"\tsed -e \"s/ \\$//\" file-1 >file-fixed\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(nofix)} 
      {
        (SQ <"\n"> <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\n"> 
          <"\t# Baseline.  Applying without fixing any whitespace\n"> <"\t# breakages.\n"> <"\tgit apply --whitespace=nowarn patch-0 &&\n"> 
          <"\tgit apply --whitespace=nowarn patch-1 &&\n"> <"\n"> <"\t# The result should obviously match.\n"> <"\ttest_cmp file-1 file\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"withfix (forward)">)} 
      {
        (SQ <"\n"> <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\n"> 
          <"\t# The first application will munge the context lines\n"> <"\t# the second patch depends on.  We should be able to\n"> <"\t# adjust and still apply.\n"> 
          <"\tgit apply --whitespace=fix patch-0 &&\n"> <"\tgit apply --whitespace=fix patch-1 &&\n"> <"\n"> <"\ttest_cmp file-fixed file\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"withfix (backward)">)} 
      {
        (SQ <"\n"> <"\n"> <"\t>file &&\n"> <"\tgit add file &&\n"> <"\n"> 
          <"\t# Now we have a whitespace breakages on our side.\n"> <"\tgit apply --whitespace=nowarn patch-0 &&\n"> <"\n"> 
          <"\t# And somebody sends in a patch based on image\n"> <"\t# with whitespace already fixed.\n"> <"\tgit apply --whitespace=fix patch-2 &&\n"> <"\n"> 
          <"\t# The result should accept the whitespace fixed\n"> <"\t# postimage.  But the line with \"h\" is beyond context\n"> <"\t# horizon and left unfixed.\n"> 
          <"\n"> <"\tsed -e /h/d file-fixed >fixed-head &&\n"> <"\tsed -e /h/d file >file-head &&\n"> 
          <"\ttest_cmp fixed-head file-head &&\n"> <"\n"> <"\tsed -n -e /h/p file-fixed >fixed-tail &&\n"> <"\tsed -n -e /h/p file >file-tail &&\n"> <"\n"> 
          <"\t! test_cmp fixed-tail file-tail\n"> <"\n">
        )
      }
    )
    (C {(test_done)})
  ]
)