1. 05 3月, 2015 1 次提交
    • J
      log --decorate: do not leak "commit" color into the next item · 5ee87585
      Junio C Hamano 提交于
      In "git log --decorate", you would see the commit header like this:
      
          commit ... (HEAD, jc/decorate-leaky-separator-color)
      
      where "commit ... (" is painted in color.diff.commit, "HEAD" in
      color.decorate.head, ", " in color.diff.commit, the branch name in
      color.decorate.branch and then closing ")" in color.diff.commit.
      
      If you wanted to paint the HEAD and local branch name in the same
      color as the body text (perhaps because cyan and green are too faint
      on a black-on-white terminal to be readable), you would not want to
      have to say
      
          [color "decorate"]
              head = black
              branch = black
      
      because that you would not be able to reuse same configuration on a
      white-on-black terminal.  You would naively expect
      
          [color "decorate"]
              head = normal
      	branch = normal
      
      to work, but unfortunately it does not.  It paints the string "HEAD"
      and the branch name in the same color as the opening parenthesis or
      comma between the decoration elements.  This is because the code
      forgets to reset the color after printing the "prefix" in its own
      color.
      
      It theoretically is possible that some people were expecting and
      relying on that the attribute set as the "diff.commit" color, which
      is used to draw these opening parenthesis and inter-item comma, is
      inherited by the drawing of branch names, but it is not how the
      coloring works everywhere else.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5ee87585
  2. 21 12月, 2013 1 次提交
    • B
      log: properly handle decorations with chained tags · 5e1361cc
      brian m. carlson 提交于
      git log did not correctly handle decorations when a tag object referenced
      another tag object that was no longer a ref, such as when the second tag was
      deleted.  The commit would not be decorated correctly because parse_object had
      not been called on the second tag and therefore its tagged field had not been
      filled in, resulting in none of the tags being associated with the relevant
      commit.
      
      Call parse_object to fill in this field if it is absent so that the chain of
      tags can be dereferenced and the commit can be properly decorated.  Include
      tests as well to prevent future regressions.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5e1361cc
  3. 02 8月, 2013 1 次提交
    • T
      log: use true parents for diff even when rewriting · 53d00b39
      Thomas Rast 提交于
      When using pathspec filtering in combination with diff-based log
      output, parent simplification happens before the diff is computed.
      The diff is therefore against the *simplified* parents.
      
      This works okay, arguably by accident, in the normal case:
      simplification reduces to one parent as long as the commit is TREESAME
      to it.  So the simplified parent of any given commit must have the
      same tree contents on the filtered paths as its true (unfiltered)
      parent.
      
      However, --full-diff breaks this guarantee, and indeed gives pretty
      spectacular results when comparing the output of
      
        git log --graph --stat ...
        git log --graph --full-diff --stat ...
      
      (--graph internally kicks in parent simplification, much like
      --parents).
      
      To fix it, store a copy of the parent list before simplification (in a
      slab) whenever --full-diff is in effect.  Then use the stored parents
      instead of the simplified ones in the commit display code paths.  The
      latter do not actually check for --full-diff to avoid duplicated code;
      they just grab the original parents if save_parents() has not been
      called for this revision walk.
      
      For ordinary commits it should be obvious that this is the right thing
      to do.
      
      Merge commits are a bit subtle.  Observe that with default
      simplification, merge simplification is an all-or-nothing decision:
      either the merge is TREESAME to one parent and disappears, or it is
      different from all parents and the parent list remains intact.
      Redundant parents are not pruned, so the existing code also shows them
      as a merge.
      
      So if we do show a merge commit, the parent list just consists of the
      rewrite result on each parent.  Running, e.g., --cc on this in
      --full-diff mode is not very useful: if any commits were skipped, some
      hunks will disagree with all sides of the merge (with one side,
      because commits were skipped; with the others, because they didn't
      have those changes in the first place).  This triggers --cc showing
      these hunks spuriously.
      
      Therefore I believe that even for merge commits it is better to show
      the diffs wrt. the original parents.
      Reported-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Helped-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      53d00b39
  4. 04 7月, 2013 1 次提交
    • J
      teach format-patch to place other authors into in-body "From" · a9080475
      Jeff King 提交于
      Format-patch generates emails with the "From" address set to the
      author of each patch. If you are going to send the emails, however,
      you would want to replace the author identity with yours (if they
      are not the same), and bump the author identity to an in-body
      header.
      
      Normally this is handled by git-send-email, which does the
      transformation before sending out the emails. However, some
      workflows may not use send-email (e.g., imap-send, or a custom
      script which feeds the mbox to a non-git MUA). They could each
      implement this feature themselves, but getting it right is
      non-trivial (one must canonicalize the identities by reversing any
      RFC2047 encoding or RFC822 quoting of the headers, which has caused
      many bugs in send-email over the years).
      
      This patch takes a different approach: it teaches format-patch a
      "--from" option which handles the ident check and in-body header
      while it is writing out the email.  It's much simpler to do at this
      level (because we haven't done any quoting yet), and any workflow
      based on format-patch can easily turn it on.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a9080475
  5. 27 6月, 2013 1 次提交
    • A
      pretty: --format output should honor logOutputEncoding · ecaee805
      Alexey Shumkin 提交于
      One can set an alias
      	$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
      	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
      	--abbrev-commit --date=local"
      
      to see the log as a pretty tree (like *gitk* but in a terminal).
      
      However, log messages written in an encoding i18n.commitEncoding which differs
      from terminal encoding are shown corrupted even when i18n.logOutputEncoding
      and terminal encoding are the same (e.g. log messages committed on a Cygwin box
      with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
      
      To simplify an example we can say the following two commands are expected
      to give the same output to a terminal:
      
      	$ git log --oneline --no-color
      	$ git log --pretty=format:'%h %s'
      
      However, the former pays attention to i18n.logOutputEncoding
      configuration, while the latter does not when it formats "%s".
      
      The same corruption is true for
      	$ git diff --submodule=log
      and
      	$ git rev-list --pretty=format:%s HEAD
      and
      	$ git reset --hard
      
      This patch makes pretty --format honor logOutputEncoding when it formats
      log message.
      Signed-off-by: NAlexey Shumkin <Alex.Crezoff@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ecaee805
  6. 19 4月, 2013 1 次提交
  7. 29 3月, 2013 1 次提交
    • T
      Implement line-history search (git log -L) · 12da1d1f
      Thomas Rast 提交于
      This is a rewrite of much of Bo's work, mainly in an effort to split
      it into smaller, easier to understand routines.
      
      The algorithm is built around the struct range_set, which encodes a
      series of line ranges as intervals [a,b).  This is used in two
      contexts:
      
      * A set of lines we are tracking (which will change as we dig through
        history).
      * To encode diffs, as pairs of ranges.
      
      The main routine is range_set_map_across_diff().  It processes the
      diff between a commit C and some parent P.  It determines which diff
      hunks are relevant to the ranges tracked in C, and computes the new
      ranges for P.
      
      The algorithm is then simply to process history in topological order
      from newest to oldest, computing ranges and (partial) diffs.  At
      branch points, we need to merge the ranges we are watching.  We will
      find that many commits do not affect the chosen ranges, and mark them
      TREESAME (in addition to those already filtered by pathspec limiting).
      Another pass of history simplification then gets rid of such commits.
      
      This is wired as an extra filtering pass in the log machinery.  This
      currently only reduces code duplication, but should allow for other
      simplifications and options to be used.
      
      Finally, we hook a diff printer into the output chain.  Ideally we
      would wire directly into the diff logic, to optionally use features
      like word diff.  However, that will require some major reworking of
      the diff chain, so we completely replace the output with our own diff
      for now.
      
      As this was a GSoC project, and has quite some history by now, many
      people have helped.  In no particular order, thanks go to
      
        Jakub Narebski <jnareb@gmail.com>
        Jens Lehmann <Jens.Lehmann@web.de>
        Jonathan Nieder <jrnieder@gmail.com>
        Junio C Hamano <gitster@pobox.com>
        Ramsay Jones <ramsay@ramsay1.demon.co.uk>
        Will Palmer <wmpalmer@gmail.com>
      
      Apologies to everyone I forgot.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      12da1d1f
  8. 28 3月, 2013 1 次提交
    • T
      Avoid loading commits twice in log with diffs · d1b9b767
      Thomas Rast 提交于
      If you run a log with diffs (such as -p, --raw, --stat etc.) the
      current code ends up loading many objects twice.  For example, for
      'log -3000 -p' my instrumentation said the objects loaded more than
      once are distributed as follows:
      
        2008 blob
        2103 commit
        2678 tree
      
      Fixing blobs and trees will be harder, because those are really used
      within the diff engine and need some form of caching.
      
      However, fixing the commits is easy at least at the band-aid level.
      They are triggered by log_tree_diff() invoking diff_tree_sha1() on
      commits, which duly loads the specified object to dereference it to a
      tree.  Since log_tree_diff() knows that it works with commits and they
      must have trees, we can simply pass through the trees.
      
      We add some parse_commit() calls.  The ones for the parents are
      required; we do not know at this stage if they have been looked at.
      The one for the commit itself is pure paranoia, but has about the same
      cost as an assertion on commit->object.parsed.
      
      This has a quite dramatic effect on log --raw, though only a
      negligible impact on log -p:
      
      Test                      this tree         HEAD
      --------------------------------------------------------------------
      4000.2: log --raw -3000   0.50(0.43+0.06)   0.54(0.46+0.06) +7.0%***
      4000.3: log -p -3000      2.34(2.20+0.13)   2.37(2.22+0.13) +1.2%
      --------------------------------------------------------------------
      Significance hints:  '.' 0.1  '*' 0.05  '**' 0.01  '***' 0.001
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d1b9b767
  9. 15 2月, 2013 2 次提交
  10. 13 2月, 2013 2 次提交
  11. 11 1月, 2013 1 次提交
  12. 22 12月, 2012 4 次提交
    • J
      format-patch: add --reroll-count=$N option · 5fe10fe8
      Junio C Hamano 提交于
      The --reroll-count=$N option, when given a positive integer:
      
       - Adds " v$N" to the subject prefix specified.  As the default
         subject prefix string is "PATCH", --reroll-count=2 makes it
         "PATCH v2".
      
       - Prefixes "v$N-" to the names used for output files.  The cover
         letter, whose name is usually 0000-cover-letter.patch, becomes
         v2-0000-cover-letter.patch when given --reroll-count=2.
      
      This allows users to use the same --output-directory for multiple
      iterations of the same series, without letting the output for a
      newer round overwrite output files from the earlier rounds.  The
      user can incorporate materials from earlier rounds to update the
      newly minted iteration, and use "send-email v2-*.patch" to send out
      the patches belonging to the second iteration easily.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5fe10fe8
    • J
      get_patch_filename(): split into two functions · d28b5d47
      Junio C Hamano 提交于
      The function switched between two operating modes depending on the
      NULL-ness of its two parameters, as a hacky way to share small part
      of implementation, sacrificing cleanliness of the API.
      
      Implement "fmt_output_subject()" function that takes a subject
      string and gives the name for the output file, and on top of it,
      implement "fmt_output_commit()" function that takes a commit and
      gives the name for the output file.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d28b5d47
    • J
      get_patch_filename(): drop "just-numbers" hack · 38ec23ac
      Junio C Hamano 提交于
      The function chooses from three operating modes (format using the
      subject, the commit, or just number) based on NULL-ness of two of
      its parameters, which is an ugly hack for sharing only a bit of
      code.
      
      Separate out the "just numbers" part out to the callers.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      38ec23ac
    • J
      get_patch_filename(): simplify function signature · 021f2f4c
      Junio C Hamano 提交于
      Most functions that emit to a strbuf take the strbuf as their first
      parameter; make this function follow suit.
      
      The serial number of the patch being emitted (nr) and suffix used
      for patch filename (suffix) are both recorded in rev_info; drop
      these separate parameters and pass the rev_info directly.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      021f2f4c
  13. 18 12月, 2012 1 次提交
    • J
      log --format: teach %C(auto,black) to respect color config · 30825178
      Junio C Hamano 提交于
      Traditionally, %C(color attr) always emitted the ANSI color
      sequence; it was up to the scripts that wanted to conditionally
      color their output to omit %C(...) specifier when they do not want
      colors.
      
      Optionally allow "auto," to be prefixed to the color, so that the
      output is colored iff we would color regular "log" output
      (e.g., taking into account color.* and --color command line
      options).
      
      Tests and pretty_context bits by Jeff King <peff@peff.net>.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      30825178
  14. 14 11月, 2012 1 次提交
  15. 18 10月, 2012 4 次提交
  16. 23 5月, 2012 1 次提交
    • J
      format-patch: refactor get_patch_filename · a21c2f94
      Jeff King 提交于
      The get_patch_filename function expects a commit argument
      and uses it to get the sanitized subject line when making a
      patch filename. However, we also want to use this same
      function for the cover letter, which does not have a commit
      object. The current solution is to create a fake commit with
      the subject "cover letter". Instead, let's make the
      get_patch_filename interface more flexibile, and allow
      passing a direct subject.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a21c2f94
  17. 08 5月, 2012 1 次提交
  18. 05 5月, 2012 1 次提交
    • J
      log: respect date_mode_explicit with --format:%gd · f026c756
      Jeff King 提交于
      When we show a reflog selector (e.g., via "git log -g"), we
      perform some DWIM magic: while we normally show the entry's
      index (e.g., HEAD@{1}), if the user has given us a date
      with "--date", then we show a date-based select (e.g.,
      HEAD@{yesterday}).
      
      However, we don't want to trigger this magic if the
      alternate date format we got was from the "log.date"
      configuration; that is not sufficiently strong context for
      us to invoke this particular magic. To fix this, commit
      f4ea32f0 (improve reflog date/number heuristic, 2009-09-24)
      introduced a "date_mode_explicit" flag in rev_info. This
      flag is set only when we see a "--date" option on the
      command line, and we a vanilla date to the reflog code if
      the date was not explicit.
      
      Later, commit 8f8f5476 (Introduce new pretty formats %g[sdD]
      for reflog information, 2009-10-19) added another way to
      show selectors, and it did not respect the date_mode_explicit
      flag from f4ea32f0.
      
      This patch propagates the date_mode_explicit flag to the
      pretty-print code, which can then use it to pass the
      appropriate date field to the reflog code. This brings the
      behavior of "%gd" in line with the other formats, and means
      that its output is independent of any user configuration.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f026c756
  19. 02 5月, 2012 1 次提交
  20. 21 3月, 2012 1 次提交
  21. 12 1月, 2012 1 次提交
  22. 06 1月, 2012 3 次提交
  23. 18 12月, 2011 1 次提交
  24. 13 11月, 2011 1 次提交
    • J
      log: --show-signature · 0c37f1fc
      Junio C Hamano 提交于
      This teaches the "log" family of commands to pass the GPG signature in the
      commit objects to "gpg --verify" via the verify_signed_buffer() interface
      used to verify signed tag objects. E.g.
      
          $ git show --show-signature -s HEAD
      
      shows GPG output in the header part of the output.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0c37f1fc
  25. 05 10月, 2011 1 次提交
  26. 26 8月, 2011 1 次提交
  27. 20 8月, 2011 2 次提交
    • J
      color: delay auto-color decision until point of use · daa0c3d9
      Jeff King 提交于
      When we read a color value either from a config file or from
      the command line, we use git_config_colorbool to convert it
      from the tristate always/never/auto into a single yes/no
      boolean value.
      
      This has some timing implications with respect to starting
      a pager.
      
      If we start (or decide not to start) the pager before
      checking the colorbool, everything is fine. Either isatty(1)
      will give us the right information, or we will properly
      check for pager_in_use().
      
      However, if we decide to start a pager after we have checked
      the colorbool, things are not so simple. If stdout is a tty,
      then we will have already decided to use color. However, the
      user may also have configured color.pager not to use color
      with the pager. In this case, we need to actually turn off
      color. Unfortunately, the pager code has no idea which color
      variables were turned on (and there are many of them
      throughout the code, and they may even have been manipulated
      after the colorbool selection by something like "--color" on
      the command line).
      
      This bug can be seen any time a pager is started after
      config and command line options are checked. This has
      affected "git diff" since 89d07f75 (diff: don't run pager if
      user asked for a diff style exit code, 2007-08-12). It has
      also affect the log family since 1fda91b5 (Fix 'git log'
      early pager startup error case, 2010-08-24).
      
      This patch splits the notion of parsing a colorbool and
      actually checking the configuration. The "use_color"
      variables now have an additional possible value,
      GIT_COLOR_AUTO. Users of the variable should use the new
      "want_color()" wrapper, which will lazily determine and
      cache the auto-color decision.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      daa0c3d9
    • N
      log: decorate "replaced" on to replaced commits · 5267d292
      Nguyễn Thái Ngọc Duy 提交于
      Old code also decorates "new" commits with "refs/replace/SHA1". This
      is now gone, but I guess no one will miss it.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5267d292
  28. 19 8月, 2011 2 次提交