1. 13 2月, 2008 1 次提交
    • L
      Add "--dirstat" for some directory statistics · 7df7c019
      Linus Torvalds 提交于
      This adds a new form of overview diffstat output, doing something that I
      have occasionally ended up doing manually (and badly, because it's
      actually pretty nasty to do), and that I think is very useful for an
      project like the kernel that has a fairly deep and well-separated
      directory structure with semantic meaning.
      
      What I mean by that is that it's often interesting to see exactly which
      sub-directories are impacted by a patch, and to what degree - even if you
      don't perhaps care so much about the individual files themselves.
      
      What makes the concept more interesting is that the "impact" is often
      hierarchical: in the kernel, for example, something could either have a
      very localized impact to "fs/ext3/" and then it's interesting to see that
      such a patch changes mostly that subdirectory, but you could have another
      patch that changes some generic VFS-layer issue which affects _many_
      subdirectories that are all under "fs/", but none - or perhaps just a
      couple of them - of the individual filesystems are interesting in
      themselves.
      
      So what commonly happens is that you may have big changes in a specific
      sub-subdirectory, but still also significant separate changes to the
      subdirectory leading up to that - maybe you have significant VFS-level
      changes, but *also* changes under that VFS layer in the NFS-specific
      directories, for example. In that case, you do want the low-level parts
      that are significant to show up, but then the insignificant ones should
      show up as under the more generic top-level directory.
      
      This patch shows all of that with "--dirstat". The output can be either
      something simple like
      
              commit 81772fe...
              Author: Thomas Gleixner <tglx@linutronix.de>
              Date:   Sun Feb 10 23:57:36 2008 +0100
      
                  x86: remove over noisy debug printk
      
                  pageattr-test.c contains a noisy debug printk that people reported.
                  The condition under which it prints (randomly tapping into a mem_map[]
                  hole and not being able to c_p_a() there) is valid behavior and not
                  interesting to report.
      
                  Remove it.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      
               100.0% arch/x86/mm/
      
      or something much more complex like
      
              commit e231c2e...
              Author: David Howells <dhowells@redhat.com>
              Date:   Thu Feb 7 00:15:26 2008 -0800
      
                  Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)
      
      	  20.5% crypto/
      	   7.6% fs/afs/
      	   7.6% fs/fuse/
      	   7.6% fs/gfs2/
      	   5.1% fs/jffs2/
      	   5.1% fs/nfs/
      	   5.1% fs/nfsd/
      	   7.6% fs/reiserfs/
      	  15.3% fs/
      	   7.6% net/rxrpc/
      	  10.2% security/keys/
      
      where that latter example is an example of significant work in some
      individual fs/*/ subdirectories (like the patches to reiserfs accounting
      for 7.6% of the whole), but then discounting those individual filesystems,
      there's also 15.3% other "random" things that weren't worth reporting on
      their oen left over under fs/ in general (either in that directory itself,
      or in subdirectories of fs/ that didn't have enough changes to be reported
      individually).
      
      I'd like to stress that the "15.3% fs/" mentioned above is the stuff that
      is under fs/ but that was _not_ significant enough to report on its own.
      So the above does _not_ mean that 15.3% of the work was under fs/ per se,
      because that 15.3% does *not* include the already-reported 7.6% of afs,
      7.6% of fuse etc.
      
      If you want to enable "cumulative" directory statistics, you can use the
      "--cumulative" flag, which adds up percentages recursively even when
      they have been already reported for a sub-directory.  That cumulative
      output is disabled if *all* of the changes in one subdirectory come from
      a deeper subdirectory, to avoid repeating subdirectories all the way to
      the root.
      
      For an example of the cumulative reporting, the above commit becomes
      
      	commit e231c2e...
      	Author: David Howells <dhowells@redhat.com>
      	Date:   Thu Feb 7 00:15:26 2008 -0800
      
      	    Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)
      
      	  20.5% crypto/
      	   7.6% fs/afs/
      	   7.6% fs/fuse/
      	   7.6% fs/gfs2/
      	   5.1% fs/jffs2/
      	   5.1% fs/nfs/
      	   5.1% fs/nfsd/
      	   7.6% fs/reiserfs/
      	  61.5% fs/
      	   7.6% net/rxrpc/
      	  10.2% security/keys/
      
      in which the commit percentages now obviously add up to much more than
      100%: now the changes that were already reported for the sub-directories
      under fs/ are then cumulatively included in the whole percentage of fs/
      (ie now shows 61.5% as opposed to the 15.3% without the cumulative
      reporting).
      
      The default reporting limit has been arbitrarily set at 3%, which seems
      to be a pretty good cut-off, but you can specify the cut-off manually by
      giving it as an option parameter (eg "--dirstat=5" makes the cut-off be
      at 5% instead)
      
      NOTE! The percentages are purely about the total lines added and removed,
      not anything smarter (or dumber) than that. Also note that you should not
      generally expect things to add up to 100%: not only does it round down, we
      don't report leftover scraps (they add up to the top-level change count,
      but we don't even bother reporting that, it only reports subdirectories).
      
      Quite frankly, as a top-level manager this is really convenient for me,
      but it's going to be very boring for git itself since there are few
      subdirectories. Also, don't expect things to make tons of sense if you
      combine this with "-M" and there are cross-directory renames etc.
      
      But even for git itself, you can get some fun statistics. Try out
      
              git log --dirstat
      
      and see the occasional mentions of things like Documentation/, git-gui/,
      gitweb/ and gitk-git/. Or try out something like
      
              git diff --dirstat v1.5.0..v1.5.4
      
      which does kind of git an overview that shows *something*. But in general,
      the output is more exciting for big projects with deeper structure, and
      doing a
      
              git diff --dirstat v2.6.24..v2.6.25-rc1
      
      on the kernel is what I actually wrote this for!
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7df7c019
  2. 05 1月, 2008 1 次提交
    • J
      add a "basic" diff config callback · 9a1805a8
      Jeff King 提交于
      The diff porcelain uses git_diff_ui_config to set
      porcelain-ish config options, like automatically turning on
      color. The plumbing specifically avoids calling this
      function, since it doesn't want things like automatic color
      or rename detection.
      
      However, some diff options should be set for both plumbing
      and porcelain. For example, one can still turn on color in
      git-diff-files using the --color command line option. This
      means we want the color config from color.diff.* (so that
      once color is on, we use the user's preferred scheme), but
      _not_ the color.diff variable.
      
      We split the diff config into "ui" and "basic", where
      "basic" is suitable for use by plumbing (so _most_ things
      affecting the output should still go into the "ui" part).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9a1805a8
  3. 20 12月, 2007 1 次提交
  4. 14 12月, 2007 2 次提交
    • J
      diff --check: minor fixups · da31b358
      Junio C Hamano 提交于
      There is no reason --exit-code and --check-diff must be mutually
      exclusive, so assign different bits to different results and allow them
      to be returned from the command.  Introduce diff_result_code() to factor
      out the common code to decide final status code based on diffopt
      settings and use it everywhere.
      
      Update tests to match the above fix.
      
      Turning pager off when "diff --check" is used is a regression.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      da31b358
    • W
      "diff --check" should affect exit status · 62c64895
      Wincent Colaiuta 提交于
      "git diff" has a --check option that can be used to check for whitespace
      problems but it only reported by printing warnings to the
      console.
      
      Now when the --check option is used we give a non-zero exit status,
      making "git diff --check" nicer to use in scripts and hooks.
      Signed-off-by: NWincent Colaiuta <win@wincent.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      62c64895
  5. 12 11月, 2007 1 次提交
  6. 10 11月, 2007 2 次提交
    • J
      git-add: make the entry stat-clean after re-adding the same contents · fb63d7f8
      Junio C Hamano 提交于
      Earlier in commit 0781b8a9
      (add_file_to_index: skip rehashing if the cached stat already
      matches), add_file_to_index() were taught not to re-add the path
      if it already matches the index.
      
      The change meant well, but was not executed quite right.  It
      used ie_modified() to see if the file on the work tree is really
      different from the index, and skipped adding the contents if the
      function says "not modified".
      
      This was wrong.  There are three possible comparison results
      between the index and the file in the work tree:
      
       - with lstat(2) we _know_ they are different.  E.g. if the
         length or the owner in the cached stat information is
         different from the length we just obtained from lstat(2), we
         can tell the file is modified without looking at the actual
         contents.
      
       - with lstat(2) we _know_ they are the same.  The same length,
         the same owner, the same everything (but this has a twist, as
         described below).
      
       - we cannot tell from lstat(2) information alone and need to go
         to the filesystem to actually compare.
      
      The last case arises from what we call 'racy git' situation,
      that can be caused with this sequence:
      
          $ echo hello >file
          $ git add file
          $ echo aeiou >file ;# the same length
      
      If the second "echo" is done within the same filesystem
      timestamp granularity as the first "echo", then the timestamp
      recorded by "git add" and the timestamp we get from lstat(2)
      will be the same, and we can mistakenly say the file is not
      modified.  The path is called 'racily clean'.  We need to
      reliably detect racily clean paths are in fact modified.
      
      To solve this problem, when we write out the index, we mark the
      index entry that has the same timestamp as the index file itself
      (that is the time from the point of view of the filesystem) to
      tell any later code that does the lstat(2) comparison not to
      trust the cached stat info, and ie_modified() then actually goes
      to the filesystem to compare the contents for such a path.
      
      That's all good, but it should not be used for this "git add"
      optimization, as the goal of "git add" is to actually update the
      path in the index and make it stat-clean.  With the false
      optimization, we did _not_ cause any data loss (after all, what
      we failed to do was only to update the cached stat information),
      but it made the following sequence leave the file stat dirty:
      
          $ echo hello >file
          $ git add file
          $ echo hello >file ;# the same contents
          $ git add file
      
      The solution is not to use ie_modified() which goes to the
      filesystem to see if it is really clean, but instead use
      ie_match_stat() with "assume racily clean paths are dirty"
      option, to force re-adding of such a path.
      
      There was another problem with "git add -u".  The codepath
      shares the same issue when adding the paths that are found to be
      modified, but in addition, it asked "git diff-files" machinery
      run_diff_files() function (which is "git diff-files") to list
      the paths that are modified.  But "git diff-files" machinery
      uses the same ie_modified() call so that it does not report
      racily clean _and_ actually clean paths as modified, which is
      not what we want.
      
      The patch allows the callers of run_diff_files() to pass the
      same "assume racily clean paths are dirty" option, and makes
      "git-add -u" codepath to use that option, to discover and re-add
      racily clean _and_ actually clean paths.
      
      We could further optimize on top of this patch to differentiate
      the case where the path really needs re-adding (i.e. the content
      of the racily clean entry was indeed different) and the case
      where only the cached stat information needs to be refreshed
      (i.e. the racily clean entry was actually clean), but I do not
      think it is worth it.
      
      This patch applies to maint and all the way up.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fb63d7f8
    • J
      ce_match_stat, run_diff_files: use symbolic constants for readability · 4bd5b7da
      Junio C Hamano 提交于
      ce_match_stat() can be told:
      
       (1) to ignore CE_VALID bit (used under "assume unchanged" mode)
           and perform the stat comparison anyway;
      
       (2) not to perform the contents comparison for racily clean
           entries and report mismatch of cached stat information;
      
      using its "option" parameter.  Give them symbolic constants.
      
      Similarly, run_diff_files() can be told not to report anything
      on removed paths.  Also give it a symbolic constant for that.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4bd5b7da
  7. 15 8月, 2007 1 次提交
    • R
      diff: squelch empty diffs even more · 6d2d9e86
      René Scharfe 提交于
      When we compare two non-tracked files, or explicitly
      specify --no-index, the suggestion to run git-status
      is not helpful.
      
      The patch adds a new diff_options bitfield member, no_index, that
      is used instead of the special value of -2 of the rev_info field
      max_count to indicate that the index is not to be used.  This makes
      it possible to pass that flag down to diffcore_skip_stat_unmatch(),
      which only has one diff_options parameter.
      
      This could even become a cleanup if we removed all assignments of
      max_count to a value of -2 (viz. replacement of a magic value with
      a self-documenting field name) but I didn't dare to do that so late
      in the rc game..
      
      The no_index bit, if set, then tells diffcore_skip_stat_unmatch()
      to not account for any skipped stat-mismatches, which avoids the
      suggestion to run git-status.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d2d9e86
  8. 14 8月, 2007 1 次提交
    • J
      git-diff: squelch "empty" diffs · fb13227e
      Junio C Hamano 提交于
      After starting to edit a working tree file but later when your edit ends
      up identical to the original (this can also happen when you ran a
      wholesale regexp replace with something like "perl -i" that does not
      actually modify many of the paths), "git diff" between the index and the
      working tree outputs many "empty" diffs that show "diff --git" headers
      and nothing else, because these paths are stat-dirty.  While it was a
      way to warn the user that the earlier action of the user made the index
      ineffective as an optimization mechanism, it was felt too loud for the
      purpose of warning even to experienced users, and also resulted in
      confusing people new to git.
      
      This replaces the "empty" diffs with a single warning message at the
      end.  Having many such paths hurts performance, and you can run
      "git-update-index --refresh" to update the lstat(2) information recorded
      in the index in such a case.  "git-status" does so as a side effect, and
      that is more familiar to the end-user, so we recommend it to them.
      
      The change affects only "git diff" that outputs patch text, because that
      is where the annoyance of too many "empty" diff is most strongly felt,
      and because the warning message can be safely ignored by downstream
      tools without getting mistaken as part of the patch.  For the low-level
      "git diff-files" and "git diff-index", the traditional behaviour is
      retained.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fb13227e
  9. 23 6月, 2007 1 次提交
    • L
      Finally implement "git log --follow" · 750f7b66
      Linus Torvalds 提交于
      Ok, I've really held off doing this too damn long, because I'm lazy, and I
      was always hoping that somebody else would do it.
      
      But no, people keep asking for it, but nobody actually did anything, so I
      decided I might as well bite the bullet, and instead of telling people
      they could add a "--follow" flag to "git log" to do what they want to do,
      I decided that it looks like I just have to do it for them..
      
      The code wasn't actually that complicated, in that the diffstat for this
      patch literally says "70 insertions(+), 1 deletions(-)", but I will have
      to admit that in order to get to this fairly simple patch, you did have to
      know and understand the internal git diff generation machinery pretty
      well, and had to really be able to follow how commit generation interacts
      with generating patches and generating the log.
      
      So I suspect that while I was right that it wasn't that hard, I might have
      been expecting too much of random people - this patch does seem to be
      firmly in the core "Linus or Junio" territory.
      
      To make a long story short: I'm sorry for it taking so long until I just
      did it.
      
      I'm not going to guarantee that this works for everybody, but you really
      can just look at the patch, and after the appropriate appreciative noises
      ("Ooh, aah") over how clever I am, you can then just notice that the code
      itself isn't really that complicated.
      
      All the real new code is in the new "try_to_follow_renames()" function. It
      really isn't rocket science: we notice that the pathname we were looking
      at went away, so we start a full tree diff and try to see if we can
      instead make that pathname be a rename or a copy from some other previous
      pathname. And if we can, we just continue, except we show *that*
      particular diff, and ever after we use the _previous_ pathname.
      
      One thing to look out for: the "rename detection" is considered to be a
      singular event in the _linear_ "git log" output! That's what people want
      to do, but I just wanted to point out that this patch is *not* carrying
      around a "commit,pathname" kind of pair and it's *not* going to be able to
      notice the file coming from multiple *different* files in earlier history.
      
      IOW, if you use "git log --follow", then you get the stupid CVS/SVN kind
      of "files have single identities" kind of semantics, and git log will just
      pick the identity based on the normal move/copy heuristics _as_if_ the
      history could be linearized.
      
      Put another way: I think the model is broken, but given the broken model,
      I think this patch does just about as well as you can do. If you have
      merges with the same "file" having different filenames over the two
      branches, git will just end up picking _one_ of the pathnames at the point
      where the newer one goes away. It never looks at multiple pathnames in
      parallel.
      
      And if you understood all that, you probably didn't need it explained, and
      if you didn't understand the above blathering, it doesn't really mtter to
      you. What matters to you is that you can now do
      
      	git log -p --follow builtin-rev-list.c
      
      and it will find the point where the old "rev-list.c" got renamed to
      "builtin-rev-list.c" and show it as such.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      750f7b66
  10. 08 6月, 2007 1 次提交
  11. 23 4月, 2007 1 次提交
    • J
      Support 'diff=pgm' attribute · f1af60bd
      Junio C Hamano 提交于
      This enhances the attributes mechanism so that external programs
      meant for existing GIT_EXTERNAL_DIFF interface can be specifed
      per path.
      
      To configure such a custom diff driver, first define a custom
      diff driver in the configuration:
      
      	[diff "my-c-diff"]
      		command = <<your command string comes here>>
      
      Then mark the paths that you want to use this custom driver
      using the attribute mechanism.
      
      	*.c	diff=my-c-diff
      
      The intent of this separation is that the attribute mechanism is
      used for specifying the type of the contents, while the
      configuration mechanism is used to define what needs to be done
      to that type of the contents, which would be specific to both
      platform and personal taste.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      f1af60bd
  12. 15 3月, 2007 3 次提交
    • J
      diff --quiet · 68aacb2f
      Junio C Hamano 提交于
      This adds the command line option 'quiet' to tell 'git diff-*'
      that we are not interested in the actual diff contents but only
      want to know if there is any change.  This option automatically
      turns --exit-code on, and turns off output formatting, as it
      does not make much sense to show the first hit we happened to
      have found.
      
      The --quiet option is silently turned off (but --exit-code is
      still in effect, so is silent output) if postprocessing filters
      such as pickaxe and diff-filter are used.  For all practical
      purposes I do not think of a reason to want to use these filters
      and not viewing the diff output.
      
      The backends have not been taught about the option with this patch.
      That is a topic for later rounds.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      68aacb2f
    • J
      Remove unused diffcore_std_no_resolve · 3161b4b5
      Junio C Hamano 提交于
      This was only used by diff-tree-helper program, whose purpose
      was to translate a raw diff to a patch.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      3161b4b5
    • A
      Allow git-diff exit with codes similar to diff(1) · 41bbf9d5
      Alex Riesen 提交于
      This introduces a new command-line option: --exit-code. The diff
      programs will return 1 for differences, return 0 for equality, and
      something else for errors.
      Signed-off-by: NAlex Riesen <raa.lkml@gmail.com>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      41bbf9d5
  13. 01 3月, 2007 1 次提交
  14. 26 2月, 2007 1 次提交
  15. 23 2月, 2007 1 次提交
    • J
      Teach git-diff-files the new option `--no-index` · d516c2d1
      Johannes Schindelin 提交于
      With this flag and given two paths, git-diff-files behaves as a GNU diff
      lookalike (plus the git goodies like --check, colour, etc.).  This flag
      is also available in git-diff.  It also works outside of a git repository.
      
      In addition, if git-diff{,-files} is called without revision or stage
      parameter, and with exactly two paths at least one of which is not tracked,
      the default is --no-index.
      
      So, you can now say
      
      	git diff /etc/inittab /etc/fstab
      
      and it actually works!
      
      This also unifies the duplicated argument parsing between cmd_diff_files()
      and builtin_diff_files().
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d516c2d1
  16. 06 2月, 2007 1 次提交
    • J
      git-blame: no rev means start from the working tree file. · 1cfe7733
      Junio C Hamano 提交于
      Warning: this changes the semantics.
      
      This makes "git blame" without any positive rev to start digging
      from the working tree copy, which is made into a fake commit
      whose sole parent is the HEAD.
      
      It also adds --contents <file> option to pretend as if the
      working tree copy has the contents of the named file.  You can
      use '-' to make the command read from the standard input.
      
      If you want the command to start annotating from the HEAD
      commit, you need to explicitly give HEAD parameter.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      1cfe7733
  17. 07 1月, 2007 1 次提交
    • J
      diff-index --cached --raw: show tree entry on the LHS for unmerged entries. · e9c84099
      Junio C Hamano 提交于
      This updates the way diffcore represents an unmerged pair
      somewhat.  It used to be that entries with mode=0 on both sides
      were used to represent an unmerged pair, but now it has an
      explicit flag.  This is to allow diff-index --cached to report
      the entry from the tree when the path is unmerged in the index.
      
      This is used in updating "git reset <tree> -- <path>" to restore
      absense of the path in the index from the tree.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e9c84099
  18. 16 12月, 2006 1 次提交
  19. 05 11月, 2006 1 次提交
  20. 27 10月, 2006 1 次提交
    • R
      Make git-cherry handle root trees · 2b60356d
      Rene Scharfe 提交于
      This patch on top of 'next' makes built-in git-cherry handle root
      commits.
      
      It moves the static function log-tree.c::diff_root_tree() to
      tree-diff.c and makes it more similar to diff_tree_sha1() by
      shuffling around arguments and factoring out the call to
      log_tree_diff_flush().  Consequently the name is changed to
      diff_root_tree_sha1().  It is a version of diff_tree_sha1() that
      compares the empty tree (= root tree) against a single 'real' tree.
      
      This function is then used in get_patch_id() to compute patch IDs
      for initial commits instead of SEGFAULTing, as the current code
      does if confronted with parentless commits.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      2b60356d
  21. 14 10月, 2006 1 次提交
  22. 27 9月, 2006 1 次提交
  23. 24 9月, 2006 1 次提交
  24. 08 9月, 2006 1 次提交
  25. 11 8月, 2006 1 次提交
  26. 24 7月, 2006 1 次提交
    • J
      Colorize 'commit' lines in log ui · ce436973
      Jeff King 提交于
      When paging through the output of git-whatchanged, the color cues help to
      visually navigate within a diff. However, it is difficult to notice when a
      new commit starts, because the commit and log are shown in the "normal"
      color. This patch colorizes the 'commit' line, customizable through
      diff.colors.commit and defaulting to yellow.
      
      As a side effect, some of the diff color engine (slot enum, get_color) has
      become accessible outside of diff.c.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ce436973
  27. 08 7月, 2006 3 次提交
  28. 27 6月, 2006 3 次提交
  29. 24 6月, 2006 1 次提交
  30. 18 6月, 2006 1 次提交
  31. 21 5月, 2006 2 次提交