1. 20 11月, 2015 2 次提交
  2. 24 6月, 2015 1 次提交
    • J
      Revert "diff-lib.c: adjust position of i-t-a entries in diff" · 78cc1a54
      Junio C Hamano 提交于
      This reverts commit d95d728a.
      
      It turns out that many other commands that need to interact with the
      result of running diff-files and diff-index, e.g.  "git apply", "git
      rm", etc., need to be adjusted to the new world order it brings in.
      For example, it would break this sequence to correct a whitespace
      breakage in the parts you changed:
      
      	git add -N file
      	git diff --cached file | git apply --cached --whitespace=fix
      	git checkout file
      
      In the old world order, "diff" showed a patch to modify an existing
      empty file by adding its full contents, and "apply" updated the
      index by modifying the existing empty blob (which is what an
      Intent-to-Add entry records in the index) with that patch.
      
      In the new world order, "diff" shows a patch to create a new file
      with its full contents, but because "apply" thinks that the i-t-a
      entry already exists in the index, it refused to accept a creation.
      
      Adjusting "apply" to this new world order is easy, but we need to
      assess the extent of the damage to the rest of the system the new
      world order brought in before going forward and adjust them all,
      after which we can resurrect the commit being reverted here.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      78cc1a54
  3. 24 3月, 2015 1 次提交
    • N
      diff-lib.c: adjust position of i-t-a entries in diff · d95d728a
      Nguyễn Thái Ngọc Duy 提交于
      Entries added by "git add -N" are reminder for the user so that they
      don't forget to add them before committing. These entries appear in
      the index even though they are not real. Their presence in the index
      leads to a confusing "git status" like this:
      
          On branch master
          Changes to be committed:
                  new file:   foo
      
          Changes not staged for commit:
                  modified:   foo
      
      If you do a "git commit", "foo" will not be included even though
      "status" reports it as "to be committed". This patch changes the
      output to become
      
          On branch master
          Changes not staged for commit:
                  new file:   foo
      
          no changes added to commit
      
      The two hunks in diff-lib.c adjust "diff-index" and "diff-files" so
      that i-t-a entries appear as new files in diff-files and nothing in
      diff-index.
      
      Due to this change, diff-files may start to report "new files" for the
      first time. "add -u" needs to be told about this or it will die in
      denial, screaming "new files can't exist! Reality is wrong." Luckily,
      it's the only one among run_diff_files() callers that needs fixing.
      
      Now in the new world order, a hierarchy in the index that contain
      i-t-a paths is written out as a tree object as if these i-t-a
      entries do not exist, and comparing the index with such a tree
      object that would result from writing out the hierarchy will result
      in no difference.  Update a test in t2203 that expected the i-t-a
      entries to appear as "added to the index" in the comparison to
      instead expect no output.
      
      An earlier change eec3e7e4 (cache-tree: invalidate i-t-a paths after
      generating trees, 2012-12-16) becomes an unnecessary pessimization
      in the new world order---a cache-tree in the index that corresponds
      to a hierarchy with i-t-a paths can now be marked as valid and
      record the object name of the tree that results from writing a tree
      object out of that hierarchy, as it will compare equal to that tree.
      
      Reverting the commit is left for the future, though, as it is purely
      a performance issue and no longer affects correctness.
      Helped-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d95d728a
  4. 14 3月, 2015 1 次提交
  5. 05 2月, 2015 1 次提交
  6. 16 5月, 2014 1 次提交
    • J
      run_diff_files: do not look at uninitialized stat data · 53048100
      Jeff King 提交于
      If we try to diff an index entry marked CE_VALID (because it
      was marked with --assume-unchanged), we do not bother even
      running stat() on the file to see if it was removed. This
      started long ago with 540e694b (Prevent diff machinery from
      examining assume-unchanged entries on worktree, 2009-08-11).
      
      However, the subsequent code may look at our "struct stat"
      and expect to find actual data; currently it will find
      whatever cruft was left on the stack. This can cause
      problems in two situations:
      
        1. We call match_stat_with_submodule with the stat data,
           so a submodule may be erroneously marked as changed.
      
        2. If --find-copies-harder is in effect, we pass all
           entries, even unchanged ones, to diff_change, so it can
           list them as rename/copy sources. Since we found no
           change, we assume that function will realize it and not
           actually display any diff output. However, we end up
           feeding it a bogus mode, leading it to sometimes claim
           there was a mode change.
      
      We can fix both by splitting the CE_VALID and regular code
      paths, and making sure only to look at the stat information
      in the latter. Furthermore, we push the declaration of our
      "struct stat" down into the code paths that actually set it,
      so we cannot accidentally access it uninitialized in future
      code.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      53048100
  7. 25 2月, 2014 2 次提交
  8. 20 7月, 2013 2 次提交
  9. 16 7月, 2013 2 次提交
  10. 03 6月, 2013 2 次提交
  11. 30 7月, 2012 1 次提交
    • J
      diff: do not use null sha1 as a sentinel value · e5450100
      Jeff King 提交于
      The diff code represents paths using the diff_filespec
      struct. This struct has a sha1 to represent the sha1 of the
      content at that path, as well as a sha1_valid member which
      indicates whether its sha1 field is actually useful. If
      sha1_valid is not true, then the filespec represents a
      working tree file (e.g., for the no-index case, or for when
      the index is not up-to-date).
      
      The diff_filespec is only used internally, though. At the
      interfaces to the diff subsystem, callers feed the sha1
      directly, and we create a diff_filespec from it. It's at
      that point that we look at the sha1 and decide whether it is
      valid or not; callers may pass the null sha1 as a sentinel
      value to indicate that it is not.
      
      We should not typically see the null sha1 coming from any
      other source (e.g., in the index itself, or from a tree).
      However, a corrupt tree might have a null sha1, which would
      cause "diff --patch" to accidentally diff the working tree
      version of a file instead of treating it as a blob.
      
      This patch extends the edges of the diff interface to accept
      a "sha1_valid" flag whenever we accept a sha1, and to use
      that flag when creating a filespec. In some cases, this
      means passing the flag through several layers, making the
      code change larger than would be desirable.
      
      One alternative would be to simply die() upon seeing
      corrupted trees with null sha1s. However, this fix more
      directly addresses the problem (while bogus sha1s in a tree
      are probably a bad thing, it is really the sentinel
      confusion sending us down the wrong code path that is what
      makes it devastating). And it means that git is more capable
      of examining and debugging these corrupted trees. For
      example, you can still "diff --raw" such a tree to find out
      when the bogus entry was introduced; you just cannot do a
      "--patch" diff (just as you could not with any other
      corrupted tree, as we do not have any content to diff).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5450100
  12. 19 1月, 2012 1 次提交
    • N
      diff-index: enable recursive pathspec matching in unpack_trees · 5c8eeb83
      Nguyen Thai Ngoc Duy 提交于
      The pathspec structure has a few bits of data to drive various operation
      modes after we unified the pathspec matching logic in various codepaths.
      For example, max_depth field is there so that "git grep" can limit the
      output for files found in limited depth of tree traversal. Also in order
      to show just the surface level differences in "git diff-tree", recursive
      field stops us from descending into deeper level of the tree structure
      when it is set to false, and this also affects pathspec matching when
      we have wildcards in the pathspec.
      
      The diff-index has always wanted the recursive behaviour, and wanted to
      match pathspecs without any depth limit. But we forgot to do so when we
      updated tree_entry_interesting() logic to unify the pathspec matching
      logic.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5c8eeb83
  13. 17 1月, 2012 1 次提交
    • N
      diff-index: enable recursive pathspec matching in unpack_trees · 4838237c
      Nguyen Thai Ngoc Duy 提交于
      The pathspec structure has a few bits of data to drive various operation
      modes after we unified the pathspec matching logic in various codepaths.
      For example, max_depth field is there so that "git grep" can limit the
      output for files found in limited depth of tree traversal. Also in order
      to show just the surface level differences in "git diff-tree", recursive
      field stops us from descending into deeper level of the tree structure
      when it is set to false, and this also affects pathspec matching when
      we have wildcards in the pathspec.
      
      The diff-index has always wanted the recursive behaviour, and wanted to
      match pathspecs without any depth limit. But we forgot to do so when we
      updated tree_entry_interesting() logic to unify the pathspec matching
      logic.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4838237c
  14. 22 9月, 2011 1 次提交
  15. 30 8月, 2011 1 次提交
    • J
      diff-index: pass pathspec down to unpack-trees machinery · 2f88c197
      Junio C Hamano 提交于
      And finally, pass the pathspec down through unpack_trees() to traverse_trees()
      callchain.
      
      Before and after applying this series, looking for changes in the kernel
      repository with a fairly narrow pathspec becomes somewhat faster.
      
        (without patch)
        $ /usr/bin/time git diff --raw v2.6.27 -- net/ipv6 >/dev/null
        0.48user 0.05system 0:00.53elapsed 100%CPU (0avgtext+0avgdata 163296maxresident)k
        0inputs+952outputs (0major+11163minor)pagefaults 0swaps
      
        (with patch)
        $ /usr/bin/time git diff --raw v2.6.27 -- net/ipv6 >/dev/null
        0.01user 0.00system 0:00.02elapsed 104%CPU (0avgtext+0avgdata 43856maxresident)k
        0inputs+24outputs (0major+3688minor)pagefaults 0swaps
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f88c197
  16. 14 7月, 2011 3 次提交
  17. 01 6月, 2011 2 次提交
    • J
      diff-index --quiet: learn the "stop feeding the backend early" logic · b4194828
      Junio C Hamano 提交于
      A negative return from the unpack callback function usually means unpack
      failed for the entry and signals the unpack_trees() machinery to fail the
      entire merge operation, immediately and there is no other way for the
      callback to tell the machinery to exit early without reporting an error.
      
      This is what we usually want to make a merge all-or-nothing operation, but
      the machinery is also used for diff-index codepath by using a custom
      unpack callback function. And we do sometimes want to exit early without
      failing, namely when we are under --quiet and can short-cut the diff upon
      finding the first difference.
      
      Add "exiting_early" field to unpack_trees_options structure, to signal the
      unpack_trees() machinery that the negative return value is not signaling
      an error but an early return from the unpack_trees() machinery. As this by
      definition hasn't unpacked everything, discard the resulting index just
      like the failure codepath.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b4194828
    • J
      diff: futureproof "stop feeding the backend early" logic · 28b9264d
      Junio C Hamano 提交于
      Refactor the "do not stop feeding the backend early" logic into a small
      helper function and use it in both run_diff_files() and diff_tree() that
      has the stop-early optimization. We may later add other types of diffcore
      transformation that require to look at the whole result like diff-filter
      does, and having the logic in a single place is essential for longer term
      maintainability.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28b9264d
  18. 24 4月, 2011 2 次提交
    • J
      diff-files: show unmerged entries correctly · 095ce953
      Junio C Hamano 提交于
      Earlier, e9c84099 (diff-index --cached --raw: show tree entry on the LHS
      for unmerged entries., 2007-01-05) taught the command to show the object
      name and the mode from the entry coming from the tree side when comparing
      a tree with an unmerged index.
      
      This is a belated companion patch that teaches diff-files to show the mode
      from the entry coming from the working tree side, when comparing an
      unmerged index and the working tree.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      095ce953
    • J
      diff: remove often unused parameters from diff_unmerge() · fa7b2908
      Junio C Hamano 提交于
      e9c84099 (diff-index --cached --raw: show tree entry on the LHS for
      unmerged entries., 2007-01-05) added a <mode, object name> pair as
      parameters to this function, to store them in the pre-image side of an
      unmerged file pair.  Now the function is fixed to return the filepair it
      queued, we can make the caller on the special case codepath to do so.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa7b2908
  19. 17 3月, 2011 1 次提交
    • J
      diff --quiet: disable optimization when --diff-filter=X is used · 2cfe8a68
      Junio C Hamano 提交于
      The code notices that the caller does not want any detail of the changes
      and only wants to know if there is a change or not by specifying --quiet.
      And it breaks out of the loop when it knows it already found any change.
      
      When you have a post-process filter (e.g. --diff-filter), however, the
      path we found to be different in the previous round and set HAS_CHANGES
      bit may end up being uninteresting, and there may be no output at the end.
      The optimization needs to be disabled for such case.
      
      Note that the f245194f (diff: change semantics of "ignore whitespace"
      options, 2009-05-22) already disables this optimization by refraining
      from setting HAS_CHANGES when post-process filters that need to inspect
      the contents of the files (e.g. -S, -w) in diff_change() function.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2cfe8a68
  20. 04 2月, 2011 3 次提交
  21. 10 8月, 2010 1 次提交
    • J
      Submodules: Add the new "ignore" config option for diff and status · aee9c7d6
      Jens Lehmann 提交于
      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
      submodule.
      
      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: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aee9c7d6
  22. 12 6月, 2010 1 次提交
    • J
      Add optional parameters to the diff option "--ignore-submodules" · dd44d419
      Jens Lehmann 提交于
      In some use cases it is not desirable that the diff family considers
      submodules that only contain untracked content as dirty. This may happen
      e.g. when the submodule is not under the developers control and not all
      build generated files have been added to .gitignore by the upstream
      developers. Using the "untracked" parameter for the "--ignore-submodules"
      option disables checking for untracked content and lets git diff report
      them as changed only when they have new commits or modified content.
      
      Sometimes it is not wanted to have submodules show up as changed when they
      just contain changes to their work tree. An example for that are scripts
      which just want to check for submodule commits while ignoring any changes
      to the work tree. Also users having large submodules known not to change
      might want to use this option, as the - sometimes substantial - time it
      takes to scan the submodule work tree(s) is saved.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd44d419
  23. 14 3月, 2010 1 次提交
  24. 13 3月, 2010 2 次提交
    • J
      git status: Fix false positive "new commits" output for dirty submodules · 85adbf2f
      Jens Lehmann 提交于
      Testing if the output "new commits" should appear in the long format of
      "git status" is done by comparing the hashes of the diffpair. This always
      resulted in printing "new commits" for submodules that contained untracked
      or modified content, even if they did not contain new commits. The reason
      was that match_stat_with_submodule() did set the "changed" flag for dirty
      submodules, resulting in two->sha1 being set to the null_sha1 at the call
      sites, which indicates that new commits are present. This is changed so
      that when no new commits are present, the same object names are in the
      sha1 field for both sides of the filepair, and the working tree side will
      have the "dirty_submodule" flag set when appropriate. For a submodule to
      be seen as modified even when it just has a dirty work tree, some
      conditions had to be extended to also check for the "dirty_submodule"
      flag.
      
      Unfortunately the test case that should have found this bug had been
      changed incorrectly too. It is fixed and extended to test for other
      combinations too.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      85adbf2f
    • J
      Refactor dirty submodule detection in diff-lib.c · ae6d5c1b
      Jens Lehmann 提交于
      Moving duplicated code into the new function match_stat_with_submodule().
      Replacing the implicit activation of detailed checks for the dirtiness of
      submodules when DIFF_FORMAT_PATCH was selected with explicitly setting
      the recently added DIFF_OPT_DIRTY_SUBMODULES option in diff_setup_done().
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae6d5c1b
  25. 09 3月, 2010 2 次提交
    • J
      revision: introduce setup_revision_opt · 32962c9b
      Junio C Hamano 提交于
      So far the last parameter to setup_revisions() was to specify the default
      ref when the command line did not give any (typically "HEAD").  This changes
      it to take a pointer to a structure so that we can add other information without
      touching too many codepaths in later patches.
      
      There is no functionality change.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      32962c9b
    • J
      git status: Show detailed dirty status of submodules in long format · 9297f77e
      Jens Lehmann 提交于
      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: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9297f77e
  26. 05 3月, 2010 1 次提交
    • J
      git diff --submodule: Show detailed dirty status of submodules · c7e1a736
      Jens Lehmann 提交于
      When encountering a dirty submodule while doing "git diff --submodule"
      print an extra line for new untracked content and another for modified
      but already tracked content. And if the HEAD of the submodule is equal
      to the ref diffed against in the superproject, drop the output which
      would just show the same SHA1s and no commit message headlines.
      
      To achieve that, the dirty_submodule bitfield is expanded to two bits.
      The output of "git status" inside the submodule is parsed to set the
      according bits.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7e1a736
  27. 25 1月, 2010 1 次提交