1. 14 7月, 2017 1 次提交
    • J
      pretty: respect color settings for %C placeholders · 18fb7ffc
      Jeff King 提交于
      The color placeholders have traditionally been
      unconditional, showing colors even when git is not otherwise
      configured to do so. This was not so bad for their original
      use, which was on the command-line (and the user could
      decide at that moment whether to add colors or not). But
      these days we have configured formats via pretty.*, and
      those should operate correctly in multiple contexts.
      
      In 30825178 (log --format: teach %C(auto,black) to respect
      color config, 2012-12-17), we gave an extended placeholder
      that could be used to accomplish this. But it's rather
      clunky to use, because you have to specify it individually
      for each color (and their matching resets) in the format.
      We shied away from just switching the default to auto,
      because it is technically breaking backwards compatibility.
      
      However, there's not really a use case for unconditional
      colors. The most plausible reason you would want them is to
      redirect "git log" output to a file. But there, the right
      answer is --color=always, as it does the right thing both
      with custom user-format colors and git-generated colors.
      
      So let's switch to the more useful default. In the
      off-chance that somebody really does find a use for
      unconditional colors without wanting to enable the rest of
      git's colors, we provide a new %C(always,...) to enable the
      old behavior. And we can remind them of --color=always in
      the documentation.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18fb7ffc
  2. 16 6月, 2017 2 次提交
  3. 08 5月, 2017 1 次提交
    • B
      object: convert parse_object* to take struct object_id · c251c83d
      brian m. carlson 提交于
      Make parse_object, parse_object_or_die, and parse_object_buffer take a
      pointer to struct object_id.  Remove the temporary variables inserted
      earlier, since they are no longer necessary.  Transform all of the
      callers using the following semantic patch:
      
      @@
      expression E1;
      @@
      - parse_object(E1.hash)
      + parse_object(&E1)
      
      @@
      expression E1;
      @@
      - parse_object(E1->hash)
      + parse_object(E1)
      
      @@
      expression E1, E2;
      @@
      - parse_object_or_die(E1.hash, E2)
      + parse_object_or_die(&E1, E2)
      
      @@
      expression E1, E2;
      @@
      - parse_object_or_die(E1->hash, E2)
      + parse_object_or_die(E1, E2)
      
      @@
      expression E1, E2, E3, E4, E5;
      @@
      - parse_object_buffer(E1.hash, E2, E3, E4, E5)
      + parse_object_buffer(&E1, E2, E3, E4, E5)
      
      @@
      expression E1, E2, E3, E4, E5;
      @@
      - parse_object_buffer(E1->hash, E2, E3, E4, E5)
      + parse_object_buffer(E1, E2, E3, E4, E5)
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c251c83d
  4. 27 4月, 2017 1 次提交
    • J
      timestamp_t: a new data type for timestamps · dddbad72
      Johannes Schindelin 提交于
      Git's source code assumes that unsigned long is at least as precise as
      time_t. Which is incorrect, and causes a lot of problems, in particular
      where unsigned long is only 32-bit (notably on Windows, even in 64-bit
      versions).
      
      So let's just use a more appropriate data type instead. In preparation
      for this, we introduce the new `timestamp_t` data type.
      
      By necessity, this is a very, very large patch, as it has to replace all
      timestamps' data type in one go.
      
      As we will use a data type that is not necessarily identical to `time_t`,
      we need to be very careful to use `time_t` whenever we interact with the
      system functions, and `timestamp_t` everywhere else.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dddbad72
  5. 24 4月, 2017 1 次提交
  6. 02 3月, 2017 1 次提交
  7. 12 12月, 2016 1 次提交
    • J
      pretty: add %(trailers) format for displaying trailers of a commit message · d9f31fbf
      Jacob Keller 提交于
      Recent patches have expanded on the trailers.c code and we have the
      builtin commant git-interpret-trailers which can be used to add or
      modify trailer lines. However, there is no easy way to simply display
      the trailers of a commit message.
      
      Add support for %(trailers) format modifier which will use the
      trailer_info_get() calls to read trailers in an identical way as git
      interpret-trailers does. Use a long format option instead of a short
      name so that future work can more easily unify ref-filter and pretty
      formats.
      
      Add documentation and tests for the same.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d9f31fbf
  8. 13 10月, 2016 1 次提交
    • M
      gpg-interface: use more status letters · 661a1806
      Michael J Gruber 提交于
      According to gpg2's doc/DETAILS:
      
          For each signature only one of the codes GOODSIG, BADSIG,
          EXPSIG, EXPKEYSIG, REVKEYSIG or ERRSIG will be emitted.
      
      gpg1 ("classic") behaves the same (although doc/DETAILS differs).
      
      Currently, we parse gpg's status output for GOODSIG, BADSIG and
      trust information and translate that into status codes G, B, U, N
      for the %G?  format specifier.
      
      git-verify-* returns success in the GOODSIG case only. This is
      somewhat in disagreement with gpg, which considers the first 5 of
      the 6 above as VALIDSIG, but we err on the very safe side.
      
      Introduce additional status codes E, X, Y, R for ERRSIG, EXPSIG,
      EXPKEYSIG, and REVKEYSIG so that a user of %G? gets more information
      about the absence of a 'G' on first glance.
      Requested-by: NAlex <agrambot@gmail.com>
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      661a1806
  9. 11 10月, 2016 1 次提交
  10. 30 9月, 2016 1 次提交
  11. 20 9月, 2016 1 次提交
  12. 08 9月, 2016 1 次提交
  13. 07 8月, 2016 1 次提交
  14. 23 6月, 2016 1 次提交
  15. 17 6月, 2016 2 次提交
  16. 07 6月, 2016 1 次提交
    • E
      pretty: support "mboxrd" output format · 9f23e040
      Eric Wong 提交于
      This output format prevents format-patch output from breaking
      readers if somebody copy+pasted an mbox into a commit message.
      
      Unlike the traditional "mboxo" format, "mboxrd" is designed to
      be fully-reversible.  "mboxrd" also gracefully degrades to
      showing extra ">" in existing "mboxo" readers.
      
      This degradation is preferable to breaking message splitting
      completely, a problem I've seen in "mboxcl" due to having
      multiple, non-existent, or inaccurate Content-Length headers.
      
      "mboxcl2" is a non-starter since it's inherits the problems
      of "mboxcl" while being completely incompatible with existing
      tooling based around mailsplit.
      
      ref: http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.htmlSigned-off-by: NEric Wong <e@80x24.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9f23e040
  17. 28 5月, 2016 1 次提交
    • E
      format_commit_message: honor `color=auto` for `%C(auto)` · b15a3e00
      Edward Thomson 提交于
      git-log(1) documents that when specifying the `%C(auto)` format
      placeholder will "turn on auto coloring on the next %placeholders
      until the color is switched again."
      
      However, when `%C(auto)` is used, the present implementation will turn
      colors on unconditionally (even if the color configuration is turned off
      for the current context - for example, `--no-color` was specified or the
      color is `auto` and the output is not a tty).
      
      Update `format_commit_one` to examine the current context when a format
      string of `%C(auto)` is specified, which ensures that we will not
      unconditionally write colors.  This brings that behavior in line with
      the behavior of `%C(auto,<colorname>)`, and allows the user the ability
      to specify that color should be displayed only when the output is a
      tty.
      
      Additionally, add a test for `%C(auto)` and update the existing tests
      for `%C(auto,...)` as they were misidentified as being applicable to
      `%C(auto)`.
      
      Tests from Jeff King.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NEdward Thomson <ethomson@edwardthomson.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b15a3e00
  18. 31 3月, 2016 3 次提交
    • J
      pretty: allow tweaking tabwidth in --expand-tabs · fe37a9c5
      Junio C Hamano 提交于
      When the local convention of the project is to use tab width that is
      not 8, it may make sense to allow "git log --expand-tabs=<n>" to
      tweak the output to match it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fe37a9c5
    • J
      pretty: enable --expand-tabs by default for selected pretty formats · 0893eec8
      Junio C Hamano 提交于
      "git log --pretty={medium,full,fuller}" and "git log" by default
      prepend 4 spaces to the log message, so it makes sense to enable
      the new "expand-tabs" facility by default for these formats.
      Add --no-expand-tabs option to override the new default.
      
      The change alone breaks a test in t4201 that runs "git shortlog"
      on the output from "git log", and expects that the output from
      "git log" does not do such a tab expansion.  Adjust the test to
      explicitly disable expand-tabs with --no-expand-tabs.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0893eec8
    • L
      pretty: expand tabs in indented logs to make things line up properly · 7cc13c71
      Linus Torvalds 提交于
      A commit log message sometimes tries to line things up using tabs,
      assuming fixed-width font with the standard 8-place tab settings.
      Viewing such a commit however does not work well in "git log", as
      we indent the lines by prefixing 4 spaces in front of them.
      
      This should all line up:
      
        Column 1	Column 2
        --------	--------
        A		B
        ABCD		EFGH
        SPACES        Instead of Tabs
      
      Even with multi-byte UTF8 characters:
      
        Column 1	Column 2
        --------	--------
        Ä		B
        åäö		100
        A Møøse	once bit my sister..
      
      Tab-expand the lines in "git log --expand-tabs" output before
      prefixing 4 spaces.
      
      This is based on the patch by Linus Torvalds, but at this step, we
      require an explicit command line option to enable the behaviour.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7cc13c71
  19. 20 11月, 2015 3 次提交
  20. 30 6月, 2015 1 次提交
    • J
      convert "enum date_mode" into a struct · a5481a6c
      Jeff King 提交于
      In preparation for adding date modes that may carry extra
      information beyond the mode itself, this patch converts the
      date_mode enum into a struct.
      
      Most of the conversion is fairly straightforward; we pass
      the struct as a pointer and dereference the type field where
      necessary. Locations that declare a date_mode can use a "{}"
      constructor.  However, the tricky case is where we use the
      enum labels as constants, like:
      
        show_date(t, tz, DATE_NORMAL);
      
      Ideally we could say:
      
        show_date(t, tz, &{ DATE_NORMAL });
      
      but of course C does not allow that. Likewise, we cannot
      cast the constant to a struct, because we need to pass an
      actual address. Our options are basically:
      
        1. Manually add a "struct date_mode d = { DATE_NORMAL }"
           definition to each caller, and pass "&d". This makes
           the callers uglier, because they sometimes do not even
           have their own scope (e.g., they are inside a switch
           statement).
      
        2. Provide a pre-made global "date_normal" struct that can
           be passed by address. We'd also need "date_rfc2822",
           "date_iso8601", and so forth. But at least the ugliness
           is defined in one place.
      
        3. Provide a wrapper that generates the correct struct on
           the fly. The big downside is that we end up pointing to
           a single global, which makes our wrapper non-reentrant.
           But show_date is already not reentrant, so it does not
           matter.
      
      This patch implements 3, along with a minor macro to keep
      the size of the callers sane.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a5481a6c
  21. 23 2月, 2015 1 次提交
  22. 15 10月, 2014 1 次提交
    • J
      color_parse: do not mention variable name in error message · f6c5a296
      Jeff King 提交于
      Originally the color-parsing function was used only for
      config variables. It made sense to pass the variable name so
      that the die() message could be something like:
      
        $ git -c color.branch.plain=bogus branch
        fatal: bad color value 'bogus' for variable 'color.branch.plain'
      
      These days we call it in other contexts, and the resulting
      error messages are a little confusing:
      
        $ git log --pretty='%C(bogus)'
        fatal: bad color value 'bogus' for variable '--pretty format'
      
        $ git config --get-color foo.bar bogus
        fatal: bad color value 'bogus' for variable 'command line'
      
      This patch teaches color_parse to complain only about the
      value, and then return an error code. Config callers can
      then propagate that up to the config parser, which mentions
      the variable name. Other callers can provide a custom
      message. After this patch these three cases now look like:
      
        $ git -c color.branch.plain=bogus branch
        error: invalid color value: bogus
        fatal: unable to parse 'color.branch.plain' from command-line config
      
        $ git log --pretty='%C(bogus)'
        error: invalid color value: bogus
        fatal: unable to parse --pretty format
      
        $ git config --get-color foo.bar bogus
        error: invalid color value: bogus
        fatal: unable to parse default color value
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f6c5a296
  23. 08 10月, 2014 1 次提交
  24. 19 9月, 2014 1 次提交
  25. 09 9月, 2014 1 次提交
  26. 30 8月, 2014 1 次提交
  27. 28 8月, 2014 1 次提交
    • J
      commit: provide a function to find a header in a buffer · fe6eb7f2
      Jeff King 提交于
      Usually when we parse a commit, we read it line by line and
      handle each individual line (e.g., parse_commit and
      parse_commit_header).  Sometimes, however, we only care
      about extracting a single header. Code in this situation is
      stuck doing an ad-hoc parse of the commit buffer.
      
      Let's provide a reusable function to locate a header within
      the commit.  The code is modeled after pretty.c's
      get_header, which is used to extract the encoding.
      
      Since some callers may not have the "struct commit" to go
      along with the buffer, we drop that parameter.  The only
      thing lost is a warning for truncated commits, but that's
      OK.  This shouldn't happen in practice, and even if it does,
      there's no particular reason that this function needs to
      complain about it. It either finds the header it was asked
      for, or it doesn't (and in the latter case, the caller will
      typically complain).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fe6eb7f2
  28. 05 8月, 2014 1 次提交
  29. 31 7月, 2014 2 次提交
    • J
      pretty: make empty userformats truly empty · b9c7d6e4
      Jeff King 提交于
      If the user provides an empty format with "--format=", we
      end up putting in extra whitespace that the user cannot
      prevent. This comes from two places:
      
        1. If the format is missing a terminating newline, we add
           one automatically. This makes sense for --format=%h, but
           not for a truly empty format.
      
        2. We add an extra newline between the pretty-printed
           format and a diff or diffstat. If the format is empty,
           there's no point in doing so if there's nothing to
           separate.
      
      With this patch, one can get a diff with no other cruft out
      of "diff-tree --format= $commit".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b9c7d6e4
    • J
      pretty: treat "--format=" as an empty userformat · c75e7ad2
      Jeff King 提交于
      Until now, we treated "--pretty=" or "--format=" as "give me
      the default format". This was not planned nor documented,
      but only what happened to work due to our parsing of
      "--pretty" (which should give the default format).
      
      Let's instead let these be an actual empty userformat.
      Otherwise one must write out the annoyingly long
      "--pretty=tformat:" to get the same behavior.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c75e7ad2
  30. 18 7月, 2014 1 次提交
  31. 11 7月, 2014 1 次提交
  32. 03 7月, 2014 1 次提交
  33. 24 6月, 2014 1 次提交