1. 21 9月, 2016 1 次提交
  2. 16 9月, 2016 1 次提交
    • J
      format-patch: show base info before email signature · 480871e0
      Josh Triplett 提交于
      Any text below the "-- " for the email signature gets treated as part of
      the signature, and many mail clients will trim it from the quoted text
      for a reply.  Move it above the signature, so people can reply to it
      more easily.
      
      Similarly, when producing the patch as a MIME attachment, the
      original code placed the base info after the attached part, which
      would be discarded.  Move the base info to the end of the part,
      still inside the part boundary.
      
      Add tests for the exact format of the email signature, and add tests
      to ensure that the base info appears before the email signature when
      producing a plain-text output, and that it appears before the part
      boundary when producing a MIME attachment.
      Signed-off-by: NJosh Triplett <josh@joshtriplett.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      480871e0
  3. 08 9月, 2016 3 次提交
  4. 24 8月, 2016 1 次提交
  5. 12 8月, 2016 1 次提交
    • K
      rebase: avoid computing unnecessary patch IDs · b3dfeebb
      Kevin Willford 提交于
      The `rebase` family of Git commands avoid applying patches that were
      already integrated upstream. They do that by using the revision walking
      option that computes the patch IDs of the two sides of the rebase
      (local-only patches vs upstream-only ones) and skipping those local
      patches whose patch ID matches one of the upstream ones.
      
      In many cases, this causes unnecessary churn, as already the set of
      paths touched by a given commit would suffice to determine that an
      upstream patch has no local equivalent.
      
      This hurts performance in particular when there are a lot of upstream
      patches, and/or large ones.
      
      Therefore, let's introduce the concept of a "diff-header-only" patch ID,
      compare those first, and only evaluate the "full" patch ID lazily.
      
      Please note that in contrast to the "full" patch IDs, those
      "diff-header-only" patch IDs are prone to collide with one another, as
      adjacent commits frequently touch the very same files. Hence we now
      have to be careful to allow multiple hash entries with the same hash.
      We accomplish that by using the hashmap_add() function that does not even
      test for hash collisions.  This also allows us to evaluate the full patch ID
      lazily, i.e. only when we found commits with matching diff-header-only
      patch IDs.
      
      We add a performance test that demonstrates ~1-6% improvement.  In
      practice this will depend on various factors such as how many upstream
      changes and how big those changes are along with whether file system
      caches are cold or warm.  As Git's test suite has no way of catching
      performance regressions, we also add a regression test that verifies
      that the full patch ID computation is skipped when the diff-header-only
      computation suffices.
      Signed-off-by: NKevin Willford <kcwillford@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3dfeebb
  6. 02 8月, 2016 1 次提交
  7. 25 6月, 2016 5 次提交
    • J
      format-patch: use stdout directly · 36a4d905
      Johannes Schindelin 提交于
      Earlier, we freopen()ed stdout in order to write patches to files.
      That forced us to duplicate stdout (naming it "realstdout") because we
      *still* wanted to be able to report the file names.
      
      As we do not abuse stdout that way anymore, we no longer need to
      duplicate stdout, either.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      36a4d905
    • J
      format-patch: avoid freopen() · 95235f5b
      Johannes Schindelin 提交于
      We just taught the relevant functions to respect the diffopt.file field,
      to allow writing somewhere else than stdout. Let's make use of it.
      
      Technically, we do not need to avoid that call in a builtin: we assume
      that builtins (as opposed to library functions) are stand-alone programs
      that may do with their (global) state. Yet, we want to be able to reuse
      that code in properly lib-ified code, e.g. when converting scripts into
      builtins.
      
      Further, while we did not *have* to touch the cmd_show() and cmd_cherry()
      code paths (because they do not want to write anywhere but stdout as of
      yet), it just makes sense to be consistent, making it easier and safer to
      move the code later.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      95235f5b
    • J
      format-patch: explicitly switch off color when writing to files · 11f4eb19
      Johannes Schindelin 提交于
      The --color=auto handling is done by seeing if file descriptor 1
      (the standard output) is connected to a terminal.  format-patch
      used freopen() to reuse the standard output stream even when sending
      its output to an on-disk file, and this check is appropriate.
      
      In the next step, however, we will stop reusing "FILE *stdout", and
      instead start using arbitrary file descriptor obtained by doing an
      fopen(3) ourselves.  The check --color=auto does will become useless,
      as we no longer are writing to the standard output stream.
      
      But then, we do not need to guess to begin with. As argued in the commit
      message of 7787570c (format-patch: ignore ui.color, 2011-09-13), we do not
      allow the ui.color setting to affect format-patch's output. The only time,
      therefore, that we allow color sequences to be written to the output files
      is when the user specified the --color=always command-line option explicitly.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      11f4eb19
    • J
      log: prepare log/log-tree to reuse the diffopt.close_file attribute · 6ea57703
      Johannes Schindelin 提交于
      We are about to teach the log-tree machinery to reuse the diffopt.file
      field to output to a file stream other than stdout, in line with the
      diff machinery already writing to diffopt.file.
      
      However, we might want to write something after the diff in
      log_tree_commit() (e.g. with the --show-linear-break option), therefore
      we must not let the diff machinery close the file (as per
      diffopt.close_file.
      
      This means that log_tree_commit() itself must override the
      diffopt.close_file flag and close the file, and if log_tree_commit() is
      called in a loop, the caller is responsible to do the same.
      
      Note: format-patch has an `--output-directory` option. Due to the fact
      that format-patch's options are parsed first, and that the parse-options
      machinery accepts uniquely abbreviated options, the diff options
      `--output` (and `-o`) are shadowed. Therefore close_file is not set to 1
      so that cmd_format_patch() does *not* need to handle the close_file flag
      differently, even if it calls log_tree_commit() in a loop.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6ea57703
    • M
      log: add log.showSignature configuration variable · fce04c3c
      Mehul Jain 提交于
      Users may want to always use "--show-signature" while using git-log and
      related commands.
      
      When log.showSignature is set to true, git-log and related commands will
      behave as if "--show-signature" was given to them.
      
      Note that this config variable is meant to affect git-log, git-show,
      git-whatchanged and git-reflog. Other commands like git-format-patch,
      git-rev-list are not to be affected by this config variable.
      Signed-off-by: NMehul Jain <mehul.jain2029@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fce04c3c
  8. 14 6月, 2016 1 次提交
    • J
      use string_list initializer consistently · 2721ce21
      Jeff King 提交于
      There are two types of string_lists: those that own the
      string memory, and those that don't. You can tell the
      difference by the strdup_strings flag, and one should use
      either STRING_LIST_INIT_DUP, or STRING_LIST_INIT_NODUP as an
      initializer.
      
      Historically, the normal all-zeros initialization has
      corresponded to the NODUP case. Many sites use no
      initializer at all, and that works as a shorthand for that
      case. But for a reader of the code, it can be hard to
      remember which is which. Let's be more explicit and actually
      have each site declare which type it means to use.
      
      This is a fairly mechanical conversion; I assumed each site
      was correct as-is, and just switched them all to NODUP.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2721ce21
  9. 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
  10. 27 4月, 2016 3 次提交
    • X
      format-patch: introduce format.useAutoBase configuration · bb52995f
      Xiaolong Ye 提交于
      This allows to record the base commit automatically, it is equivalent
      to set --base=auto in cmdline.
      
      The format.useAutoBase has lower priority than command line option,
      so if user set format.useAutoBase and pass the command line option in
      the meantime, base_commit will be the one passed to command line
      option.
      Signed-off-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bb52995f
    • X
      format-patch: introduce --base=auto option · 3de66517
      Xiaolong Ye 提交于
      Introduce --base=auto to record the base commit info automatically, the
      base_commit will be the merge base of tip commit of the upstream branch
      and revision-range specified in cmdline.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Helped-by: NWu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3de66517
    • X
      format-patch: add '--base' option to record base tree info · fa2ab86d
      Xiaolong Ye 提交于
      Maintainers or third party testers may want to know the exact base tree
      the patch series applies to. Teach git format-patch a '--base' option
      to record the base tree info and append it at the end of the first
      message (either the cover letter or the first patch in the series).
      
      The base tree info consists of the "base commit", which is a well-known
      commit that is part of the stable part of the project history everybody
      else works off of, and zero or more "prerequisite patches", which are
      well-known patches in flight that is not yet part of the "base commit"
      that need to be applied on top of "base commit" in topological order
      before the patches can be applied.
      
      The "base commit" is shown as "base-commit: " followed by the 40-hex of
      the commit object name.  A "prerequisite patch" is shown as
      "prerequisite-patch-id: " followed by the 40-hex "patch id", which can
      be obtained by passing the patch through the "git patch-id --stable"
      command.
      
      Imagine that on top of the public commit P, you applied well-known
      patches X, Y and Z from somebody else, and then built your three-patch
      series A, B, C, the history would be like:
      
      ---P---X---Y---Z---A---B---C
      
      With "git format-patch --base=P -3 C" (or variants thereof, e.g. with
      "--cover-letter" of using "Z..C" instead of "-3 C" to specify the
      range), the base tree information block is shown at the end of the
      first message the command outputs (either the first patch, or the
      cover letter), like this:
      
      base-commit: P
      prerequisite-patch-id: X
      prerequisite-patch-id: Y
      prerequisite-patch-id: Z
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Helped-by: NWu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa2ab86d
  11. 31 3月, 2016 1 次提交
    • 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
  12. 26 2月, 2016 2 次提交
  13. 14 1月, 2016 1 次提交
  14. 16 12月, 2015 1 次提交
  15. 20 11月, 2015 3 次提交
  16. 06 10月, 2015 1 次提交
    • J
      use strbuf_complete to conditionally append slash · 00b6c178
      Jeff King 提交于
      When working with paths in strbufs, we frequently want to
      ensure that a directory contains a trailing slash before
      appending to it. We can shorten this code (and make the
      intent more obvious) by calling strbuf_complete.
      
      Most of these cases are trivially identical conversions, but
      there are two things to note:
      
        - in a few cases we did not check that the strbuf is
          non-empty (which would lead to an out-of-bounds memory
          access). These were generally not triggerable in
          practice, either from earlier assertions, or typically
          because we would have just fed the strbuf to opendir(),
          which would choke on an empty path.
      
        - in a few cases we indexed the buffer with "original_len"
          or similar, rather than the current sb->len, and it is
          not immediately obvious from the diff that they are the
          same. In all of these cases, I manually verified that
          the strbuf does not change between the assignment and
          the strbuf_complete call.
      
      This does not convert cases which look like:
      
        if (sb->len && !is_dir_sep(sb->buf[sb->len - 1]))
      	  strbuf_addch(sb, '/');
      
      as those are obviously semantically different. Some of these
      cases arguably should be doing that, but that is out of
      scope for this change, which aims purely for cleanup with no
      behavior change (and at least it will make such sites easier
      to find and examine in the future, as we can grep for
      strbuf_complete).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      00b6c178
  17. 26 8月, 2015 1 次提交
  18. 21 8月, 2015 3 次提交
    • J
      log: show merge commit when --cc is given · 82dee416
      Junio C Hamano 提交于
      We defaulted to ignoring merge diffs because long long ago, in a
      galaxy far away, we didn't have a great way to show the diffs.  The
      whole "--cc" option goes back to January '06 and commit d8f4790e
      ("diff-tree --cc: denser combined diff output for a merge commit").
      And before that option - so for about 8 months - we had no good way
      to show the diffs of merges in a good dense way.  So the whole
      "don't show diffs for merges by default" actually made a lot of
      sense originally, because our merge diffs were not very useful.
      
      And this was carried forward to this day.  "git log --cc" still
      ignores merge commits, and you need to say "git log -m --cc" to view
      a sensible rendition of merge and non-merge commits, even with the
      previous change to make "--cc" imply "-p".
      
      Teach "git log" that "--cc" means the user wants to see interesting
      changes in merge commits by turning "-m" on.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      82dee416
    • J
      log: when --cc is given, default to -p unless told otherwise · c7eaf8b4
      Junio C Hamano 提交于
      The "--cc" option to "git log" is clearly a request to show some
      sort of combined diff (be it --patch or --raw), but traditionally
      we required the command line to explicitly ask for "git log -p --cc".
      
      Teach the command line parser to treat a lone "--cc" as if the user
      specified "-p --cc".  Formats that do ask for other forms of diff
      output, e.g. "log --raw --cc", are not overriden.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7eaf8b4
    • J
      log: rename "tweak" helpers · b130c706
      Junio C Hamano 提交于
      The revision walking API allows the callers to tweak its
      configuration at the last minute, immediately after all the revision
      and pathspec parameters are parsed from the command line but before
      the default actions are decided based on them, by defining a "tweak"
      callback function when calling setup_revisions().  Traditionally,
      this facility was used by "git show" to turn on the patch output
      "-p" by default when no diff output option (e.g.  "--raw" or "-s" to
      squelch the output altogether) is given on the command line, and
      further give dense combined diffs "--cc" for merge commits when no
      option to countermand it (e.g. "-m" to show pairwise patches).
      
      Recently, "git log" started using the same facility, but we named
      the callback function "default_follow_tweak()", as if the only kind
      of tweaking we would want for "git log" will forever be limited to
      turning "--follow" on by default when told by a configuration
      variable.  That was myopic.
      
      Rename it to more generic name "log_setup_revisions_tweak()", and
      match the one used by show "show_setup_revisions_tweak()".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b130c706
  19. 10 7月, 2015 1 次提交
  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 6月, 2015 1 次提交
  22. 02 6月, 2015 1 次提交
  23. 22 5月, 2015 2 次提交
    • J
      remote.c: report specific errors from branch_get_upstream · 3a429d0a
      Jeff King 提交于
      When the previous commit introduced the branch_get_upstream
      helper, there was one call-site that could not be converted:
      the one in sha1_name.c, which gives detailed error messages
      for each possible failure.
      
      Let's teach the helper to optionally report these specific
      errors. This lets us convert another callsite, and means we
      can use the helper in other locations that want to give the
      same error messages.
      
      The logic and error messages come straight from sha1_name.c,
      with the exception that we start each error with a lowercase
      letter, as is our usual style (note that a few tests need
      updated as a result).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3a429d0a
    • J
      remote.c: introduce branch_get_upstream helper · a9f9f8cc
      Jeff King 提交于
      All of the information needed to find the @{upstream} of a
      branch is included in the branch struct, but callers have to
      navigate a series of possible-NULL values to get there.
      Let's wrap that logic up in an easy-to-read helper.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a9f9f8cc
  24. 04 5月, 2015 1 次提交
  25. 15 1月, 2015 1 次提交
  26. 08 1月, 2015 1 次提交