summaryrefslogtreecommitdiff
path: root/src/attr_file.c
Commit message (Collapse)AuthorAgeFilesLines
* Minor fixesRussell Belfer2014-04-181-1/+2
| | | | | | | | Only apply LEADING_DIR pattern munging to patterns in ignore and attribute files, not to pathspecs used to select files to operate on. Also, allow internal macro definitions to be evaluated before loading all external ones (important so that external ones can make use of internal `binary` definition).
* Fix ignore difference from git with trailing /*Russell Belfer2014-04-181-0/+9
| | | | | | | | | Ignore patterns that ended with a trailing '/*' were still needing to match against another actual '/' character in the full path. This is not the same behavior as core Git. Instead, we strip a trailing '/*' off of any patterns that were matching and just take it to imply the FNM_LEADING_DIR behavior.
* Preload attribute files that may contain macrosRussell Belfer2014-04-181-3/+1
| | | | | | | | | There was a latent bug where files that use macro definitions could be parsed before the macro definitions were loaded. Because of attribute file caching, preloading files that are going to be used doesn't add a significant amount of overhead, so let's always preload any files that could contain macros before we assemble the actual vector of files to scan for attributes.
* Fix broken logic for attr cache invalidationRussell Belfer2014-04-171-37/+78
| | | | | | | 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-2/+29
| | | | | | | | | 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-3/+1
|
* Attribute file cache refactorRussell Belfer2014-04-171-128/+198
| | | | | | | 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.
* Add diff threading tests and attr file cache locksRussell Belfer2014-04-171-4/+9
| | | | | | This adds a basic test of doing simultaneous diffs on multiple threads and adds basic locking for the attr file cache because that was the immediate problem that arose from these tests.
* Fix core.excludesfile named .gitignorerb/fix-leading-slash-ignoresRussell Belfer2014-04-141-10/+8
| | | | | | | | | | | | | | | | | 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 warningLinquize2013-09-191-1/+1
|
* Revert PR #1462 and provide alternative fixRussell Belfer2013-08-091-42/+19
| | | | | | | | | | | 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-10/+37
|\ | | | | status: fix handling of filenames with special prefixes
| * status: fix handling of filenames with special prefixesyorah2013-04-151-10/+37
| | | | | | | | Fix libgit2/libgit2sharp#379
* | Add status flags to force output sort orderRussell Belfer2013-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Files in status will, be default, be sorted according to the case insensitivity of the filesystem that we're running on. However, in some cases, this is not desirable. Even on case insensitive file systems, 'git status' at the command line will generally use a case sensitive sort (like 'ls'). Some GUIs prefer to display a list of file case insensitively even on case-sensitive platforms. This adds two new flags: GIT_STATUS_OPT_SORT_CASE_SENSITIVELY and GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY that will override the default sort order of the status output and give the user control. This includes tests for exercising these new options and makes the examples/status.c program emulate core Git and always use a case sensitive sort.
* | allow (ignore) bare slash in gitignoreEdward Thomson2013-05-291-1/+2
|/
* Notify '*' pathspec correctly when diffingyorah2013-04-111-1/+23
| | | | I also moved all tests related to notifying in their own file.
* Implement global/system file search pathsRussell Belfer2013-03-151-0/+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.
* Vector improvements and their falloutPhilip Kelley2013-01-271-5/+6
|
* Minor fixes for ignorecase supportPhilip Kelley2012-09-171-0/+2
|
* Support for core.ignorecasePhilip Kelley2012-09-171-5/+6
|
* Add template dir and set gid to repo initRussell Belfer2012-08-221-9/+6
| | | | | | | | | | | | | | | | | This extends git_repository_init_ext further with support for initializing the repository from an external template directory and with support for the "create shared" type flags that make a set GID repository directory. This also adds tests for much of the new functionality to the existing `repo/init.c` test suite. Also, this adds a bunch of new utility functions including a very general purpose `git_futils_mkdir` (with the ability to make paths and to chmod the paths post-creation) and a file tree copying function `git_futils_cp_r`. Also, this includes some new path functions that were useful to keep the code simple.
* Merge remote-tracking branch 'nulltoken/topic/amd64-compat' into developmentVicent Marti2012-08-021-1/+1
|\ | | | | | | | | | | | | Conflicts: src/netops.c src/netops.h src/oid.c
| * portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
| |
* | attr: Do not export variables externallyattr-exportVicent Marti2012-08-021-8/+4
| | | | | | | | | | | | | | | | | | | | Fixes #824 Exporting variables in a dynamic library is a PITA. Let's keep these values internally and wrap them through a helper method. This doesn't break the external API. @arrbee, aren't you glad I turned the `GIT_ATTR_` macros into function macros? :sparkles:
* | Add git_buf_unescape and git__unescape to unescape all characters in a ↵yorah2012-07-241-11/+1
|/ | | | string (in-place)
* attr: Rename the `git_attr__` exportsVicent Marti2012-07-151-7/+7
| | | | | | | Pevents collisions with the original libgit, which also exports those exact symbols. Fixes #822
* Fix bugs for status with spaces and reloaded attrsRussell Belfer2012-05-241-9/+17
| | | | | | | | | | | | | | | | | | | | | | This fixes two bugs: * Issue #728 where git_status_file was not working for files that contain spaces. This was caused by reusing the "fnmatch" parsing code from ignore and attribute files to interpret the "pathspec" that constrained the files to apply the status to. In that code, unescaped whitespace was considered terminal to the pattern, so a file with internal whitespace was excluded from the matched files. The fix was to add a mode to that code that allows spaces and tabs inside patterns. This mode only comes into play when parsing in-memory strings. * The other issue was undetected, but it was in the recently added code to reload gitattributes / gitignores when they were changed on disk. That code was not clearing out the old values from the cached file content before reparsing which meant that newly added patterns would be read in, but deleted patterns would not be removed. The fix was to clear the vector of patterns in a cached file before reparsing the file.
* Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
* Fix 64-bit build warningRussell Belfer2012-05-091-1/+1
|
* msvc: Do not use `isspace` Vicent Martí2012-05-091-6/+6
| | | | Locale-aware bullshit bitting my ass again yo
* Support reading attributes from indexRussell Belfer2012-05-031-46/+44
| | | | | | | | | | | | | | 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 Win32 warningsRussell Belfer2012-04-261-1/+2
|
* Fix leading slash behavior in attrs/ignoresRussell Belfer2012-04-261-13/+38
| | | | | | 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 hashtable usage over to khashRussell Belfer2012-04-251-2/+2
| | | | | | | | | | | | | | | This updates khash.h with some extra features (like error checking on allocations, ability to use wrapped malloc, foreach calls, etc), creates two high-level wrappers around khash: `git_khash_str` and `git_khash_oid` for string-to-void-ptr and oid-to-void-ptr tables, then converts all of the old usage of `git_hashtable` over to use these new hashtables. For `git_khash_str`, I've tried to create a set of macros that yield an API not too unlike the old `git_hashtable` API. Since the oid hashtable is only used in one file, I haven't bother to set up all those macros and just use the khash APIs directly for now.
* Convert attrs and diffs to use string poolsRussell Belfer2012-04-251-23/+39
| | | | | | | 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.
* Add support for pathspec to diff and statusRussell Belfer2012-04-131-0/+4
| | | | | | | This adds preliminary support for pathspecs to diff and status. The implementation is not very optimized (it still looks at every single file and evaluated the the pathspec match against them), but it works.
* Improve config handling for diff,submodules,attrsRussell Belfer2012-03-301-2/+2
| | | | | | | | 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-1/+1
| | | | | 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-11/+11
| | | | | | | | 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.
* Migrating diff to new error handlingRussell Belfer2012-03-061-62/+37
| | | | | | Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
* error-handling: ReferencesVicent Martí2012-03-061-2/+3
| | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
* attr: Change the attribute check macrosVicent Martí2012-03-021-3/+3
| | | | | | | | | | | | | | | | | | | | | The point of having `GIT_ATTR_TRUE` and `GIT_ATTR_FALSE` macros is to be able to change the way that true and false values are stored inside of the returned gitattributes value pointer. However, if these macros are implemented as a simple rename for the `git_attr__true` pointer, they will always be used with the `==` operator, and hence we cannot really change the implementation to any other way that doesn't imply using special pointer values and comparing them! We need to do the same thing that core Git does, which is using a function macro. With `GIT_ATTR_TRUE(attr)`, we can change internally the way that these values are stored to anything we want. This commit does that, and rewrites a large chunk of the attributes test suite to remove duplicated code for expected attributes, and to properly test the function macro behavior instead of comparing pointers.
* 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 issue with ignoring whole directoriesRussell Belfer2012-01-311-0/+2
| | | | | | Now that is_dir is calculated correctly for attr/ignore paths, it is possible to use it so that ignoring "dir/" will properly match the directory name and ignore the entire directory.
* Fix attr path is_dir checkRussell Belfer2012-01-311-1/+11
| | | | | | | 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-42/+81
|\ | | | | | | This resolves issue #535 and issue #533.
| * Remove poor git__removechar functionRussell Belfer2012-01-161-2/+12
| | | | | | | | | | | | | | | | | | | | Going back over this, the git__removechar function was not needed (only invoked once) and is actually mislabeled. As implemented, it really only made sense for removing backslash characters, since two of the "removed" characters in a row would include the second one -- i.e. it really implements stripping backslash-escaped strings where a backslash allows internal whitespace in a word.
| * Fix handling of relative paths for attrsRussell Belfer2012-01-161-42/+71
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* Initial implementation of gitignore supportRussell Belfer2012-01-111-52/+54
| | | | | | | | 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).