1. 28 12月, 2008 3 次提交
  2. 22 10月, 2008 1 次提交
    • A
      builtin-blame: Reencode commit messages according to git-log rules. · 69cd8f63
      Alexander Gavrilov 提交于
      Currently git-blame outputs text from the commit messages
      (e.g. the author name and the summary string) as-is, without
      even providing any information about the encoding used for
      the data. It makes interpreting the data in multilingual
      environment very difficult.
      
      This commit changes the blame implementation to recode the
      messages using the rules used by other commands like git-log.
      Namely, the target encoding can be specified through the
      i18n.commitEncoding or i18n.logOutputEncoding options, or
      directly on the command line using the --encoding parameter.
      
      Converting the encoding before output seems to be more
      friendly to the porcelain tools than simply providing the
      value of the encoding header, and does not require changing
      the output format.
      
      If anybody needs the old behavior, it is possible to
      achieve it by specifying --encoding=none.
      Signed-off-by: NAlexander Gavrilov <angavrilov@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      69cd8f63
  3. 13 10月, 2008 1 次提交
  4. 05 9月, 2008 1 次提交
  5. 29 8月, 2008 1 次提交
  6. 22 7月, 2008 1 次提交
    • J
      Rename path_list to string_list · c455c87c
      Johannes Schindelin 提交于
      The name path_list was correct for the first usage of that data structure,
      but it really is a general-purpose string list.
      
      $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list)
      $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list)
      $ git mv path-list.h string-list.h
      $ git mv path-list.c string-list.c
      $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path)
      $ perl -i -pe 's/path/string/g' string-list.[ch]
      $ git mv Documentation/technical/api-path-list.txt \
      	Documentation/technical/api-string-list.txt
      $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths)
      
      ... and then fix all users of string-list to access the member "string"
      instead of "path".
      
      Documentation/technical/api-string-list.txt needed some rewrapping, too.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c455c87c
  7. 12 7月, 2008 1 次提交
  8. 26 5月, 2008 1 次提交
  9. 10 4月, 2008 1 次提交
    • J
      log: teach "terminator" vs "separator" mode to "--pretty=format" · 4da45bef
      Junio C Hamano 提交于
      This attached patch introduces a single bit "use_terminator" in "struct
      rev_info", which is normally false (i.e. most formats use separator
      semantics) but by flipping it to true, you can ask for terminator
      semantics just like oneline format does.
      
      The function get_commit_format(), which is what parses "--pretty=" option,
      now takes a pointer to "struct rev_info" and updates its commit_format and
      use_terminator fields.  It used to return the value of type "enum
      cmit_fmt", but all the callers assigned it to rev->commit_format.
      
      There are only two cases the code turns use_terminator on.  Obviously, the
      traditional oneline format (--pretty=oneline) is one of them, and the new
      case is --pretty=tformat:... that acts like --pretty=format:... but flips
      the bit on.
      
      With this, "--pretty=tformat:%H %s" acts like --pretty=oneline.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4da45bef
  10. 23 3月, 2008 1 次提交
  11. 15 3月, 2008 1 次提交
    • J
      format-patch: generate MIME header as needed even when there is format.header · 6bf4f1b4
      Junio C Hamano 提交于
      Earlier, the callchain from pretty_print_commit() down to pp_title_line()
      had an unwarranted assumption that the presense of "after_subject"
      parameter, means the caller has already output MIME headers for
      attachments.  The parameter's primary purpose is to give extra header
      lines the caller wants to place after pp_title_line() generates the
      "Subject: " line.
      
      This assumption does not hold when the user used the format.header
      configuration variable to pass extra headers, and caused a message with
      non-ASCII character to lack proper MIME headers (e.g.  8-bit CTE header).
      The earlier logic also failed to suppress duplicated MIME headers when
      "format-patch -s --attach" is asked for and the signer's name demanded
      8-bit clean transport.
      
      This patch fixes the logic by introducing a separate need_8bit_cte
      parameter passed down the callchain.  This can have one of these values:
      
       -1 : we've already done MIME crap and we do not want to add extra header
            to say this is 8bit in pp_title_line();
      
        0 : we haven't done MIME and we have not seen anything that is 8bit yet;
      
        1 : we haven't done MIME and we have seen something that is 8bit;
            pp_title_line() must add MIME header.
      
      It adds two tests by Jeff King who independently diagnosed this issue.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6bf4f1b4
  12. 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
  13. 19 2月, 2008 1 次提交
  14. 10 2月, 2008 1 次提交
  15. 07 1月, 2008 1 次提交
  16. 27 12月, 2007 1 次提交
  17. 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
  18. 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
  19. 06 11月, 2007 1 次提交
  20. 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
  21. 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
  22. 16 10月, 2007 1 次提交
  23. 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
  24. 26 9月, 2007 1 次提交
  25. 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
  26. 19 9月, 2007 1 次提交
  27. 17 9月, 2007 2 次提交
  28. 11 9月, 2007 2 次提交
  29. 04 9月, 2007 1 次提交
  30. 22 7月, 2007 1 次提交
  31. 14 7月, 2007 2 次提交
  32. 17 6月, 2007 1 次提交
  33. 13 6月, 2007 2 次提交
    • 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