1. 05 2月, 2008 15 次提交
    • J
      git-apply --whitespace=fix: fix whitespace fuzz introduced by previous run · c1beba5b
      Junio C Hamano 提交于
      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: NJunio C Hamano <gitster@pobox.com>
      c1beba5b
    • J
      builtin-apply.c: pass ws_rule down to match_fragment() · c607aaa2
      Junio C Hamano 提交于
      This is necessary to allow match_fragment() to attempt a match
      with a preimage that is based on a version before whitespace
      errors were fixed.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c607aaa2
    • J
      builtin-apply.c: move copy_wsfix() function a bit higher. · ee810b71
      Junio C Hamano 提交于
      I'll be calling this from match_fragment() in later rounds.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ee810b71
    • J
      builtin-apply.c: do not feed copy_wsfix() leading '+' · 42ab241c
      Junio C Hamano 提交于
      The "patch" parameter used to include leading '+' of an added
      line in the patch, and the array was treated as 1-based.  Make
      it accept the contents of the line alone and simplify the code.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      42ab241c
    • J
      builtin-apply.c: simplify calling site to apply_line() · 8441a9a8
      Junio C Hamano 提交于
      The function apply_line() changed its behaviour depending on the
      ws_error_action, whitespace_error and if the input was a context.
      Make its caller responsible for such checking so that we can convert
      the function to copy the contents of line while fixing whitespace
      breakage more easily.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8441a9a8
    • J
      builtin-apply.c: clean-up apply_one_fragment() · 61e08cca
      Junio C Hamano 提交于
      We had two pointer variables pointing to the same buffer and an
      integer variable used to index into its tail part that was
      active (old, oldlines and oldsize for the preimage, and their
      'new' counterparts for the postimage).
      
      To help readability, use 'oldlines' as the allocated pointer,
      and use 'old' as the pointer to the tail that advances while the
      code builds up the contents in the buffer.  The size 'oldsize'
      can be computed as (old-oldines).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      61e08cca
    • J
      builtin-apply.c: mark common context lines in lineinfo structure. · c330fdd4
      Junio C Hamano 提交于
      This updates the way preimage and postimage in a patch hunk is
      parsed and prepared for applying.  By looking at image->line[n].flag,
      the code can tell if it is a common context line that is the
      same between the preimage and the postimage.
      
      This matters when we actually start applying a patch with
      contexts that have whitespace breakages that have already been
      fixed in the target file.
      c330fdd4
    • J
      builtin-apply.c: optimize match_beginning/end processing a bit. · ecf4c2ec
      Junio C Hamano 提交于
      Wnen the caller knows the hunk needs to match at the beginning
      or at the end, there is no point starting from the line number
      that is found in the patch and trying match with increasing
      offset.  The logic to find matching lines was made more line
      oriented with the previous patch and this optimization is now
      trivial.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ecf4c2ec
    • J
      builtin-apply.c: make it more line oriented · b94f2eda
      Junio C Hamano 提交于
      This changes the way git-apply internally works to be more line
      oriented.  The logic to find where the patch applies with offset
      used to count line numbers by always counting LF from the
      beginning of the buffer, but it is simplified because we count
      the line length of the target file and the preimage snippet
      upfront now.
      
      The ultimate motivation is to allow applying patches
      whose preimage context has whitespace corruption that has
      already been corrected in the local copy.  For that purpose, we
      introduce a table of line-hash that allows us to match lines
      that differ only in whitespaces.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b94f2eda
    • J
      builtin-apply.c: push match-beginning/end logic down · dc41976a
      Junio C Hamano 提交于
      This moves the logic to force match at the beginning and/or at
      the end of the buffer to the actual function that finds the
      match from its caller.  This is a necessary preparation for the
      next step to allow matching disregarding certain differences,
      such as whitespace changes.
      
      We probably could optimize this even more by taking advantage of
      the fact that match_beginning and match_end forces the match to
      be at an exact location (anchored at the beginning and/or the
      end), but that's for another commit.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dc41976a
    • J
      builtin-apply.c: restructure "offset" matching · fcb77bc5
      Junio C Hamano 提交于
      This restructures code to find matching location with offset
      in find_offset() function, so that there is need for only one
      call site of match_fragment() function.  There still isn't a
      change in the logic of the program.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fcb77bc5
    • J
      builtin-apply.c: refactor small part that matches context · c89fb6b1
      Junio C Hamano 提交于
      This moves three "if" conditions out of line from find_offset()
      function, which is responsible for finding the matching place in
      the preimage to apply the patch.  There is no change in the
      logic of the program.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c89fb6b1
    • J
      man pages are littered with .ft C and others · 7a2078b4
      Jonas Fonseca 提交于
      Jakub Narebski <jnareb@gmail.com> wrote Sun, Feb 03, 2008:
      > Junio C Hamano wrote:
      > > Jakub Narebski <jnareb@gmail.com> writes:
      > >
      > > [From] http://thread.gmane.org/gmane.comp.version-control.git/53457/focus=53458
      > Julian Phillips:
      > > Are you using docbook xsl 1.72?  There are known problems building the
      > > manpages with that version.  1.71 works, and 1.73 should work when it get
      > > released.
      
      I was able to solve this problem with this patch, which adds a XSL file
      used specifically for DOCBOOK_XSL_172=YesPlease and where dots and
      backslashes are escaped properly so they won't be substituted to the
      wrong thing further down the "DocBook XSL pipeline". Doing the escaping
      in the existing callout.xsl breaks v1.70.1. Hopefully v1.73 will end
      this part of the manpage nightmare.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7a2078b4
    • J
      4f395eed
    • D
      Test :/string form for checkout · b1e9efa7
      Daniel Barkalow 提交于
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b1e9efa7
  2. 04 2月, 2008 12 次提交
  3. 03 2月, 2008 5 次提交
  4. 02 2月, 2008 4 次提交
    • J
      Sane use of test_expect_failure · 41ac414e
      Junio C Hamano 提交于
      Originally, test_expect_failure was designed to be the opposite
      of test_expect_success, but this was a bad decision.  Most tests
      run a series of commands that leads to the single command that
      needs to be tested, like this:
      
          test_expect_{success,failure} 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              what is to be tested
          '
      
      And expecting a failure exit from the whole sequence misses the
      point of writing tests.  Your setup$N that are supposed to
      succeed may have failed without even reaching what you are
      trying to test.  The only valid use of test_expect_failure is to
      check a trivial single command that is expected to fail, which
      is a minority in tests of Porcelain-ish commands.
      
      This large-ish patch rewrites all uses of test_expect_failure to
      use test_expect_success and rewrites the condition of what is
      tested, like this:
      
          test_expect_success 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              ! this command should fail
          '
      
      test_expect_failure is redefined to serve as a reminder that
      that test *should* succeed but due to a known breakage in git it
      currently does not pass.  So if git-foo command should create a
      file 'bar' but you discovered a bug that it doesn't, you can
      write a test like this:
      
          test_expect_failure 'git-foo should create bar' '
              rm -f bar &&
              git foo &&
              test -f bar
          '
      
      This construct acts similar to test_expect_success, but instead
      of reporting "ok/FAIL" like test_expect_success does, the
      outcome is reported as "FIXED/still broken".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      41ac414e
    • J
      Update stale documentation links from the main documentation. · 6ce8e44a
      Junio C Hamano 提交于
      This could have been part of the 1.5.4 commit, but it isn't.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6ce8e44a
    • J
      GIT 1.5.4 · c3c13529
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3c13529
    • J
      Fix "git checkout -b foo ':/substring'" · 7dc46429
      Junio C Hamano 提交于
      Because ':/substring' extended SHA1 expression cannot take
      postfix modifiers such as ^{tree} and ^{commit}, we would need
      to do it in multiple steps.  With the patch, you can start a new
      branch from a randomly-picked commit whose message has the named
      string in it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7dc46429
  5. 01 2月, 2008 3 次提交
  6. 31 1月, 2008 1 次提交