This project is mirrored from https://github.com/git/git. Updated .
  1. 26 Jan, 2010 1 commit
  2. 13 Mar, 2008 1 commit
    • Jeff King's avatar
      add test_cmp function for test scripts · 82ebb0b6
      Jeff King authored
      Many scripts compare actual and expected output using
      "diff -u". This is nicer than "cmp" because the output shows
      how the two differ. However, not all versions of diff
      understand -u, leading to unnecessary test failure.
      
      This adds a test_cmp function to the test scripts and
      switches all "diff -u" invocations to use it. The function
      uses the contents of "$GIT_TEST_CMP" to compare its
      arguments; the default is "diff -u".
      
      On systems with a less-capable diff, you can do:
      
        GIT_TEST_CMP=cmp make test
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      82ebb0b6
  3. 05 Feb, 2008 1 commit
    • Junio C Hamano's avatar
      git-apply --whitespace=fix: fix whitespace fuzz introduced by previous run · c1beba5b
      Junio C Hamano authored
      When you have more than one patch series, an earlier one of which
      tries to introduce whitespace breakages and a later one of which
      has such a new line in its context, "git-apply --whitespace=fix"
      will apply and fix the whitespace breakages in the earlier one,
      making the resulting file not to match the context of the later
      patch.
      
      A short demonstration is in the new test, t4125.
      
      For example, suppose the first patch is:
      
          diff a/hello.txt b/hello.txt
          --- a/hello.txt
          +++ b/hello.txt
          @@ -20,3 +20,3 @@
           Hello world.$
          -How Are you$
          -Today?$
          +How are you $
          +today? $
      
      to fix broken case in the string, but it introduces unwanted
      trailing whitespaces to the result (pretend you are looking at
      "cat -e" output of the patch --- '$' signs are not in the patch
      but are shown to make the EOL stand out).  And the second patch
      is to change the wording of the greeting further:
      
          diff a/hello.txt b/hello.txt
          --- a/hello.txt
          +++ b/hello.txt
          @@ -18,5 +18,5 @@
           Greetings $
      
          -Hello world.$
          +Hello, everybody. $
           How are you $
          -today? $
          +these days? $
      
      If you apply the first one with --whitespace=fix, you will get
      this as the result:
      
          Hello world.$
          How are you$
          today?$
      
      and this does not match the preimage of the second patch, which
      demands extra whitespace after "How are you" and "today?".
      
      This series is about teaching "git apply --whitespace=fix" to
      cope with this situation better.  If the patch does not apply,
      it rewrites the second patch like this and retries:
      
          diff a/hello.txt b/hello.txt
          --- a/hello.txt
          +++ b/hello.txt
          @@ -18,5 +18,5 @@
           Greetings$
      
          -Hello world.$
          +Hello, everybody.$
           How are you$
          -today?$
          +these days?$
      
      This is done by rewriting the preimage lines in the hunk
      (i.e. the lines that begin with ' ' or '-'), using the same
      whitespace fixing rules as it is using to apply the patches, so
      that it can notice what it did to the previous ones in the
      series.
      
      A careful reader may notice that the first patch in the example
      did not touch the "Greetings" line, so the trailing whitespace
      that is in the original preimage of the second patch is not from
      the series.  Is rewriting this context line a problem?
      
      If you think about it, you will realize that the reason for the
      difference is because the submitter's tree was based on an
      earlier version of the file that had whitespaces wrong on that
      "Greetings" line, and the change that introduced the "Greetings"
      line was added independently of this two-patch series to our
      tree already with an earlier "git apply --whitespace=fix".
      
      So it may appear this logic is rewriting too much, it is not
      so.  It is just rewriting what we would have rewritten in the
      past.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      c1beba5b