1. 07 1月, 2013 1 次提交
    • A
      dir.c: use a single struct exclude_list per source of excludes · c082df24
      Adam Spiers 提交于
      Previously each exclude_list could potentially contain patterns
      from multiple sources.  For example dir->exclude_list[EXC_FILE]
      would typically contain patterns from .git/info/exclude and
      core.excludesfile, and dir->exclude_list[EXC_DIRS] could contain
      patterns from multiple per-directory .gitignore files during
      directory traversal (i.e. when dir->exclude_stack was more than
      one item deep).
      
      We split these composite exclude_lists up into three groups of
      exclude_lists (EXC_CMDL / EXC_DIRS / EXC_FILE as before), so that each
      exclude_list now contains patterns from a single source.  This will
      allow us to cleanly track the origin of each pattern simply by adding
      a src field to struct exclude_list, rather than to struct exclude,
      which would make memory management of the source string tricky in the
      EXC_DIRS case where its contents are dynamically generated.
      
      Similarly, by moving the filebuf member from struct exclude_stack to
      struct exclude_list, it allows us to track and subsequently free
      memory buffers allocated during the parsing of all exclude files,
      rather than only tracking buffers allocated for files in the EXC_DIRS
      group.
      Signed-off-by: NAdam Spiers <git@adamspiers.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c082df24
  2. 29 12月, 2012 3 次提交
  3. 21 12月, 2012 1 次提交
  4. 12 7月, 2012 1 次提交
    • T
      Strip namelen out of ce_flags into a ce_namelen field · b60e188c
      Thomas Gummerer 提交于
      Strip the name length from the ce_flags field and move it
      into its own ce_namelen field in struct cache_entry. This
      will both give us a tiny bit of a performance enhancement
      when working with long pathnames and is a refactoring for
      more readability of the code.
      
      It enhances readability, by making it more clear what
      is a flag, and where the length is stored and make it clear
      which functions use stages in comparisions and which only
      use the length.
      
      It also makes CE_NAMEMASK private, so that users don't
      mistakenly write the name length in the flags.
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b60e188c
  5. 09 7月, 2012 1 次提交
  6. 06 6月, 2012 1 次提交
    • J
      unpack-trees.c: use path_excluded() in check_ok_to_remove() · 589570db
      Junio C Hamano 提交于
      This function is responsible for determining if a path that is not
      tracked is ignored and allow "checkout" to overwrite it as needed.
      It used excluded() without checking if higher level directory in the
      path is ignored; correct it to use path_excluded() for this check.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ---
      
       * There are uses of lower-level interface excluded_from_list() in
         the codepath for narrow-checkout hack; they are supposed to be
         already checking each level as they descend, and are not touched
         with this patch.
      589570db
  7. 21 5月, 2012 1 次提交
  8. 01 5月, 2012 1 次提交
  9. 28 4月, 2012 1 次提交
  10. 11 4月, 2012 2 次提交
    • R
      unpack-trees: plug minor memory leak · 6ff264ee
      René Scharfe 提交于
      The allocations made by unpack_nondirectories() using create_ce_entry()
      are never freed.
      
      In the non-merge case, we duplicate them using add_entry() and later
      only look at the first allocated element (src[0]), perhaps even only
      by mistake.  Split out the actual addition from add_entry() into the
      new helper do_add_entry() and call this non-duplicating function
      instead of add_entry() to avoid the leak.
      
      Valgrind reports this for the command "git archive v1.7.9" without
      the patch:
      
        ==13372== LEAK SUMMARY:
        ==13372==    definitely lost: 230,986 bytes in 2,325 blocks
        ==13372==    indirectly lost: 0 bytes in 0 blocks
        ==13372==      possibly lost: 98 bytes in 1 blocks
        ==13372==    still reachable: 2,259,198 bytes in 3,243 blocks
        ==13372==         suppressed: 0 bytes in 0 blocks
      
      And with the patch applied:
      
        ==13375== LEAK SUMMARY:
        ==13375==    definitely lost: 65 bytes in 1 blocks
        ==13375==    indirectly lost: 0 bytes in 0 blocks
        ==13375==      possibly lost: 0 bytes in 0 blocks
        ==13375==    still reachable: 2,364,417 bytes in 3,245 blocks
        ==13375==         suppressed: 0 bytes in 0 blocks
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6ff264ee
    • R
      unpack-trees: don't perform any index operation if we're not merging · 97e5954b
      René Scharfe 提交于
      src[0] points to the index entry in the merge case and to the first
      tree to unpack in the non-merge case.  We only want to mark the index
      entry, so check first if we're merging.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      97e5954b
  11. 28 10月, 2011 1 次提交
  12. 23 9月, 2011 2 次提交
  13. 22 9月, 2011 1 次提交
  14. 30 8月, 2011 1 次提交
    • J
      unpack-trees: allow pruning with pathspec · 40e37256
      Junio C Hamano 提交于
      Use the pathspec pruning of traverse_trees() from unpack_trees(). Again,
      the unpack_trees() machinery is primarily meant for merging two (or more)
      trees, and because a merge is a full tree operation, it didn't support any
      pruning with pathspec, and this codepath probably should not be enabled
      while running a merge, but the caller in diff-lib.c::diff_cache() should
      be able to take advantage of it.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      40e37256
  15. 01 8月, 2011 1 次提交
  16. 01 6月, 2011 1 次提交
    • 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
  17. 26 5月, 2011 1 次提交
    • J
      unpack-trees: add the dry_run flag to unpack_trees_options · 2c9078d0
      Jens Lehmann 提交于
      Until now there was no way to test if unpack_trees() with update=1 would
      succeed without really updating the work tree. The reason for that is that
      setting update to 0 does skip the tests for new files and deactivates the
      sparse handling, thereby making that unsuitable as a dry run.
      
      Add the new dry_run flag to struct unpack_trees_options unpack_trees().
      Setting that together with the update flag will check if the work tree
      update would be successful without doing it for real.
      
      The only class of problems that is not detected at the moment are file
      system conditions like ENOSPC or missing permissions. Also the index
      entries of updated files are not as they would be after a real checkout
      because lstat() isn't run as the files aren't updated for real.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2c9078d0
  18. 11 5月, 2011 1 次提交
    • N
      sparse checkout: do not eagerly decide the fate for whole directory · 28911091
      Nguyễn Thái Ngọc Duy 提交于
      Sparse-setting code follows closely how files are excluded in
      read_directory(), every entry (including directories) are fed to
      excluded_from_list() to decide if the entry is suitable. Directories
      are treated no different than files. If a directory is matched (or
      not), the whole directory is considered matched (or not) and the
      process moves on.
      
      This generally works as long as there are no patterns to exclude parts
      of the directory. In case of sparse checkout code, the following patterns
      
        t
        !t/t0000-basic.sh
      
      will produce a worktree with full directory "t" even if t0000-basic.sh
      is requested to stay out.
      
      By the same reasoning, if a directory is to be excluded, any rules to
      re-include certain files within that directory will be ignored.
      
      Fix it by always checking files against patterns. If no pattern can be
      used to decide whether an entry is in our out
      (ie. excluded_from_list() returns -1), the entry will be
      included/excluded the same as their parent directory.
      
      Noticed-by: <skillzero@gmail.com>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28911091
  19. 23 3月, 2011 1 次提交
    • S
      Fix sparse warnings · c2e86add
      Stephen Boyd 提交于
      Fix warnings from 'make check'.
      
       - These files don't include 'builtin.h' causing sparse to complain that
         cmd_* isn't declared:
      
         builtin/clone.c:364, builtin/fetch-pack.c:797,
         builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
         builtin/merge-index.c:69, builtin/merge-recursive.c:22
         builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
         builtin/notes.c:822, builtin/pack-redundant.c:596,
         builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
         builtin/remote.c:1512, builtin/remote-ext.c:240,
         builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
         builtin/unpack-file.c:25, builtin/var.c:75
      
       - These files have symbols which should be marked static since they're
         only file scope:
      
         submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
         submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
         unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
         url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
      
       - These files redeclare symbols to be different types:
      
         builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
         usage.c:49, usage.c:58, usage.c:63, usage.c:72
      
       - These files use a literal integer 0 when they really should use a NULL
         pointer:
      
         daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
      
      While we're in the area, clean up some unused #includes in builtin files
      (mostly exec_cmd.h).
      Signed-off-by: NStephen Boyd <bebarino@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2e86add
  20. 16 2月, 2011 1 次提交
  21. 14 1月, 2011 2 次提交
    • J
      unpack-trees: handle lstat failure for existing file · a93e5301
      Jonathan Nieder 提交于
      When check_leading_path notices a file in the way of a new entry to be
      checked out, verify_absent uses (1) the mode to determine whether it
      is a directory (2) the rest of the stat information to check if this
      is actually an old entry, disguised by a change in filename (e.g.,
      README -> Readme) that is significant to git but insignificant to the
      underlying filesystem.  If lstat fails, these checks are performed
      with an uninitialied stat structure, producing essentially random
      results.
      
      Better to just error out when lstat fails.
      
      The easiest way to reproduce this is to remove a file after the
      check_leading_path call and before the lstat in verify_absent.  An
      lstat failure other than ENOENT in check_leading_path would also
      trigger the same code path.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a93e5301
    • J
      unpack-trees: handle lstat failure for existing directory · 92fda79e
      Jonathan Nieder 提交于
      When check_leading_path notices no file in the way of the new entry to
      be checked out, verify_absent checks whether there is a directory
      there or nothing at all.  If that lstat call fails (for example due to
      ENOMEM), it assumes ENOENT, meaning a directory with untracked files
      would be clobbered in that case.
      
      Check errno after calling lstat, and for conditions other than ENOENT,
      just error out.
      
      This is a theoretical race condition.  lstat has to succeed moments
      before it fails for there to be trouble.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      92fda79e
  22. 05 1月, 2011 1 次提交
    • J
      unpack_trees(): skip trees that are the same in all input · 83c90314
      Junio C Hamano 提交于
      unpack_trees() merges two trees (the current HEAD and the destination
      commit) when switching to another branch, checking and updating the index
      entry where the destination differs from the current HEAD.  It merges three
      trees (the common ancestor, the current HEAD and the other commit) when
      performing a three-way merge, checking and updating the index entry when
      the merge result differs from the current HEAD.  It does so by walking the
      input trees in parallel all the way down to the leaves.
      
      One common special case is a directory is identical across the trees
      involved in the merge.  In such a case, we do not have to descend into the
      directory at all---we know that the end result is to keep the entries in
      the current index.
      
      This optimization cannot be applied in a few special cases in
      unpack_trees(), though.  We need to descend into the directory and update
      the index entries from the target tree in the following cases:
      
       - When resetting (e.g. "git reset --hard"); and
      
       - When checking out a tree for the first time into an empty working tree
         (e.g. "git read-tree -m -u HEAD HEAD" with missing .git/index).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      83c90314
  23. 23 12月, 2010 1 次提交
  24. 15 12月, 2010 3 次提交
  25. 01 12月, 2010 1 次提交
    • N
      unpack-trees: fix sparse checkout's "unable to match directories" · 9037026d
      Nguyễn Thái Ngọc Duy 提交于
      Matching index entries against an excludes file currently has two
      problems.
      
      First, there's no function to do it.  Code paths (like sparse
      checkout) that wanted to try it would iterate over index entries and
      for each index entry pass that path to excluded_from_list().  But that
      is not how excluded_from_list() works; one is supposed to feed in each
      ancester of a path before a given path to find out if it was excluded
      because of some parent or grandparent matching a
      
        bigsubdirectory/
      
      pattern despite the path not matching any .gitignore pattern directly.
      
      Second, it's inefficient.  The excludes mechanism is supposed to let
      us block off vast swaths of the filesystem as uninteresting; separately
      checking every index entry doesn't fit that model.
      
      Introduce a new function to take care of both these problems.  This
      traverses the index in depth-first order (well, that's what order the
      index is in) to mark un-excluded entries.
      
      Maybe some day the in-core index format will be restructured to make
      this sort of operation easier.  Or maybe we will want to try some
      binary search based thing.  The interface is simple enough to allow
      all those things.  Example:
      
        clear_ce_flags(the_index.cache, the_index.cache_nr,
                       CE_CANDIDATE, CE_CLEARME, exclude_list);
      
      would clear the CE_CLEARME flag on all index entries with
      CE_CANDIDATE flag and not matched by exclude_list.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9037026d
  26. 30 11月, 2010 2 次提交
    • N
      unpack-trees: move all skip-worktree checks back to unpack_trees() · 2431afbf
      Nguyễn Thái Ngọc Duy 提交于
      Earlier, the will_have_skip_worktree() checks are done in various
      places, which makes it hard to traverse the index tree-alike, required
      by excluded_from_list(). This patch moves all the checks into two
      loops in unpack_trees().
      
      Entries in index in this operation can be classified into two
      groups: ones already in index before unpack_trees() is called and ones
      added to index after traverse_trees() is called.
      
      In both groups, before checking file status on worktree, the future
      skip-worktree bit must be checked, so that if an entry will be outside
      worktree, worktree should not be checked.
      
      For the first group, the future skip-worktree bit is precomputed and
      stored as CE_NEW_SKIP_WORKTREE in the first loop before
      traverse_trees() is called so that *way_merge() function does not need
      to compute it again.
      
      For the second group, because we don't know what entries will be in
      this group until traverse_trees() finishes, operations that need
      future skip-worktree check is delayed until CE_NEW_SKIP_WORKTREE is
      computed in the second loop. CE_ADDED is used to mark entries in the
      second group.
      
      CE_ADDED and CE_NEW_SKIP_WORKTREE are temporary flags used in
      unpack_trees().  CE_ADDED is only used by add_to_index(), which should
      not be called while unpack_trees() is running.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2431afbf
    • N
      0fd0e241
  27. 16 11月, 2010 1 次提交
  28. 14 10月, 2010 2 次提交
  29. 04 9月, 2010 3 次提交