1. 19 1月, 2019 1 次提交
  2. 16 1月, 2019 1 次提交
    • B
      tree-walk: store object_id in a separate member · ea82b2a0
      brian m. carlson 提交于
      When parsing a tree, we read the object ID directly out of the tree
      buffer. This is normally fine, but such an object ID cannot be used with
      oidcpy, which copies GIT_MAX_RAWSZ bytes, because if we are using SHA-1,
      there may not be that many bytes to copy.
      
      Instead, store the object ID in a separate struct member. Since we can
      no longer efficiently compute the path length, store that information as
      well in struct name_entry. Ensure we only copy the object ID into the
      new buffer if the path length is nonzero, as some callers will pass us
      an empty path with no object ID following it, and we will not want to
      read past the end of the buffer.
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ea82b2a0
  3. 19 11月, 2018 1 次提交
    • N
      tree-walk.c: make tree_entry_interesting() take an index · 67022e02
      Nguyễn Thái Ngọc Duy 提交于
      In order to support :(attr) when matching pathspec on a tree,
      tree_entry_interesting() needs to take an index (because
      git_check_attr() needs it). This is the preparation step for it. This
      also makes it clearer what index we fall back to when looking up
      attributes during an unpack-trees operation: the source index.
      
      This also fixes revs->pruning.repo initialization that should have
      been done in 2abf3503 (revision.c: remove implicit dependency on
      the_index - 2018-09-21). Without it, skip_uninteresting() will
      dereference a NULL pointer through this call chain
      
        get_revision(revs)
        get_revision_internal
        get_revision_1
        try_to_simplify_commit
        rev_compare_tree
        diff_tree_oid(..., &revs->pruning)
        ll_diff_tree_oid
        diff_tree_paths
        ll_diff_tree
        skip_uninteresting
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      67022e02
  4. 16 8月, 2018 1 次提交
  5. 02 5月, 2018 1 次提交
  6. 15 3月, 2018 1 次提交
  7. 15 8月, 2017 1 次提交
  8. 28 9月, 2016 1 次提交
  9. 26 4月, 2016 2 次提交
  10. 06 1月, 2016 1 次提交
    • D
      do_compare_entry: use already-computed path · d9c2bd56
      David Turner 提交于
      In traverse_trees, we generate the complete traverse path for a
      traverse_info.  Later, in do_compare_entry, we used to go do a bunch
      of work to compare the traverse_info to a cache_entry's name without
      computing that path.  But since we already have that path, we don't
      need to do all that work.  Instead, we can just put the generated
      path into the traverse_info, and do the comparison more directly.
      
      We copy the path because prune_traversal might mutate `base`. This
      doesn't happen in any codepaths where do_compare_entry is called,
      but it's better to be safe.
      
      This makes git checkout much faster -- about 25% on Twitter's
      monorepo.  Deeper directory trees are likely to benefit more than
      shallower ones.
      Signed-off-by: NDavid Turner <dturner@twopensource.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d9c2bd56
  11. 21 5月, 2015 1 次提交
  12. 25 2月, 2014 1 次提交
    • K
      tree-walk: finally switch over tree descriptors to contain a pre-parsed entry · 7146e66f
      Kirill Smelkov 提交于
      This continues 4651ece8 (Switch over tree descriptors to contain a
      pre-parsed entry) and moves the only rest computational part
      
          mode = canon_mode(mode)
      
      from tree_entry_extract() to tree entry decode phase - to
      decode_tree_entry().
      
      The reason to do it, is that canon_mode() is at least 2 conditional
      jumps for regular files, and that could be noticeable should canon_mode()
      be invoked several times.
      
      That does not matter for current Git codebase, where typical tree
      traversal is
      
          while (t->size) {
              sha1 = tree_entry_extract(t, &path, &mode);
              ...
              update_tree_entry(t);
          }
      
      i.e. we do t -> sha1,path.mode "extraction" only once per entry. In such
      cases, it does not matter performance-wise, where that mode
      canonicalization is done - either once in tree_entry_extract(), or once
      in decode_tree_entry() called by update_tree_entry() - it is
      approximately the same.
      
      But for future code, which could need to work with several tree_desc's
      in parallel, it could be handy to operate on tree_desc descriptors, and
      do "extracts" only when needed, or at all, access only relevant part of
      it through structure fields directly.
      
      And for such situations, having canon_mode() be done once in decode
      phase is better - we won't need to pay the performance price of 2 extra
      conditional jumps on every t->mode access.
      
      So let's move mode canonicalization to decode_tree_entry(). That was the
      final bit. Now after tree entry is decoded, it is fully ready and could
      be accessed either directly via field, or through tree_entry_extract()
      which this time got really "totally trivial".
      Signed-off-by: NKirill Smelkov <kirr@mns.spb.ru>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7146e66f
  13. 18 6月, 2013 1 次提交
  14. 28 10月, 2011 2 次提交
  15. 30 8月, 2011 1 次提交
    • J
      traverse_trees(): allow pruning with pathspec · 2842c0f9
      Junio C Hamano 提交于
      The traverse_trees() machinery is primarily meant for merging two (or
      more) trees, and because a merge is a full tree operation, it doesn't
      support any pruning with pathspec.
      
      Since d1f2d7e8 (Make run_diff_index() use unpack_trees(), not read_tree(),
      2008-01-19), however, we use unpack_trees() to traverse_trees() callchain
      to perform "diff-index", which could waste a lot of work traversing trees
      outside the user-supplied pathspec, only to discard at the blob comparison
      level in diff-lib.c::oneway_diff() which is way too late.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2842c0f9
  16. 04 2月, 2011 4 次提交
  17. 27 8月, 2010 1 次提交
  18. 26 8月, 2010 1 次提交
  19. 12 8月, 2010 1 次提交
    • M
      unpack_trees: group error messages by type · e6c111b4
      Matthieu Moy 提交于
      When an error is encountered, it calls add_rejected_file() which either
      - directly displays the error message and stops if in plumbing mode
        (i.e. if show_all_errors is not initialized at 1)
      - or stores it so that it will be displayed at the end with display_error_msgs(),
      
      Storing the files by error type permits to have a list of files for
      which there is the same error instead of having a serie of almost
      identical errors.
      
      As each bind_overlap error combines a file and an old file, a list cannot be
      done, therefore, theses errors are not stored but directly displayed.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e6c111b4
  20. 09 3月, 2008 3 次提交
  21. 02 12月, 2007 1 次提交
    • J
      rename: Break filepairs with different types. · b45563a2
      Junio C Hamano 提交于
      When we consider if a path has been totally rewritten, we did not
      touch changes from symlinks to files or vice versa.  But a change
      that modifies even the type of a blob surely should count as a
      complete rewrite.
      
      While we are at it, modernise diffcore-break to be aware of gitlinks (we
      do not want to touch them).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b45563a2
  22. 17 11月, 2007 1 次提交
    • L
      Fix rev-list when showing objects involving submodules · 481f0ee6
      Linus Torvalds 提交于
      The function mark_tree_uninteresting() assumed that the tree entries
      are blob when they are not trees.  This is not so.  Since we do
      not traverse into submodules (yet), the gitlinks should be ignored.
      
      In general, we should try to start moving away from using the
      "S_ISLNK()" like things for internal git state. It was a mistake to
      just assume the numbers all were same across all systems in the first
      place.  This implementation converts to the "object_type", and then
      uses a case statement.
      
      Noticed by Ilari on IRC.
      Test script taken from an earlier version by Dscho.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      481f0ee6
  23. 14 11月, 2007 1 次提交
    • L
      Fix rev-list when showing objects involving submodules · 4d1012c3
      Linus Torvalds 提交于
      The function mark_tree_uninteresting() assumed that the tree entries
      are blob when they are not trees.  This is not so.  Since we do
      not traverse into submodules (yet), the gitlinks should be ignored.
      
      In general, we should try to start moving away from using the
      "S_ISLNK()" like things for internal git state. It was a mistake to
      just assume the numbers all were same across all systems in the first
      place.  This implementation converts to the "object_type", and then
      uses a case statement.
      
      Noticed by Ilari on IRC.
      Test script taken from an earlier version by Dscho.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4d1012c3
  24. 23 6月, 2007 1 次提交
  25. 14 5月, 2007 1 次提交
  26. 22 3月, 2007 3 次提交
  27. 19 3月, 2007 1 次提交
    • L
      Avoid unnecessary strlen() calls · 304de2d2
      Linus Torvalds 提交于
      This is a micro-optimization that grew out of the mailing list discussion
      about "strlen()" showing up in profiles.
      
      We used to pass regular C strings around to the low-level tree walking
      routines, and while this worked fine, it meant that we needed to call
      strlen() on strings that the caller always actually knew the size of
      anyway.
      
      So pass the length of the string down wih the string, and avoid
      unnecessary calls to strlen(). Also, when extracting a pathname from a
      tree entry, use "tree_entry_len()" instead of strlen(), since the length
      of the pathname is directly calculable from the decoded tree entry itself
      without having to actually do another strlen().
      
      This shaves off another ~5-10% from some loads that are very tree
      intensive (notably doing commit filtering by a pathspec).
      
      Signed-off-by: Linus Torvalds  <torvalds@linux-foundation.org>"
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      304de2d2
  28. 31 5月, 2006 1 次提交
    • L
      tree_entry(): new tree-walking helper function · 4c068a98
      Linus Torvalds 提交于
      This adds a "tree_entry()" function that combines the common operation of
      doing a "tree_entry_extract()" + "update_tree_entry()".
      
      It also has a simplified calling convention, designed for simple loops
      that traverse over a whole tree: the arguments are pointers to the tree
      descriptor and a name_entry structure to fill in, and it returns a boolean
      "true" if there was an entry left to be gotten in the tree.
      
      This allows tree traversal with
      
      	struct tree_desc desc;
      	struct name_entry entry;
      
      	desc.buf = tree->buffer;
      	desc.size = tree->size;
      	while (tree_entry(&desc, &entry) {
      		... use "entry.{path, sha1, mode, pathlen}" ...
      	}
      
      which is not only shorter than writing it out in full, it's hopefully less
      error prone too.
      
      [ It's actually a tad faster too - we don't need to recalculate the entry
        pathlength in both extract and update, but need to do it only once.
        Also, some callers can avoid doing a "strlen()" on the result, since
        it's returned as part of the name_entry structure.
      
        However, by now we're talking just 1% speedup on "git-rev-list --objects
        --all", and we're definitely at the point where tree walking is no
        longer the issue any more. ]
      
      NOTE! Not everybody wants to use this new helper function, since some of
      the tree walkers very much on purpose do the descriptor update separately
      from the entry extraction. So the "extract + update" sequence still
      remains as the core sequence, this is just a simplified interface.
      
      We should probably add a silly two-line inline helper function for
      initializing the descriptor from the "struct tree" too, just to cut down
      on the noise from that common "desc" initializer.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      4c068a98
  29. 20 4月, 2006 1 次提交
  30. 30 3月, 2006 1 次提交
    • J
      tree/diff header cleanup. · 1b0c7174
      Junio C Hamano 提交于
      Introduce tree-walk.[ch] and move "struct tree_desc" and
      associated functions from various places.
      
      Rename DIFF_FILE_CANON_MODE(mode) macro to canon_mode(mode) and
      move it to cache.h.  This macro returns the canonicalized
      st_mode value in the host byte order for files, symlinks and
      directories -- to be compared with a tree_desc entry.
      create_ce_mode(mode) in cache.h is similar but is intended to be
      used for index entries (so it does not work for directories) and
      returns the value in the network byte order.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      1b0c7174