summaryrefslogtreecommitdiff
path: root/src/ignore.c
Commit message (Collapse)AuthorAgeFilesLines
* Pop ignore only if whole relative path matchesRussell Belfer2014-04-181-5/+8
| | | | | | | | | | | When traversing the directory structure, the iterator pushes and pops ignore files using a vector. Some directories don't have ignore files, so it uses a path comparison to decide when it is right to actually pop the last ignore file. This was only comparing directory suffixes, though, so a subdirectory with the same name as a parent could result in the parent's .gitignore being popped off the list ignores too early. This changes the logic to compare the entire relative path of the ignore file.
* Fix broken logic for attr cache invalidationRussell Belfer2014-04-171-36/+26
| | | | | | | The checks to see if files were out of date in the attibute cache was wrong because the cache-breaker data wasn't getting stored correctly. Additionally, when the cache-breaker triggered, the old file data was being leaked.
* Lock attribute file while reparsing dataRussell Belfer2014-04-171-14/+17
| | | | | | | | | I don't love this approach, but achieving thread-safety for attribute and ignore data while reloading files would require a larger rewrite in order to avoid this. If an attribute or ignore file is out of date, this holds a lock on the file while we are reloading the data so that another thread won't try to reload the data at the same time.
* Fix tests with new attr cache codeRussell Belfer2014-04-171-13/+14
|
* Attribute file cache refactorRussell Belfer2014-04-171-53/+75
| | | | | | | This is a big refactoring of the attribute file cache to be a bit simpler which in turn makes it easier to enforce a lock around any updates to the cache so that it can be used in a threaded env. Tons of changes to the attributes and ignores code.
* Fix leak when using push and pop with ignoresRussell Belfer2014-04-171-0/+3
| | | | | | | | The iterator pushes and pops ignores incrementally onto a list as it traverses the directory structure so that it doesn't have to constantly recheck which ignore files apply. With the new ref counting, it wasn't decrementing the refcount on the ignores that it removed from the vector.
* Fix refcount issues with mutex protected ignoresRussell Belfer2014-04-171-1/+15
| | | | Some ignore files were not being freed from the cache.
* Fix core.excludesfile named .gitignorerb/fix-leading-slash-ignoresRussell Belfer2014-04-141-8/+4
| | | | | | | | | | | | | | | | | Ignore rules with slashes in them are matched using FNM_PATHNAME and use the path to the .gitignore file from the root of the repository along with the path fragment (including slashes) in the ignore file itself. Unfortunately, the relative path to the .gitignore file was being applied to the global core.excludesfile if that was also named ".gitignore". This fixes that with more precise matching and includes test for ignore rules with leading slashes (which were the primary example of this being broken in the real world). This also backports an improvement to the file context logic from the threadsafe-iterators branch where we don't rely on mutating the key of the attribute file name to generate the context path.
* Fix bug popping ignore files during wd iterationRussell Belfer2014-04-101-1/+10
| | | | | | | | | | | | | | | There were a couple bugs in popping ignore files during iteration that could result in incorrect decisions be made and thus ignore files below the root either not being loaded correctly or not being popped at the right time. One bug was an off-by-one in comparing the path of the gitignore file with the path being exited during iteration. The second bug was not correctly truncating the path being tracked during traversal if there were no ignores on the list (i.e. when you have no .gitignore at the root, but do have some in contained directories).
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-18/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
* Further EUSER and error propagation fixesRussell Belfer2013-12-111-3/+18
| | | | | | | | | | | | | This continues auditing all the places where GIT_EUSER is being returned and making sure to clear any existing error using the new giterr_user_cancel helper. As a result, places that relied on intercepting GIT_EUSER but having the old error preserved also needed to be cleaned up to correctly stash and then retrieve the actual error. Additionally, as I encountered places where error codes were not being propagated correctly, I tried to fix them up. A number of those fixes are included in the this commit as well.
* The "common.h" should be included before "config.h".Cheng Zhao2013-10-281-0/+1
| | | | | | | | | When building libgit2 for ia32 architecture on a x64 machine, including "config.h" without a "common.h" would result the following error: C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2288): error C2373: 'InterlockedIncrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2295): error C2373: 'InterlockedDecrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2303): error C2373: 'InterlockedExchange' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2314): error C2373: 'InterlockedExchangeAdd' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
* Improve and comment git_ignore__pop_dirRussell Belfer2013-08-091-9/+19
| | | | | This just cleans up the improved logic for popping ignore dirs and documents why the complex behavior is needed.
* Improve building ignore file listsRussell Belfer2013-08-091-10/+20
| | | | | | | | | | | | | | | | | The routines to push and pop ignore files while traversing a directory had some issues. In particular, setting up the initial list would sometimes push an ignore file before it ought to be applied if the starting path was a directory containing an ignore file. Also, the pop function was not always matching the right part of the path and would fail to pop ignores from the list in some cases. This adds some tests that exercise a particular problematic case and then fixes the problems that I could find related to this. At some point, I'd like to isolate this ignore rule management code and rewrite it, but that's a larger project and right now, I'll opt to just try to fix the broken behaviors.
* Revert PR #1462 and provide alternative fixRussell Belfer2013-08-091-2/+2
| | | | | | | | | | | This rolls back the changes to fnmatch parsing from commit 2e40a60e847d6c128af23e24ea7a8efebd2427da except for the tests that were added. Instead this adds couple of new flags that can be passed in when attempting to parse an fnmatch pattern. Also, this changes the pathspec match logic to special case matching a filename with a '!' prefix against a negative pattern. This fixes the build.
* Merge pull request #1462 from yorah/fix/libgit2sharp-issue-379Russell Belfer2013-08-091-1/+1
|\ | | | | status: fix handling of filenames with special prefixes
| * status: fix handling of filenames with special prefixesyorah2013-04-151-1/+1
| | | | | | | | Fix libgit2/libgit2sharp#379
* | Add fn to check pathspec for ignored filesRussell Belfer2013-06-191-0/+58
| | | | | | | | | | | | | | | | | | Command line Git sometimes generates an error message if given a pathspec that contains an exact match to an ignored file (provided --force isn't also given). This adds an internal function that makes it easy to check it that has happened. Right now, I'm not creating a public API for this because that would get a little more complicated with a need for callbacks for all invalid paths.
* | Use config cache where possibleRussell Belfer2013-04-231-28/+10
|/ | | | | | This converts many of the config lookups that are done around the library to use the repository config cache. This was everything I could find that wasn't part of diff (which requires a larger fix).
* Implement global/system file search pathsRussell Belfer2013-03-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | The goal of this work is to expose the search logic for "global", "system", and "xdg" files through the git_libgit2_opts() interface. Behind the scenes, I changed the logic for finding files to have a notion of a git_strarray that represents a search path and to store a separate search path for each of the three tiers of config file. For each tier, I implemented a function to initialize it to default values (generally based on environment variables), and then general interfaces to get it, set it, reset it, and prepend new directories to it. Next, I exposed these interfaces through the git_libgit2_opts interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants for the user to control which search path they were modifying. There are alternative designs for the opts interface / argument ordering, so I'm putting this phase out for discussion. Additionally, I ended up doing a little bit of clean up regarding attr.h and attr_file.h, adding a new attrcache.h so the other two files wouldn't have to be included in so many places.
* Set up default internal ignoresRussell Belfer2012-11-191-13/+21
| | | | | | This adds "." ".." and ".git" to the internal ignores list by default - asking about paths with these files will always say that they are ignored.
* Fix single-file ignore checksRussell Belfer2012-10-151-4/+65
| | | | | | | | To answer if a single given file should be ignored, the path to that file has to be processed progressively checking that there are no intermediate ignored directories in getting to the file in question. This enables that, fixing the broken old behavior, and adds tests to exercise various ignore situations.
* Fix a bug where ignorecase wasn't applied to ignoresPhilip Kelley2012-10-081-4/+5
|
* Support for core.ignorecasePhilip Kelley2012-09-171-10/+43
|
* Fix crash with adding internal ignoresRussell Belfer2012-08-241-8/+12
| | | | | | Depending on what you had done before adding new items to the internal ignores list, it was possible for the cache of ignore data to be uninitialized.
* Wrap up ignore API and add testsRussell Belfer2012-08-221-0/+17
| | | | This fills out the ignore API and adds tests.
* Add public API for internal ignoresRussell Belfer2012-08-211-0/+32
| | | | | | | This creates a public API for adding to the internal ignores list, which already existing but was not accessible. This adds the new default value for core.excludesfile also.
* portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|
* Ignores allow unescapes internal whitespaceRussell Belfer2012-06-111-0/+2
|
* Fix memory leaks and use after freeRussell Belfer2012-05-041-1/+1
|
* Support reading attributes from indexRussell Belfer2012-05-031-32/+37
| | | | | | | | | | | | | | Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
* Fix leading slash behavior in attrs/ignoresRussell Belfer2012-04-261-3/+6
| | | | | | We were not following the git behavior for leading slashes in path names when matching git ignores and git attribute file patterns. This should fix issue #638.
* Convert attrs and diffs to use string poolsRussell Belfer2012-04-251-1/+3
| | | | | | | This converts the git attr related code (including ignores) and the git diff related code (and implicitly the status code) to use `git_pools` for storing strings. This reduces the number of small blocks allocated dramatically.
* Improve config handling for diff,submodules,attrsRussell Belfer2012-03-301-15/+5
| | | | | | | | This adds support for a bunch of core.* settings that affect diff and status, plus fixes up some incorrect implementations of those settings from before. Also, this cleans up the handling of config settings in the new submodules code and in the old attrs/ignore code.
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-58/+47
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Convert attr and other files to new errorsRussell Belfer2012-03-141-2/+2
| | | | | | | | This continues to add other files to the new error handling style. I think the only real concerns here are that there are a couple of error return cases that I have converted to asserts, but I think that it was the correct thing to do given the new error style.
* buffer: Unify `git_fbuffer` and `git_buf`Vicent Martí2012-02-271-3/+3
| | | | | | | | | | | | | | This makes so much sense that I can't believe it hasn't been done before. Kill the old `git_fbuffer` and read files straight into `git_buf` objects. Also: In order to fully support 4GB files in 32-bit systems, the `git_buf` implementation has been changed from using `ssize_t` for storage and storing negative values on allocation failure, to using `size_t` and changing the buffer pointer to a magical pointer on allocation failure. Hopefully this won't break anything.
* Fix iterators based on pull request feedbackRussell Belfer2012-02-221-1/+1
| | | | | | | | | | This update addresses all of the feedback in pull request #570. The biggest change was to create actual linked list stacks for storing the tree and workdir iterator state. This cleaned up the code a ton. Additionally, all of the static functions had their 'git_' prefix removed, and a lot of other unnecessary changes were removed from the original patch.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-211-31/+83
| | | | | | | | | | | | | | | This create a new git_iterator type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner.
* Fix attr path is_dir checkRussell Belfer2012-01-311-20/+23
| | | | | | | When building an attr path object, the code that checks if the file is a directory was evaluating the file as a relative path to the current working directory, instead of using the repo root. This lead to inconsistent behavior.
* Merge branch 'fix-subdir-attr-paths' into developmentRussell Belfer2012-01-201-14/+14
|\ | | | | | | This resolves issue #535 and issue #533.
| * Fix handling of relative paths for attrsRussell Belfer2012-01-161-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | Per issue #533, the handling of relative paths in attribute and ignore files was not right. Fixed this by pre-joining the relative path of the attribute/ignore file onto the match string when a full path match is required. Unfortunately, fixing this required a bit more code than I would have liked because I had to juggle things around so that the fnmatch parser would have sufficient information to prepend the relative path when it was needed.
* | Move path related functions from fileops to pathRussell Belfer2012-01-171-1/+1
|/ | | | | | | | | | | This takes all of the functions that look up simple data about paths (such as `git_futils_isdir`) and moves them over to path.h (becoming `git_path_isdir`). This leaves fileops.h just with functions that actually manipulate the filesystem or look at the file contents in some way. As part of this, the dir.h header which is really just for win32 support was moved into win32 (with some minor changes).
* Patch cleanup for mergeRussell Belfer2012-01-161-16/+1
| | | | | | | | | | After reviewing the gitignore support with Vicent, we came up with a list of minor cleanups to prepare for merge, including: * checking git_repository_config error returns * renaming git_ignore_is_ignored and moving to status.h * fixing next_line skipping to include \r skips * commenting on where ignores are and are not included
* Fix several memory issuesRussell Belfer2012-01-111-1/+3
| | | | | | | This contains fixes for several issues discovered by MSVC and by valgrind, including some bad data access, some memory leakage (in where certain files were not being successfully added to the cache), and some code simplification.
* Convert git_path_walk_up to regular functionRussell Belfer2012-01-111-6/+16
| | | | | | This gets rid of the crazy macro version of git_path_walk_up and makes it into a normal function that takes a callback parameter. This turned out not to be too messy.
* Allow ignores (and attribs) for nonexistent filesRussell Belfer2012-01-111-0/+14
| | | | | | This fixes issue 532 that attributes (and gitignores) could not be checked for files that don't exist. It should be possible to query such things regardless of the existence of the file.
* Initial implementation of gitignore supportRussell Belfer2012-01-111-0/+148
Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).