1. 24 10月, 2011 2 次提交
  2. 27 5月, 2011 3 次提交
    • J
      format-patch: preserve subject newlines with -k · 9553d2b2
      Jeff King 提交于
      In older versions of git, we used rfc822 header folding to
      indicate that the original subject line had multiple lines
      in it.  But since a1f6baa5 (format-patch: wrap long header
      lines, 2011-02-23), we now use header folding whenever there
      is a long line.
      
      This means that "git am" cannot trust header folding as a
      sign from format-patch that newlines should be preserved.
      Instead, format-patch needs to signal more explicitly that
      the newlines are significant.  This patch does so by
      rfc2047-encoding the newlines in the subject line. No
      changes are needed on the "git am" end; it already decodes
      the newlines properly.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9553d2b2
    • J
      clean up calling conventions for pretty.c functions · 6bf13944
      Jeff King 提交于
      We have a pretty_print_context representing the parameters
      for a pretty-print session, but we did not use it uniformly.
      As a result, functions kept growing more and more arguments.
      
      Let's clean this up in a few ways:
      
        1. All pretty-print pp_* functions now take a context.
           This lets us reduce the number of arguments to these
           functions, since we were just passing around the
           context values separately.
      
        2. The context argument now has a cmit_fmt field, which
           was passed around separately. That's one less argument
           per function.
      
        3. The context argument always comes first, which makes
           calling a little more uniform.
      
      This drops lines from some callers, and adds lines in a few
      places (because we need an extra line to set the context's
      fmt field). Overall, we don't save many lines, but the lines
      that are there are a lot simpler and more readable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6bf13944
    • J
      pretty: add pp_commit_easy function for simple callers · 8b8a5374
      Jeff King 提交于
      Many callers don't actually care about the pretty print
      context at all; let's just give them a simple way of
      pretty-printing a commit without having to create a context
      struct.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8b8a5374
  3. 26 5月, 2011 1 次提交
    • J
      userformat_find_requirements(): find requirement for the correct format · a6253d10
      Junio C Hamano 提交于
      This function was introduced in 5b163603 (pretty: Initialize notes if %N is
      used, 2010-04-13) to check what kind of information the "log --format=..."
      user format string wants. The function can be passed a NULL instead of a
      format string to ask it to check user_format variable kept by an earlier
      call to save_user_format().
      
      But it unconditionally checked user_format and not the string it was
      given.  The only caller introduced by the change passes NULL, which
      kept the bug unnoticed, until a new GCC noticed that there is an
      assignment to fmt that is never used.
      
      Noticed-by: Chris Wilson's compiler
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Acked-by: NJeff King <peff@peff.net>
      a6253d10
  4. 27 4月, 2011 1 次提交
    • J
      pretty: quote rfc822 specials in email addresses · 4d03c18a
      Jeff King 提交于
      If somebody has a name that includes an rfc822 special, we
      will output it literally in the "From:" header. This is
      usually OK, but certain characters (like ".") are supposed
      to be enclosed in double-quotes in a mail header.
      
      In practice, whether this matters may depend on your MUA.
      Some MUAs will happily take in:
      
         From: Foo B. Bar <author@example.com>
      
      without quotes, and properly quote the "." when they send
      the actual mail.  Others may not, or may screw up harder
      things like:
      
        From: Foo "The Baz" Bar <author@example.com>
      
      For example, mutt will strip the quotes, thinking they are
      actual syntactic rfc822 quotes.
      
      So let's quote properly, and then (if necessary) we still
      apply rfc2047 encoding on top of that, which should make all
      MUAs happy.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4d03c18a
  5. 15 4月, 2011 1 次提交
    • J
      format-patch: wrap email addresses after long names · 990f6e30
      Jeff King 提交于
      We already wrap names in "from" headers, which tend to be
      the long part of an address. But it's also possible for a
      long name to not be wrapped, but to make us want to wrap the
      email address. For example (imagine for the sake of
      readability we want to wrap at 50 characters instead of 78):
      
        From: this is my really long git name <foo@example.com>
      
      The name does not overflow the line, but the name and email
      together do. So we would rather see:
      
        From: this is my really long git name
          <git@example.com>
      
      Because we wrap the name separately during add_rfc2047, we
      neglected this case. Instead, we should see how long the
      final line of the wrapped name ended up, and decide whether
      or not to wrap based on that. We can't break the address
      into multiple parts, so we either leave it with the name, or
      put it by itself on a line.
      
      Test by Erik Faye-Lund.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      990f6e30
  6. 10 3月, 2011 1 次提交
  7. 24 2月, 2011 2 次提交
    • J
      format-patch: rfc2047-encode newlines in headers · c22e7de3
      Jeff King 提交于
      These should generally never happen, as we already
      concatenate multiples in subjects into a single line. But
      let's be defensive, since not encoding them means we will
      output malformed headers.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c22e7de3
    • J
      format-patch: wrap long header lines · a1f6baa5
      Jeff King 提交于
      Subject and identity headers may be arbitrarily long. In the
      past, we just assumed that single-line headers would be
      reasonably short. For multi-line subjects that we squish
      into a single line, we just "pre-folded" the data in
      pp_title_line by adding a newline and indentation.
      
      There were two problems. One is that, although rare,
      single-line messages can actually be longer than the
      recommended line-length limits. The second is that the
      pre-folding interacted badly with rfc2047 encoding, leading
      to malformed headers.
      
      Instead, let's stop pre-folding the subject lines, and just
      fold everything based on length in add_rfc2047, whether
      it is encoded or not.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a1f6baa5
  8. 05 11月, 2010 2 次提交
  9. 17 6月, 2010 1 次提交
  10. 01 6月, 2010 1 次提交
    • G
      enums: omit trailing comma for portability · 4b05548f
      Gary V. Vaughan 提交于
      Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX
      5.1 fails to compile git.
      
      enum style is inconsistent already, with some enums declared on one
      line, some over 3 lines with the enum values all on the middle line,
      sometimes with 1 enum value per line... and independently of that the
      trailing comma is sometimes present and other times absent, often
      mixing with/without trailing comma styles in a single file, and
      sometimes in consecutive enum declarations.
      
      Clearly, omitting the comma is the more portable style, and this patch
      changes all enum declarations to use the portable omitted dangling
      comma style consistently.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b05548f
  11. 09 5月, 2010 1 次提交
  12. 05 5月, 2010 1 次提交
  13. 04 5月, 2010 3 次提交
    • W
      pretty: add aliases for pretty formats · 8028184e
      Will Palmer 提交于
      previously the only ways to alias a --pretty format within git were
      either to set the format as your default format (via the format.pretty
      configuration variable), or by using a regular git alias. This left the
      definition of more complicated formats to the realm of "builtin or
      nothing", with user-defined formats usually being reserved for quick
      one-offs.
      
      Here we allow user-defined formats to enjoy more or less the same
      benefits of builtins. By defining pretty.myalias, "myalias" can be
      used in place of whatever would normally come after --pretty=. This
      can be a format:, tformat:, raw (ie, defaulting to tformat), or the name
      of another builtin or user-defined pretty format.
      Signed-off-by: NWill Palmer <wmpalmer@gmail.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8028184e
    • W
      pretty: add infrastructure for commit format aliases · 2d7671ef
      Will Palmer 提交于
      Allow named commit formats to alias one another; find_commit_format() will
      recursively dereference aliases when they are specified.  At this point,
      there are no aliases specified and there is no way to specify an alias,
      but the support is there for any which are added.
      
      If an alias loop is detected, the function die()s.
      Signed-off-by: NWill Palmer <wmpalmer@gmail.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2d7671ef
    • W
      pretty: make it easier to add new formats · 40957891
      Will Palmer 提交于
      As the first step towards creating aliases, we make it easier to add new
      formats to the list of builtin formats. To do this, we move the
      initialization of the formats array into a new function,
      setup_commit_formats(), which we can easily extend later. Then, rather
      than looping through only the list of known formats, we make a more
      generic find_commit_format function, which will return the commit format
      whose name is the shortest which is prefixed with the passed-in sought
      format, the same rules which were more-or-less hard-coded in before.
      Signed-off-by: NWill Palmer <wmpalmer@gmail.com>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      40957891
  14. 14 4月, 2010 1 次提交
  15. 06 4月, 2010 1 次提交
  16. 13 3月, 2010 1 次提交
  17. 14 2月, 2010 2 次提交
  18. 21 1月, 2010 1 次提交
    • J
      Fix "log" family not to be too agressive about showing notes · 66b2ed09
      Junio C Hamano 提交于
      Giving "Notes" information in the default output format of "log" and
      "show" is a sensible progress (the user has asked for it by having the
      notes), but for some commands (e.g. "format-patch") spewing notes into the
      formatted commit log message without being asked is too aggressive.
      
      Enable notes output only for "log", "show", "whatchanged" by default and
      only when the user didn't ask any specific --pretty/--format from the
      command line; users can explicitly override this default with --show-notes
      and --no-notes option.
      
      Parts of tests are taken from Jeff King's fix.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      66b2ed09
  19. 12 1月, 2010 1 次提交
  20. 09 11月, 2009 1 次提交
  21. 23 10月, 2009 1 次提交
  22. 20 10月, 2009 5 次提交
    • T
      Introduce new pretty formats %g[sdD] for reflog information · 8f8f5476
      Thomas Rast 提交于
      Add three new --pretty=format escapes:
      
        %gD  long  reflog descriptor (e.g. refs/stash@{0})
        %gd  short reflog descriptor (e.g. stash@{0})
        %gs  reflog message
      
      This is achieved by passing down the reflog info, if any, inside the
      pretty_print_context struct.
      
      We use the newly refactored get_reflog_selector(), and give it some
      extra functionality to extract a shortened ref.  The shortening is
      cached inside the commit_reflogs struct; the only allocation of it
      happens in read_complete_reflog(), where it is initialised to 0.  Also
      add another helper get_reflog_message() for the message extraction.
      
      Note that the --format="%h %gD: %gs" tests may not work in real
      repositories, as the --pretty formatter doesn't know to leave away the
      ": " on the last commit in an incomplete (because git-gc removed the
      old part) reflog.  This equivalence is nevertheless the main goal of
      this patch.
      
      Thanks to Jeff King for reviews, the %gd testcase and documentation.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8f8f5476
    • T
      Refactor pretty_print_commit arguments into a struct · dd2e794a
      Thomas Rast 提交于
      pretty_print_commit() has a bunch of rarely-used arguments, and
      introducing more of them requires yet another update of all the call
      sites.  Refactor most of them into a struct to make future extensions
      easier.
      
      The ones that stay "plain" arguments were chosen on the grounds that
      all callers put real arguments there, whereas some callers have 0/NULL
      for all arguments that were factored into the struct.
      
      We declare the struct 'const' to ensure none of the callers are bitten
      by the changed (no longer call-by-value) semantics.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd2e794a
    • J
      8b208f02
    • J
      Add flags to get_commit_notes() to control the format of the note string · c56fcc89
      Johan Herland 提交于
      This patch adds the following flags to get_commit_notes() for adjusting the
      format of the produced note string:
      - NOTES_SHOW_HEADER: Print "Notes:" line before the notes contents
      - NOTES_INDENT: Indent notes contents by 4 spaces
      Suggested-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c56fcc89
    • J
      Introduce commit notes · a97a7468
      Johannes Schindelin 提交于
      Commit notes are blobs which are shown together with the commit
      message.  These blobs are taken from the notes ref, which you can
      configure by the config variable core.notesRef, which in turn can
      be overridden by the environment variable GIT_NOTES_REF.
      
      The notes ref is a branch which contains "files" whose names are
      the names of the corresponding commits (i.e. the SHA-1).
      
      The rationale for putting this information into a ref is this: we
      want to be able to fetch and possibly union-merge the notes,
      maybe even look at the date when a note was introduced, and we
      want to store them efficiently together with the other objects.
      
      This patch has been improved by the following contributions:
      - Thomas Rast: fix core.notesRef documentation
      - Tor Arne Vestbø: fix printing of multi-line notes
      - Alex Riesen: Using char array instead of char pointer costs less BSS
      - Johan Herland: Plug leak when msg is good, but msglen or type causes return
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NTor Arne Vestbø <tavestbo@trolltech.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      
      get_commit_notes(): Plug memory leak when 'if' triggers, but not because of read_sha1_file() failure
      a97a7468
  23. 19 10月, 2009 1 次提交
  24. 05 10月, 2009 1 次提交
    • J
      Pretty-format: %[+-]x to tweak inter-item newlines · 9fa708da
      Junio C Hamano 提交于
      This teaches the "pretty" machinery to expand '%+x' to a LF followed by
      the expansion of '%x' if and only if '%x' expands to a non-empty string,
      and to remove LFs before '%-x' if '%x' expands to an empty string.  This
      works for any supported expansion placeholder 'x'.
      
      This is expected to be immediately useful to reproduce the commit log
      message with "%s%+b%n"; "%s%n%b%n" adds one extra LF if the log message is
      a one-liner.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9fa708da
  25. 27 8月, 2009 1 次提交
  26. 19 8月, 2009 1 次提交
  27. 11 8月, 2009 1 次提交
  28. 19 5月, 2009 1 次提交