1. 13 3月, 2015 4 次提交
    • N
      untracked cache: invalidate dirs recursively if .gitignore changes · 5ebf79ad
      Nguyễn Thái Ngọc Duy 提交于
      It's easy to see that if an existing .gitignore changes, its SHA-1
      would be different and invalidate_gitignore() is called.
      
      If .gitignore is removed, add_excludes() will treat it like an empty
      .gitignore, which again should invalidate the cached directory data.
      
      if .gitignore is added, lookup_untracked() already fills initial
      .gitignore SHA-1 as "empty file", so again invalidate_gitignore() is
      called.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5ebf79ad
    • N
      untracked cache: initial untracked cache validation · ccad261f
      Nguyễn Thái Ngọc Duy 提交于
      Make sure the starting conditions and all global exclude files are
      good to go. If not, either disable untracked cache completely, or wipe
      out the cache and start fresh.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ccad261f
    • N
      untracked cache: record .gitignore information and dir hierarchy · 0dcb8d7f
      Nguyễn Thái Ngọc Duy 提交于
      The idea is if we can capture all input and (non-rescursive) output of
      read_directory_recursive(), and can verify later that all the input is
      the same, then the second r_d_r() should produce the same output as in
      the first run.
      
      The requirement for this to work is stat info of a directory MUST
      change if an entry is added to or removed from that directory (and
      should not change often otherwise). If your OS and filesystem do not
      meet this requirement, untracked cache is not for you. Most file
      systems on *nix should be fine. On Windows, NTFS is fine while FAT may
      not be [1] even though FAT on Linux seems to be fine.
      
      The list of input of r_d_r() is in the big comment block in dir.h. In
      short, the output of a directory (not counting subdirs) mainly depends
      on stat info of the directory in question, all .gitignore leading to
      it and the check_only flag when r_d_r() is called recursively. This
      patch records all this info (and the output) as r_d_r() runs.
      
      Two hash_sha1_file() are required for $GIT_DIR/info/exclude and
      core.excludesfile unless their stat data matches. hash_sha1_file() is
      only needed when .gitignore files in the worktree are modified,
      otherwise their SHA-1 in index is used (see the previous patch).
      
      We could store stat data for .gitignore files so we don't have to
      rehash them if their content is different from index, but I think
      .gitignore files are rarely modified, so not worth extra cache data
      (and hashing penalty read-cache.c:verify_hdr(), as we will be storing
      this as an index extension).
      
      The implication is, if you change .gitignore, you better add it to the
      index soon or you lose all the benefit of untracked cache because a
      modified .gitignore invalidates all subdirs recursively. This is
      especially bad for .gitignore at root.
      
      This cached output is about untracked files only, not ignored files
      because the number of tracked files is usually small, so small cache
      overhead, while the number of ignored files could go really high
      (e.g. *.o files mixing with source code).
      
      [1] "Description of NTFS date and time stamps for files and folders"
          http://support.microsoft.com/kb/299648Helped-by: NTorsten Bögershausen <tboegi@web.de>
      Helped-by: NDavid Turner <dturner@twopensource.com>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0dcb8d7f
    • N
      dir.c: optionally compute sha-1 of a .gitignore file · 55fe6f51
      Nguyễn Thái Ngọc Duy 提交于
      This is not used anywhere yet. But the goal is to compare quickly if a
      .gitignore file has changed when we have the SHA-1 of both old (cached
      somewhere) and new (from index or a tree) versions.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Helped-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      55fe6f51
  2. 22 10月, 2014 1 次提交
  3. 27 8月, 2014 1 次提交
  4. 15 7月, 2014 2 次提交
  5. 21 6月, 2014 1 次提交
    • J
      cleanup duplicate name_compare() functions · ccdd4a0f
      Jeremiah Mahler 提交于
      We often represent our strings as a counted string, i.e. a pair of
      the pointer to the beginning of the string and its length, and the
      string may not be NUL terminated to that length.
      
      To compare a pair of such counted strings, unpack-trees.c and
      read-cache.c implement their own name_compare() functions
      identically.  In addition, the cache_name_compare() function in
      read-cache.c is nearly identical.  The only difference is when one
      string is the prefix of the other string, in which case
      name_compare() returns -1/+1 to show which one is longer, and
      cache_name_compare() returns the difference of the lengths to show
      the same information.
      
      Unify these three functions by using the implementation from
      cache_name_compare().  This does not make any difference to the
      existing and future callers, as they must be paying attention only
      to the sign of the returned value (and not the magnitude) because
      the original implementations of these two functions return values
      returned by memcmp(3) when the one string is not a prefix of the
      other string, and the only thing memcmp(3) guarantees its callers is
      the sign of the returned value, not the magnitude.
      Signed-off-by: NJeremiah Mahler <jmmahler@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ccdd4a0f
  6. 03 6月, 2014 1 次提交
    • P
      dir.c:trim_trailing_spaces(): fix for " \ " sequence · e61a6c1d
      Pasha Bolokhov 提交于
      Discard the unnecessary 'nr_spaces' variable, remove 'strlen()' and
      improve the 'if' structure.  Switch to pointers instead of integers
      to control the loop.
      
      Slightly more rare occurrences of 'text  \    ' with a backslash
      in between spaces are handled correctly.  Namely, the code in
      7e2e4b37 (dir: ignore trailing spaces in exclude patterns, 2014-02-09)
      does not reset 'last_space' when a backslash is encountered and the above
      line stays intact as a result.
      
      Add a test at the end of t/t0008-ignores.sh to exhibit this behavior.
      Signed-off-by: NPasha Bolokhov <pasha.bolokhov@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e61a6c1d
  7. 01 4月, 2014 1 次提交
  8. 04 3月, 2014 1 次提交
  9. 25 2月, 2014 4 次提交
  10. 21 2月, 2014 1 次提交
  11. 11 2月, 2014 2 次提交
  12. 22 1月, 2014 2 次提交
  13. 07 12月, 2013 1 次提交
  14. 18 9月, 2013 3 次提交
    • E
      dir: revert work-around for retired dangerous behavior · de372b1b
      Eric Sunshine 提交于
      directory_exists_in_index_icase() dangerously assumed that it could
      access one character beyond the end of its directory argument, and that
      that character would unconditionally be '/'.  2eac2a4c (ls-files -k: a
      directory only can be killed if the index has a non-directory,
      2013-08-15) added a caller which did not respect this undocumented
      assumption, and 680be044 (dir.c::test_one_path(): work around
      directory_exists_in_index_icase() breakage, 2013-08-23) added a
      work-around which temporarily appends a '/' before invoking
      directory_exists_in_index_icase().
      
      Since the dangerous behavior of directory_exists_in_index_icase() has
      been eliminated, the work-around is now redundant, so retire it (but not
      the tests added by the same commit).
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      de372b1b
    • E
      name-hash: stop storing trailing '/' on paths in index_state.dir_hash · d28eec26
      Eric Sunshine 提交于
      When 5102c617 (Add case insensitivity support for directories when using
      git status, 2010-10-03) added directories to the name-hash there was
      only a single hash table in which both real cache entries and leading
      directory prefixes were registered. To distinguish between the two types
      of entries, directories were stored with a trailing '/'.
      
      2092678c (name-hash.c: fix endless loop with core.ignorecase=true,
      2013-02-28), however, moved directories to a separate hash table
      (index_state.dir_hash) but retained the (now) redundant trailing '/',
      thus callers continue to bear the burden of ensuring the slash's
      presence before searching the index for a directory. Eliminate this
      redundancy by storing paths in the dir-hash without the trailing '/'.
      
      An important benefit of this change is that it eliminates undocumented
      and dangerous behavior of dir.c:directory_exists_in_index_icase() in
      which it assumes not only that it can validly access one character
      beyond the end of its incoming directory argument, but also that that
      character will unconditionally be a '/'. This perilous behavior was
      "tolerated" because the string passed in by its lone caller always had a
      '/' in that position, however, things broke [1] when 2eac2a4c (ls-files
      -k: a directory only can be killed if the index has a non-directory,
      2013-08-15) added a new caller which failed to respect the undocumented
      assumption.
      
      [1]: http://thread.gmane.org/gmane.comp.version-control.git/232727Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d28eec26
    • E
      employ new explicit "exists in index?" API · ebbd7439
      Eric Sunshine 提交于
      Each caller of index_name_exists() knows whether it is looking for a
      directory or a file, and can avoid the unnecessary indirection of
      index_name_exists() by instead calling index_dir_exists() or
      index_file_exists() directly.
      
      Invoking the appropriate search function explicitly will allow a
      subsequent patch to relieve callers of the artificial burden of having
      to add a trailing '/' to the pathname given to index_dir_exists().
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ebbd7439
  15. 24 8月, 2013 1 次提交
    • E
      dir.c::test_one_path(): work around directory_exists_in_index_icase() breakage · 680be044
      Eric Sunshine 提交于
      directory_exists_in_index() takes pathname and its length, but its
      helper function directory_exists_in_index_icase() reads one byte
      beyond the end of the pathname and expects there to be a '/'.
      
      This needs to be fixed, as that one-byte-beyond-the-end location may
      not even be readable, possibly by not registering directories to
      name hashes with trailing slashes.  In the meantime, update the new
      caller added recently to treat_one_path() to make sure that the path
      buffer it gives the function is one byte longer than the path it is
      asking the function about by appending a slash to it.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      680be044
  16. 16 8月, 2013 2 次提交
    • J
      ls-files -k: a directory only can be killed if the index has a non-directory · 2eac2a4c
      Junio C Hamano 提交于
      "ls-files -o" and "ls-files -k" both traverse the working tree down
      to find either all untracked paths or those that will be "killed"
      (removed from the working tree to make room) when the paths recorded
      in the index are checked out.  It is necessary to traverse the
      working tree fully when enumerating all the "other" paths, but when
      we are only interested in "killed" paths, we can take advantage of
      the fact that paths that do not overlap with entries in the index
      can never be killed.
      
      The treat_one_path() helper function, which is called during the
      recursive traversal, is the ideal place to implement an
      optimization.
      
      When we are looking at a directory P in the working tree, there are
      three cases:
      
       (1) P exists in the index.  Everything inside the directory P in
           the working tree needs to go when P is checked out from the
           index.
      
       (2) P does not exist in the index, but there is P/Q in the index.
           We know P will stay a directory when we check out the contents
           of the index, but we do not know yet if there is a directory
           P/Q in the working tree to be killed, so we need to recurse.
      
       (3) P does not exist in the index, and there is no P/Q in the index
           to require P to be a directory, either.  Only in this case, we
           know that everything inside P will not be killed without
           recursing.
      
      Note that this helper is called by treat_leading_path() that decides
      if we need to traverse only subdirectories of a single common
      leading directory, which is essential for this optimization to be
      correct.  This caller checks each level of the leading path
      component from shallower directory to deeper ones, and that is what
      allows us to only check if the path appears in the index.  If the
      call to treat_one_path() weren't there, given a path P/Q/R, the real
      traversal may start from directory P/Q/R, even when the index
      records P as a regular file, and we would end up having to check if
      any leading subpath in P/Q/R, e.g. P, appears in the index.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2eac2a4c
    • J
      dir.c: use the cache_* macro to access the current index · 71261027
      Junio C Hamano 提交于
      These codepaths always start from the_index and use index_*
      functions, but there is no reason to do so.  Use the compatibility
      cache_* macro to access the current in-core index like everybody
      else.
      
      While at it, fix typo in the comment for a function to check if a
      path within a directory appears in the index.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      71261027
  17. 16 7月, 2013 12 次提交