Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Oct 27, 2010
  1. Merge branch 'kb/merge-recursive-rename-threshold'

    * kb/merge-recursive-rename-threshold:
      diff: add synonyms for -M, -C, -B
      merge-recursive: option to specify rename threshold
Commits on Sep 29, 2010
  1. @kballard

    merge-recursive: option to specify rename threshold

    kballard authored committed
    The recursive merge strategy turns on rename detection but leaves the
    rename threshold at the default. Add a strategy option to allow the user
    to specify a rename threshold to use.
    Signed-off-by: Kevin Ballard <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 31, 2010
  1. git log/diff: add -G<regexp> that greps in the patch text

    Teach "-G<regexp>" that is similar to "-S<regexp> --pickaxe-regexp" to the
    "git diff" family of commands.  This limits the diff queue to filepairs
    whose patch text actually has an added or a deleted line that matches the
    given regexp.  Unlike "-S<regexp>", changing other parts of the line that
    has a substring that matches the given regexp IS counted as a change, as
    such a change would appear as one deletion followed by one addition in a
    patch text.
    Unlike -S (pickaxe) that is intended to be used to quickly detect a commit
    that changes the number of occurrences of hits between the preimage and
    the postimage to serve as a part of larger toolchain, this is meant to be
    used as the top-level Porcelain feature.
    The implementation unfortunately has to run "diff" twice if you are
    running "log" family of commands to produce patches in the final output
    (e.g. "git log -p" or "git format-patch").  I think we _could_ cache the
    result in-core if we wanted to, but that would require larger surgery to
    the diffcore machinery (i.e. adding an extra pointer in the filepair
    structure to keep a pointer to a strbuf around, stuff the textual diff to
    the strbuf inside diffgrep_consume(), and make use of it in later stages
    when it is available) and it may not be worth it.
    Signed-off-by: Junio C Hamano <>
Commits on Aug 22, 2010
  1. Merge branch 'mm/shortopt-detached'

    * mm/shortopt-detached:
      log: parse separate option for --glob
      log: parse separate options like git log --grep foo
      diff: parse separate options --stat-width n, --stat-name-width n
      diff: split off a function for --stat-* option parsing
      diff: parse separate options like -S foo
Commits on Aug 18, 2010
  1. Merge branch 'jc/maint-follow-rename-fix'

    * jc/maint-follow-rename-fix:
      log: test for regression introduced in v1.7.2-rc0~103^2~2
      diff --follow: do call diffcore_std() as necessary
      diff --follow: do not waste cycles while recursing
Commits on Aug 13, 2010
  1. diff --follow: do call diffcore_std() as necessary

    Usually, diff frontends populate the output queue with filepairs without
    any rename information and call diffcore_std() to sort the renames out.
    When --follow is in effect, however, diff-tree family of frontend has a
    hack that looks like this:
        diff-tree frontend
        -> diff_tree_sha1()
           . populate diff_queued_diff
           . if --follow is in effect and there is only one change that
             creates the target path, then
           -> try_to_follow_renames()
    	  -> diff_tree_sha1() with no pathspec but with -C
    	  -> diffcore_std() to find renames
    	  . if rename is found, tweak diff_queued_diff and put a
    	    single filepair that records the found rename there
        -> diffcore_std()
           . tweak elements on diff_queued_diff by
           - rename detection
           - path ordering
           - pickaxe filtering
    We need to skip parts of the second call to diffcore_std() that is related
    to rename detection, and do so only when try_to_follow_renames() did find
    a rename.  Earlier 1da6175 (Make diffcore_std only can run once before a
    diff_flush, 2010-05-06) tried to deal with this issue incorrectly; it
    unconditionally disabled any second call to diffcore_std().
    This hopefully fixes the breakage.
    Signed-off-by: Junio C Hamano <>
