1. 23 2月, 2008 1 次提交
    • J
      Avoid unnecessary "if-before-free" tests. · 8e0f7003
      Jim Meyering 提交于
      This change removes all obvious useless if-before-free tests.
      E.g., it replaces code like this:
      
              if (some_expression)
                      free (some_expression);
      
      with the now-equivalent:
      
              free (some_expression);
      
      It is equivalent not just because POSIX has required free(NULL)
      to work for a long time, but simply because it has worked for
      so long that no reasonable porting target fails the test.
      Here's some evidence from nearly 1.5 years ago:
      
          http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html
      
      FYI, the change below was prepared by running the following:
      
        git ls-files -z | xargs -0 \
        perl -0x3b -pi -e \
          's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s'
      
      Note however, that it doesn't handle brace-enclosed blocks like
      "if (x) { free (x); }".  But that's ok, since there were none like
      that in git sources.
      
      Beware: if you do use the above snippet, note that it can
      produce syntactically invalid C code.  That happens when the
      affected "if"-statement has a matching "else".
      E.g., it would transform this
      
        if (x)
          free (x);
        else
          foo ();
      
      into this:
      
        free (x);
        else
          foo ();
      
      There were none of those here, either.
      
      If you're interested in automating detection of the useless
      tests, you might like the useless-if-before-free script in gnulib:
      [it *does* detect brace-enclosed free statements, and has a --name=S
       option to make it detect free-like functions with different names]
      
        http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free
      
      Addendum:
        Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>.
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8e0f7003
  2. 10 2月, 2008 1 次提交
  3. 07 1月, 2008 1 次提交
  4. 27 12月, 2007 1 次提交
  5. 11 11月, 2007 2 次提交
    • R
      --format=pretty: avoid calculating expensive expansions twice · b9c62321
      René Scharfe 提交于
      As Jeff King remarked, format strings with duplicate placeholders can
      be slow to expand, because each instance is calculated anew.
      
      This patch makes use of the fact that format_commit_message() and its
      helper functions only ever add stuff to the end of the strbuf.  For
      certain expensive placeholders, store the offset and length of their
      expansion with the strbuf at the first occurrence.  Later they
      expansion result can simply be copied from there -- no malloc() or
      strdup() required.
      
      These certain placeholders are the abbreviated commit, tree and
      parent hashes, as the search for a unique abbreviated hash is quite
      costly.  Here are the times for next (best of three runs):
      
      $ time git log --pretty=format:%h >/dev/null
      
      real    0m0.611s
      user    0m0.404s
      sys     0m0.204s
      
      $ time git log --pretty=format:%h%h%h%h >/dev/null
      
      real    0m1.206s
      user    0m0.744s
      sys     0m0.452s
      
      And here those with this patch (and the previous two); the speedup
      of the single placeholder case is just noise:
      
      $ time git log --pretty=format:%h >/dev/null
      
      real    0m0.608s
      user    0m0.416s
      sys     0m0.192s
      
      $ time git log --pretty=format:%h%h%h%h >/dev/null
      
      real    0m0.639s
      user    0m0.488s
      sys     0m0.140s
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b9c62321
    • R
      --pretty=format: parse commit message only once · f29d5958
      René Scharfe 提交于
      As Jeff King pointed out, some placeholder expansions are related to
      each other: the steps to calculate one go most of the way towards
      calculating the other, too.
      
      This patch makes format_commit_message() parse the commit message
      only once, remembering the position of each item.  This speeds up
      handling of format strings containing multiple placeholders from the
      set %s, %a*, %c*, %e, %b.
      
      Here are the timings for the git version in next.  The first one is
      to estimate the overhead of the caching, the second one is taken
      from http://svn.tue.mpg.de/tentakel/trunk/tentakel/Makefile as an
      example of a format string found in the wild.  The times are the
      fastest of three consecutive runs in each case:
      
      $ time git log --pretty=format:%e >/dev/null
      
      real    0m0.381s
      user    0m0.340s
      sys     0m0.024s
      
      $ time git log --pretty=format:"* %cd %cn%n%n%s%n%b" >/dev/null
      
      real    0m0.623s
      user    0m0.556s
      sys     0m0.052s
      
      And here the times with this patch:
      
      $ time git log --pretty=format:%e >/dev/null
      
      real    0m0.385s
      user    0m0.332s
      sys     0m0.040s
      
      $ time git log --pretty=format:"* %cd %cn%n%n%s%n%b" >/dev/null
      
      real    0m0.563s
      user    0m0.504s
      sys     0m0.048s
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f29d5958
  6. 09 11月, 2007 1 次提交
    • R
      --pretty=format: on-demand format expansion · cde75e59
      René Scharfe 提交于
      Some of the --pretty=format placeholders expansions are expensive to
      calculate.  This is made worse by the current code's use of
      interpolate(), which requires _all_ placeholders are to be prepared
      up front.
      
      One way to speed this up is to check which placeholders are present
      in the format string and to prepare only the expansions that are
      needed.  That still leaves the allocation overhead of interpolate().
      
      Another way is to use a callback based approach together with the
      strbuf library to keep allocations to a minimum and avoid string
      copies.  That's what this patch does.  It introduces a new strbuf
      function, strbuf_expand().
      
      The function takes a format string, list of placeholder strings,
      a user supplied function 'fn', and an opaque pointer 'context'
      to tell 'fn' what thingy to operate on.
      
      The function 'fn' is expected to accept a strbuf, a parsed
      placeholder string and the 'context' pointer, and append the
      interpolated value for the 'context' thingy, according to the
      format specified by the placeholder.
      
      Thanks to Pierre Habouzit for his suggestion to use strchrnul() and
      the code surrounding its callsite.  And thanks to Junio for most of
      this commit message. :)
      
      Here my measurements of most of Paul Mackerras' test cases that
      highlighted the performance problem (best of three runs):
      
      (master)
      $ time git log --pretty=oneline >/dev/null
      
      real    0m0.390s
      user    0m0.340s
      sys     0m0.040s
      
      (master)
      $ time git log --pretty=raw >/dev/null
      
      real    0m0.434s
      user    0m0.408s
      sys     0m0.016s
      
      (master)
      $ time git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m1.347s
      user    0m0.080s
      sys     0m1.256s
      
      (interp_find_active -- Dscho)
      $ time ./git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m0.694s
      user    0m0.020s
      sys     0m0.672s
      
      (strbuf_expand -- this patch)
      $ time ./git log --pretty="format:%H {%P} %ct" >/dev/null
      
      real    0m0.395s
      user    0m0.352s
      sys     0m0.028s
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cde75e59
  7. 06 11月, 2007 1 次提交
  8. 04 11月, 2007 1 次提交
    • L
      Simplify topo-sort logic · 23c17d4a
      Linus Torvalds 提交于
      .. by not using quite so much indirection.
      
      This currently grows the "struct commit" a bit, which could be avoided by
      using a union for "util" and "indegree" (the topo-sort used to use "util"
      anyway, so you cannot use them together), but for now the goal of this was
      to simplify, not optimize.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      23c17d4a
  9. 02 11月, 2007 1 次提交
    • J
      format-patch -s: add MIME encoding header if signer's name requires so · 4593fb84
      Junio C Hamano 提交于
      When the body of the commit log message contains a non-ASCII character,
      format-patch correctly emitted the encoding header to mark the resulting
      message as such.  However, if the original message was fully ASCII, the
      command line switch "-s" was given to add a new sign-off, and
      the signer's name was not ASCII only, the resulting message would have
      contained non-ASCII character but was not marked as such.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4593fb84
  10. 16 10月, 2007 1 次提交
  11. 29 9月, 2007 1 次提交
    • P
      strbuf change: be sure ->buf is never ever NULL. · b315c5c0
      Pierre Habouzit 提交于
      For that purpose, the ->buf is always initialized with a char * buf living
      in the strbuf module. It is made a char * so that we can sloppily accept
      things that perform: sb->buf[0] = '\0', and because you can't pass "" as an
      initializer for ->buf without making gcc unhappy for very good reasons.
      
      strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf
      anymore.
      
      as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
      ->buf isn't an option anymore, if ->buf is going to escape from the scope,
      and eventually be free'd.
      
      API changes:
        * strbuf_setlen now always works, so just make strbuf_reset a convenience
          macro.
        * strbuf_detatch takes a size_t* optional argument (meaning it can be
          NULL) to copy the buffer's len, as it was needed for this refactor to
          make the code more readable, and working like the callers.
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b315c5c0
  12. 26 9月, 2007 1 次提交
  13. 21 9月, 2007 1 次提交
    • P
      strbuf API additions and enhancements. · c76689df
      Pierre Habouzit 提交于
      Add strbuf_remove, change strbuf_insert:
        As both are special cases of strbuf_splice, implement them as such.
        gcc is able to do the math and generate almost optimal code this way.
      
      Add strbuf_swap:
        Exchange the values of its arguments.
        Use it in fast-import.c
      
      Also fix spacing issues in strbuf.h
      Signed-off-by: NPierre Habouzit <madcoder@debian.org>
      c76689df
  14. 19 9月, 2007 1 次提交
  15. 17 9月, 2007 2 次提交
  16. 11 9月, 2007 2 次提交
  17. 04 9月, 2007 1 次提交
  18. 22 7月, 2007 1 次提交
  19. 14 7月, 2007 2 次提交
  20. 17 6月, 2007 1 次提交
  21. 13 6月, 2007 3 次提交
    • J
      More static · 4175e9e3
      Junio C Hamano 提交于
      There still are quite a few symbols that ought to be static.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4175e9e3
    • J
      Extend --pretty=oneline to cover the first paragraph, · 4234a761
      Junio C Hamano 提交于
      so that an ugly commit message like this can be
      handled sanely.
      
      Currently, --pretty=oneline and --pretty=email (hence
      format-patch) take and use only the first line of the commit log
      message.  This changes them to:
      
       - Take the first paragraph, where the definition of the first
         paragraph is "skip all blank lines from the beginning, and
         then grab everything up to the next empty line".
      
       - Replace all line breaks with a whitespace.
      
      This change would not affect a well-behaved commit message that
      adheres to the convention of "single line summary, a blank line,
      and then body of message", as its first paragraph always
      consists of a single line.  Commit messages from different
      culture, such as the ones imported from CVS/SVN, can however get
      chomped with the existing behaviour at the first linebreak in
      the middle of sentence right now, which would become much easier
      to see with this change.
      
      The Subject: and --pretty=oneline output would become very long
      and unsightly for non-conforming commits, but their messages are
      already ugly anyway, and thischange at least avoids the loss of
      information.
      
      The Subject: line from a multi-line paragraph is folded using
      RFC2822 line folding rules at the places where line breaks were
      in the original.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4234a761
    • J
      Lift 16kB limit of log message output · 80583c0e
      Junio C Hamano 提交于
      Traditionally we had 16kB limit when formatting log messages for
      output, because it was easier to arrange for the caller to have
      a reasonably big buffer and pass it down without ever worrying
      about reallocating.
      
      This changes the calling convention of pretty_print_commit() to
      lift this limit.  Instead of the buffer and remaining length, it
      now takes a pointer to the pointer that points at the allocated
      buffer, and another pointer to the location that stores the
      allocated length, and reallocates the buffer as necessary.
      
      To support the user format, the error return of interpolate()
      needed to be changed.  It used to return a bool telling "Ok the
      result fits", or "Sorry, I had to truncate it".  Now it returns
      0 on success, and returns the size of the buffer it wants in
      order to fit the whole result.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80583c0e
  22. 08 6月, 2007 1 次提交
  23. 07 6月, 2007 1 次提交
    • J
      War on whitespace · a6080a0a
      Junio C Hamano 提交于
      This uses "git-apply --whitespace=strip" to fix whitespace errors that have
      crept in to our source files over time.  There are a few files that need
      to have trailing whitespaces (most notably, test vectors).  The results
      still passes the test, and build result in Documentation/ area is unchanged.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6080a0a
  24. 03 6月, 2007 1 次提交
  25. 17 5月, 2007 1 次提交
  26. 06 5月, 2007 1 次提交
  27. 04 5月, 2007 1 次提交
  28. 26 4月, 2007 1 次提交
    • J
      Add --date={local,relative,default} · a7b02ccf
      Junio C Hamano 提交于
      This adds --date={local,relative,default} option to log family of commands,
      to allow displaying timestamps in user's local timezone, relative time, or
      the default format.
      
      Existing --relative-date option is a synonym of --date=relative; we could
      probably deprecate it in the long run.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a7b02ccf
  29. 17 4月, 2007 1 次提交
  30. 12 4月, 2007 1 次提交
  31. 29 3月, 2007 3 次提交
  32. 28 3月, 2007 1 次提交