Commits on Aug 9, 2010
  1. @jlehmann

    Submodules: Add the new "ignore" config option for diff and status

    jlehmann authored committed
    The new "ignore" config option controls the default behavior for "git
    status" and the diff family. It specifies under what circumstances they
    consider submodules as modified and can be set separately for each
    The command line option "--ignore-submodules=" has been extended to accept
    the new parameter "none" for both status and diff.
    Users that chose submodules to get rid of long work tree scanning times
    might want to set the "dirty" option for those submodules. This brings
    back the pre 1.7.0 behavior, where submodule work trees were never
    scanned for modifications. By using "--ignore-submodules=none" on the
    command line the status and diff commands can be told to do a full scan.
    This option can be set to the following values (which have the same name
    and meaning as for the "--ignore-submodules" option of status and diff):
    "all": All changes to the submodule will be ignored.
    "dirty": Only differences of the commit recorded in the superproject and
    	the submodules HEAD will be considered modifications, all changes
    	to the work tree of the submodule will be ignored. When using this
    	value, the submodule will not be scanned for work tree changes at
    	all, leading to a performance benefit on large submodules.
    "untracked": Only untracked files in the submodules work tree are ignored,
    	a changed HEAD and/or modified files in the submodule will mark it
    	as modified.
    "none" (which is the default): Either untracked or modified files in a
    	submodules work tree or a difference between the subdmodules HEAD
    	and the commit recorded in the superproject will make it show up
    	as changed. This value is added as a new parameter for the
    	"--ignore-submodules" option of the diff family and "git status"
    	so the user can override the settings in the configuration.
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 6, 2010
  1. @moy

    diff: parse separate options like -S foo

    moy authored committed
    Change the option parsing logic in revision.c to accept separate forms
    like `-S foo' in addition to `-Sfoo'. The rest of git already accepted
    this form, but revision.c still used its own option parsing.
    Short options affected are -S<string>, -l<num> and -O<orderfile>, for
    which an empty string wouldn't make sense, hence -<option> <arg> isn't
    This patch does not handle --stat-name-width and --stat-width, which are
    special-cases where diff_long_opt do not apply. They are handled in a
    separate patch to ease review.
    Original patch by Matthieu Moy, plus refactoring by Jonathan Nieder.
    Signed-off-by: Matthieu Moy <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 27, 2010
  1. Merge branch 'ab/blame-textconv'

    * ab/blame-textconv:
      t/t8006: test textconv support for blame
      textconv: support for blame
      textconv: make the API public
Commits on Jun 21, 2010
  1. Merge branch 'gv/portable'

    * gv/portable:
      test-lib: use DIFF definition from GIT-BUILD-OPTIONS
      build: propagate $DIFF to scripts
      Makefile: Tru64 portability fix
      Makefile: HP-UX 10.20 portability fixes
      Makefile: HPUX11 portability fixes
      Makefile: SunOS 5.6 portability fix
      inline declaration does not work on AIX
      Allow disabling "inline"
      Some platforms lack socklen_t type
      Make NO_{INET_NTOP,INET_PTON} configured independently
      Makefile: some platforms do not have hstrerror anywhere
      git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition
      test_cmp: do not use "diff -u" on platforms that lack one
      fixup: do not unconditionally disable "diff -u"
      tests: use "test_cmp", not "diff", when verifying the result
      Do not use "diff" found on PATH while building and installing
      enums: omit trailing comma for portability
      Makefile: -lpthread may still be necessary when libc has only pthread stubs
      Rewrite dynamic structure initializations to runtime assignment
      Makefile: pass CPPFLAGS through to fllow customization
Commits on Jun 11, 2010
  1. textconv: make the API public

    Axel Bonnet authored committed
    The textconv functionality allows one to convert a file into text before
    running diff. But this functionality can be useful to other features
    such as blame.
    Signed-off-by: Axel Bonnet <>
    Signed-off-by: Clément Poulain <>
    Signed-off-by: Diane Gasselin <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 1, 2010
  1. @byang

    Add a prefix output callback to diff output

    byang authored committed
    The callback can be used to add some prefix string to each line of
    diff output.
    Signed-off-by: Bo Yang <>
    Signed-off-by: Junio C Hamano <>
Commits on May 31, 2010
  1. enums: omit trailing comma for portability

    Gary V. Vaughan authored committed
    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: Gary V. Vaughan <>
    Signed-off-by: Junio C Hamano <>
Commits on Apr 14, 2010
  1. @trast

    diff: add --word-diff option that generalizes --color-words

    trast authored committed
    This teaches the --color-words engine a more general interface that
    supports two new modes:
    * --word-diff=plain, inspired by the 'wdiff' utility (most similar to
      'wdiff -n <old> <new>'): uses delimiters [-removed-] and {+added+}
    * --word-diff=porcelain, which generates an ad-hoc machine readable
      - each diff unit is prefixed by [-+ ] and terminated by newline as
        in unified diff
      - newlines in the input are output as a line consisting only of a
        tilde '~'
    Both of these formats still support color if it is enabled, using it
    to highlight the differences.  --color-words becomes a synonym for
    --word-diff=color, which is the color-only format.  Also adds some
    compatibility/convenience options.
    Thanks to Junio C Hamano and Miles Bader for good ideas.
    Signed-off-by: Thomas Rast <>
    Signed-off-by: Junio C Hamano <>
Commits on Mar 14, 2010
  1. @jlehmann

    git status: ignoring untracked files must apply to submodules too

    jlehmann authored committed
    Since 1.7.0 submodules are considered dirty when they contain untracked
    files. But when git status is called with the "-uno" option, the user
    asked to ignore untracked files, so they must be ignored in submodules
    too. To achieve this, the new flag DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES
    is introduced.
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Mar 8, 2010
  1. @jlehmann

    git status: Show detailed dirty status of submodules in long format

    jlehmann authored committed
    Since 1.7.0 there are three reasons a submodule is considered modified
    against the work tree: It contains new commits, modified content or
    untracked content. Lets show all reasons in the long format of git status,
    so the user can better asses the nature of the modification. This change
    does not affect the short and porcelain formats.
    Two new members are added to "struct wt_status_change_data" to store the
    information gathered by run_diff_files(). wt-status.c uses the new flag
    DIFF_OPT_DIRTY_SUBMODULES to tell diff-lib.c it wants to get detailed
    dirty information about submodules.
    A hint line for submodules is printed in the dirty header when dirty
    submodules are present.
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 25, 2010
  1. Merge branch 'jc/fix-tree-walk'

    * jc/fix-tree-walk:
      read-tree --debug-unpack
      unpack-trees.c: look ahead in the index
      unpack-trees.c: prepare for looking ahead in the index
      Aggressive three-way merge: fix D/F case
      traverse_trees(): handle D/F conflict case sanely
      more D/F conflict tests
      tests: move convenience regexp to match object names to
Commits on Jan 19, 2010
  1. @jlehmann

    Performance optimization for detection of modified submodules

    jlehmann authored committed
    In the worst case is_submodule_modified() got called three times for
    each submodule. The information we got from scanning the whole
    submodule tree the first time can be reused instead.
    New parameters have been added to diff_change() and diff_addremove(),
    the information is stored in a new member of struct diff_filespec. Its
    value is then reused instead of calling is_submodule_modified() again.
    When no explicit "-dirty" is needed in the output the call to
    is_submodule_modified() is not necessary when the submodules HEAD
    already disagrees with the ref of the superproject, as this alone
    marks it as modified. To achieve that, get_stat_data() got an extra
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 7, 2010
  1. unpack-trees.c: look ahead in the index

    This makes the traversal of index be in sync with the tree traversal.
    When unpack_callback() is fed a set of tree entries from trees, it
    inspects the name of the entry and checks if the an index entry with
    the same name could be hiding behind the current index entry, and
     (1) if the name appears in the index as a leaf node, it is also
         fed to the n_way_merge() callback function;
     (2) if the name is a directory in the index, i.e. there are entries in
         that are underneath it, then nothing is fed to the n_way_merge()
         callback function;
     (3) otherwise, if the name comes before the first eligible entry in the
         index, the index entry is first unpacked alone.
    When traverse_trees_recursive() descends into a subdirectory, the
    cache_bottom pointer is moved to walk index entries within that directory.
    All of these are omitted for diff-index, which does not even want to be
    fed an index entry and a tree entry with D/F conflicts.
    This fixes 3-way read-tree and exposes a bug in other parts of the system
    in t6035, test #5.  The test prepares these three trees:
     O = HEAD^
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/b-2/c/d
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/b/c/d
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/x
     A = HEAD
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/b-2/c/d
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/b/c/d
        100644 blob 587be6b4c3f93f93c489c0111bba5596147a26cb    a/x
     B = master
        120000 blob a36b77384451ea1de7bd340ffca868249626bc52    a/b
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/b-2/c/d
        100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    a/x
    With a clean index that matches HEAD, running
        git read-tree -m -u --aggressive $O $A $B
    now yields
        120000 a36b77384451ea1de7bd340ffca868249626bc52 3       a/b
        100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       a/b-2/c/d
        100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1       a/b/c/d
        100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 2       a/b/c/d
        100644 587be6b4c3f93f93c489c0111bba5596147a26cb 0       a/x
    which is correct.  "master" created "a/b" symlink that did not exist,
    and removed "a/b/c/d" while HEAD did not do touch either path.
    Before this series, read-tree did not notice the situation and resolved
    addition of "a/b" and removal of "a/b/c/d" independently.  If A = HEAD had
    another path "a/b/c/e" added, this merge should conflict but instead it
    silently resolved "a/b" and then immediately overwrote it to add
    "a/b/c/e", which was quite bogus.
    Tests in t1012 start to work with this.
    Signed-off-by: Junio C Hamano <>
Commits on Dec 26, 2009
  1. Merge branch 'jc/1.7.0-diff-whitespace-only-status'

    * jc/1.7.0-diff-whitespace-only-status:
      diff.c: fix typoes in comments
      Make test case number unique
      diff: Rename QUIET internal option to QUICK
      diff: change semantics of "ignore whitespace" options
Commits on Nov 28, 2009
  1. @bertwesarg

    Give the hunk comment its own color

    bertwesarg authored committed
    Inspired by the coloring of quilt.
    Introduce a separate color and paint the hunk comment part, i.e. the name
    of the function, in a separate color "diff.func" (defaults to plain).
    Whitespace between hunk header and hunk comment is printed in plain color.
    Signed-off-by: Bert Wesarg <>
    Signed-off-by: Junio C Hamano <>
Commits on Oct 20, 2009
  1. @dscho

    Add the --submodule option to the diff option family

    dscho authored committed
    When you use the option --submodule=log you can see the submodule
    summaries inlined in the diff, instead of not-quite-helpful SHA-1 pairs.
    The format imitates what "git submodule summary" shows.
    To do that, <path>/.git/objects/ is added to the alternate object
    databases (if that directory exists).
    This option was requested by Jens Lehmann at the GitTogether in Berlin.
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Jens Lehmann <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 29, 2009
  1. diff: Rename QUIET internal option to QUICK

    The option "QUIET" primarily meant "find if we have _any_ difference as
    quick as possible and report", which means we often do not even have to
    look at blobs if we know the trees are different by looking at the higher
    level (e.g. "diff-tree A B").  As a side effect, because there is no point
    showing one change that we happened to have found first, it also enables
    NO_OUTPUT and EXIT_WITH_STATUS options, making the end result look quiet.
    Rename the internal option to QUICK to reflect this better; it also makes
    grepping the source tree much easier, as there are other kinds of QUIET
    option everywhere.
    Signed-off-by: Junio C Hamano <>
  2. diff: change semantics of "ignore whitespace" options

    Traditionally, the --ignore-whitespace* options have merely meant to tell
    the diff output routine that some class of differences are not worth
    showing in the textual diff output, so that the end user has easier time
    to review the remaining (presumably more meaningful) changes.  These
    options never affected the outcome of the command, given as the exit
    status when the --exit-code option was in effect (either directly or
    When you have only whitespace changes, however, you might expect
    	git diff -b --exit-code
    to report that there is _no_ change with zero exit status.
    Change the semantics of --ignore-whitespace* options to mean more than
    "omit showing the difference in text".
    The exit status, when --exit-code is in effect, is computed by checking if
    we found any differences at the path level, while diff frontends feed
    filepairs to the diffcore engine.  When "ignore whitespace" options are in
    effect, we defer this determination until the very end of diffcore
    transformation.  We simply do not know until the textual diff is
    generated, which comes very late in the pipeline.
    When --quiet is in effect, various diff frontends optimize by breaking out
    early from the loop that enumerates the filepairs, when we find the first
    path level difference; when --ignore-whitespace* is used the above change
    automatically disables this optimization.
    Signed-off-by: Junio C Hamano <>
Commits on Mar 4, 2009
  1. Use DIFF_XDL_SET/DIFF_OPT_SET instead of raw bit-masking

    Keith Cascio authored committed
    Signed-off-by: Keith Cascio <>
    Signed-off-by: Junio C Hamano <>
Commits on Feb 11, 2009
  1. @sbeyer

    Generalize and libify index_is_dirty() to index_differs_from(...)

    sbeyer authored committed
    index_is_dirty() in builtin-revert.c checks if the index is dirty.
    This patch generalizes this function to check if the index differs
    from a revision, i.e. the former index_is_dirty() behavior can now be
    achieved by index_differs_from("HEAD", 0).
    The second argument "diff_flags" allows to set further diff option
    flags like DIFF_OPT_IGNORE_SUBMODULES. See DIFF_OPT_* macros in diff.h
    for a list.
    index_differs_from() seems to be useful for more than builtin-revert.c,
    so it is moved into diff-lib.c and also used in builtin-commit.c.
    Yet to mention:
     - "rev.abbrev = 0;" can be safely removed.
       This has no impact on performance or functioning of neither
       setup_revisions() nor run_diff_index().
     - rev.pending.objects is free()d because this fixes a leak.
       (Also see 295dd2a "Fix memory leak in traverse_commit_list")
    Mentored-by: Daniel Barkalow <>
    Mentored-by: Christian Couder <>
    Signed-off-by: Stephan Beyer <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 17, 2009
  1. @dscho

    color-words: take an optional regular expression describing words

    dscho authored committed
    In some applications, words are not delimited by white space.  To
    allow for that, you can specify a regular expression describing
    what makes a word with
    	git diff --color-words='[A-Za-z0-9]+'
    Note that words cannot contain newline characters.
    As suggested by Thomas Rast, the words are the exact matches of the
    regular expression.
    Note that a regular expression beginning with a '^' will match only
    a word at the beginning of the hunk, not a word at the beginning of
    a line, and is probably not what you want.
    This commit contains a quoting fix by Thomas Rast.
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Junio C Hamano <>
Commits on Dec 29, 2008
  1. diff: add option to show context between close hunks

    René Scharfe authored committed
    Merge two hunks if there is only the specified number of otherwise unshown
    context between them.  For --inter-hunk-context=1, the resulting patch has
    the same number of lines but shows uninterrupted context instead of a
    context header line in between.
    Patches generated with this option are easier to read but are also more
    likely to conflict if the file to be patched contains other changes.
    This patch keeps the default for this option at 0.  It is intended to just
    make the feature available in order to see its advantages and downsides.
    Signed-off-by: Rene Scharfe <>
    Signed-off-by: Junio C Hamano <>
Commits on Oct 26, 2008
  1. @peff

    userdiff: require explicitly allowing textconv

    peff authored committed
    Diffs that have been produced with textconv almost certainly
    cannot be applied, so we want to be careful not to generate
    them in things like format-patch.
    This introduces a new diff options, ALLOW_TEXTCONV, which
    controls this behavior. It is off by default, but is
    explicitly turned on for the "log" family of commands, as
    well as the "diff" porcelain (but not diff-* plumbing).
    Because both text conversion and external diffing are
    controlled by these diff options, we can get rid of the
    "plumbing versus porcelain" distinction when reading the
    config. This was an attempt to control the same thing, but
    suffered from being too coarse-grained.
    Signed-off-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
Commits on Sep 25, 2008
  1. @spearce

    Merge branch 'ho/dirstat-by-file'

    spearce authored
    * ho/dirstat-by-file:
      diff --dirstat-by-file: count changed files, not lines
Commits on Sep 19, 2008
  1. Merge branch 'jc/diff-prefix'

    * jc/diff-prefix:
      diff: vary default prefix depending on what are compared
Commits on Sep 5, 2008
  1. @heikkiorsila

    diff --dirstat-by-file: count changed files, not lines

    heikkiorsila authored committed
    This new option --dirstat-by-file is the same as --dirstat, but it
    counts "impacted files" instead of "impacted lines" (lines that are
    added or removed).
    Signed-off-by: Heikki Orsila <>
    Signed-off-by: Junio C Hamano <>
Commits on Sep 4, 2008
  1. diff --cumulative is a sub-option of --dirstat

    The option used to be implemented as if it is a totally independent one,
    but "git diff --cumulative" would not mean anything without "--dirstat".
    This makes --cumulative imply --dirstat.
    Signed-off-by: Junio C Hamano <>
Commits on Aug 31, 2008
  1. diff: vary default prefix depending on what are compared

    With a new configuration "diff.mnemonicprefix", "git diff" shows the
    differences between various combinations of preimage and postimage trees
    with prefixes different from the standard "a/" and "b/".  Hopefully this
    will make the distinction stand out for some people.
        "git diff" compares the (i)ndex and the (w)ork tree;
        "git diff HEAD" compares a (c)ommit and the (w)ork tree;
        "git diff --cached" compares a (c)ommit and the (i)ndex;
        "git-diff HEAD:file1 file2" compares an (o)bject and a (w)ork tree entity;
        "git diff --no-index a b" compares two non-git things (1) and (2).
    Because these mnemonics now have meanings, they are swapped when reverse
    diff is in effect and this feature is enabled.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 16, 2008
  1. @dmpot

    Fix buffer overflow in git diff

    dmpot authored committed
    If PATH_MAX on your system is smaller than a path stored, it may cause
    buffer overflow and stack corruption in diff_addremove() and diff_change()
    functions when running git-diff
    Signed-off-by: Dmitry Potapov <>
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.