summaryrefslogtreecommitdiff
path: root/src/index.c
Commit message (Collapse)AuthorAgeFilesLines
* Lay groundwork for updating stat cache in diffRussell Belfer2014-04-281-4/+2
| | | | | | | | | | | This reorganized the diff OID calculation to make it easier to correctly update the stat cache during a diff once the flags to do so are enabled. This includes marking the path of a git_index_entry as const so we can make a "fake" git_index_entry with a "const char *" path and not get warnings. I was a little surprised at how unobtrusive this change was, but I think it's probably a good thing.
* Fix some coverity-found issuesRussell Belfer2014-04-211-2/+3
|
* Fix race checking for existing index itemsRussell Belfer2014-04-171-20/+32
| | | | | | | In the threading tests, I was still seeing a race condition where the same item could end up being inserted multiple times into the index. Preserving the sorted-ness of the index outside of the `index_insert` call fixes the issue.
* Attribute file cache refactorRussell Belfer2014-04-171-5/+12
| | | | | | | 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 in git_index_conflict_cleanupRussell Belfer2014-04-171-22/+10
| | | | | | | | | | | | | I introduced a leak into conflict cleanup by removing items from inside the git_vector_remove_matching call. This simplifies the code to just use one common way for the two conflict cleanup APIs. When an index has an active snapshot, removing an item can cause an error (inserting into the deferred deletion vector), so I made the git_index_conflict_cleanup API return an error code. I felt like this wasn't so bad since it is just like the other APIs. I fixed up a couple of comments while I was changing the header.
* Clean up index snapshot function namingRussell Belfer2014-04-171-39/+47
| | | | | Clear up some of the various "find" functions and the snapshot API naming to be things I like more.
* Index locking and entry allocation changesRussell Belfer2014-04-171-164/+205
| | | | | | | | | | | | | | | | | This makes the lock management on the index a little bit broader, having a number of routines hold the lock across looking up the item to be modified and actually making the modification. Still not true thread safety, but more pure index modifications are now safe which allows the simple cases (such as starting up a diff while index modifications are underway) safe enough to get the snapshot without hitting allocation problems. As part of this, I simplified the allocation of index entries to use a flex array and just put the path at the end of the index entry. This makes every entry self-contained and makes it a little easier to feel sure that pointers to strings aren't being accidentally copied and freed while other references are still being held.
* Decouple index iterator sort from indexRussell Belfer2014-04-171-46/+27
| | | | | | | | This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the index data itself. To take advantage of this, I had to export a number of the internal index entry comparison functions. I also wrote some new tests to exercise the capability.
* Add mutex around index entries changesRussell Belfer2014-04-171-61/+164
| | | | | This surrounds any function that mutates the entries vector with a mutex so it can be safely snapshotted.
* Add index snapshot and use it for iteratorRussell Belfer2014-04-171-9/+33
|
* Some index internals refactoringRussell Belfer2014-04-171-165/+193
| | | | | | | | Again, laying groundwork for some index iterator changes, this contains a bunch of code refactorings for index internals that should make it easier down the line to add locking around index modifications. Also this removes the redundant prefix_position function and fixes some potential memory leaks.
* Some vector utility tweaksRussell Belfer2014-04-171-2/+5
| | | | | This is just laying some groundwork for internal index changes that I'm working on.
* Merge pull request #2215 from libgit2/rb/submodule-cache-fixesVicent Marti2014-04-041-0/+12
|\ | | | | Improve submodule cache management
| * More tests and fix submodule index refreshRussell Belfer2014-04-011-1/+3
| | | | | | | | | | | | | | | | | | | | There was a little bug where the submodule cache thought that the index date was out of date even when it wasn't that was resulting in some extra scans of index data even when not needed. Mostly this commit adds a bunch of new tests including adding and removing submodules in the index and in the HEAD and seeing if we can automatically pick them up when refreshing.
| * Make submodule refresh a bit smarterRussell Belfer2014-04-011-0/+10
| | | | | | | | | | | | This makes submodule cache refresh actually look at the timestamps from the data sources for submodules and reload as needed if they have changed since the last refresh.
* | Const correctness!Jacques Germishuys2014-04-031-1/+1
|/
* Introduce git_merge_file for consumersEdward Thomson2014-03-201-4/+4
|
* corrected typo in error messageBrendan Forster2014-03-101-1/+1
|
* Prevent icc warningBen Straub2014-02-241-1/+3
|
* Address PR commentsRussell Belfer2014-02-201-2/+2
| | | | | | | * Make GIT_INLINE an internal definition so it cannot be used in public headers * Fix language in CONTRIBUTING * Make index caps API use signed instead of unsigned values
* Fix some Windows warningsRussell Belfer2014-02-071-15/+14
| | | | | | This fixes a number of warnings with the Windows 64-bit build including a test failure in test_repo_message__message where an invalid pointer to a git_buf was being used.
* Fix typo setting sorted flag when reloading indexRussell Belfer2014-02-041-2/+4
| | | | | | | This fixes a typo I made for setting the sorted flag on the index after a reload. That typo didn't actually cause any test failures so I'm also adding a test that explicitly checks that the index is correctly sorted after a reload when ignoring case and when not.
* Convert pqueue to just be a git_vectorRussell Belfer2014-02-041-3/+3
| | | | | | | | | | | | | This updates the git_pqueue to simply be a set of specialized init/insert/pop functions on a git_vector. To preserve the pqueue feature of having a fixed size heap, I converted the "sorted" field in git_vectors to a more general "flags" field so that pqueue could mix in it's own flag. This had a bunch of ramifications because a number of places were directly looking at the vector "sorted" field - I added a couple new git_vector helpers (is_sorted, set_sorted) so the specific representation of this information could be abstracted.
* Rename conflict to collision to prevent confusionRussell Belfer2014-01-301-2/+2
|
* Give index_isrch the same semantics as index_srchEdward Thomson2014-01-291-5/+16
| | | | | | In case insensitive index mode, we would stop at a prefixed entry, treating the provided search key length as a substring, not the length of the string to match.
* index: Implement folder-file checksVicent Marti2014-01-291-52/+50
|
* index: Compare with given lenVicent Marti2014-01-291-11/+125
|
* index: rename an entry's id to 'id'Carlos Martín Nieto2014-01-251-9/+9
| | | | This was not converted when we converted the rest, so do it now.
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-6/+14
|
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+8
| | | | | | | | | | | | | 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.
* index: Free the index on git_index_open() failurenulltoken2013-11-191-1/+7
|
* move mode_t to filebuf_open instead of _commitEdward Thomson2013-11-041-2/+2
|
* Convert git_index_read to have a "force" flagRussell Belfer2013-11-011-4/+4
| | | | | This is a little more intuitive than the turned-around option that I originally wrote.
* Make diff and status perform soft index reloadRussell Belfer2013-11-011-5/+6
| | | | | | | | | | | | | | | | | | | | | This changes `git_index_read` to have two modes - a hard index reload that always resets the index to match the on-disk data (which was the old behavior) and a soft index reload that uses the timestamp / file size information and only replaces the index data if the file on disk has been modified. This then updates the git_status code to do a soft reload unless the new GIT_STATUS_OPT_NO_REFRESH flag is passed in. This also changes the behavior of the git_diff functions that use the index so that when an index is not explicitly passed in (i.e. when the functions call git_repository_index for you), they will also do a soft reload for you. This intentionally breaks the file signature of git_index_read because there has been some confusion about the behavior previously and it seems like all existing uses of the API should probably be examined to select the desired behavior.
* Merge pull request #1886 from libgit2/precompose-utf8Vicent Martí2013-10-081-3/+5
|\ | | | | Add support for core.precomposeunicode on Mac
| * More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This cleans up some additional issues. The main change is that on a filesystem that doesn't support mode bits, libgit2 will now create new blobs with GIT_FILEMODE_BLOB always instead of being at the mercy to the filesystem driver to report executable or not. This means that if "core.filemode" lies and claims that filemode is not supported, then we will ignore the executable bit from the filesystem. Previously we would have allowed it. This adds an option to the new git_repository_reset_filesystem to recurse through submodules if desired. There may be other types of APIs that would like a "recurse submodules" option, but this one is particularly useful. This also has a number of cleanups, etc., for related things including trying to give better error messages when problems come up from the filesystem. For example, the FAT filesystem driver on MacOS appears to return errno EINVAL if you attempt to write a filename with invalid UTF-8 in it. We try to capture that with a better error message now.
* | index: Make _read() cope with index file creationnulltoken2013-10-041-2/+3
|/
* Clean up newly introduced warningsRussell Belfer2013-09-231-1/+1
| | | | | | | | | | The attempt to "clean up warnings" seems to have introduced some new warnings on compliant compilers. This fixes those in a way that I suspect will also be okay for the non-compliant compilers. Also this fixes what appears to be an extra semicolon in the repo initialization template dir handling (and as part of that fix, handles the case where an error occurs correctly).
* Fix warningLinquize2013-09-191-5/+5
|
* Add more file mode permissions macrosRussell Belfer2013-09-051-1/+1
| | | | | | This adds some more macros for some standard operations on file modes, particularly related to permissions, and then updates a number of places around the code base to use the new macros.
* index: report when it's lockedCarlos Martín Nieto2013-08-191-1/+5
| | | | | | | Report the index being locked with its own error code in order to be able to differentiate, as a locked index is typically the result of a crashed process or concurrent access, both of which often require user intervention to fix.
* Fixes to safely reading the indexEdward Thomson2013-08-081-3/+4
| | | | | Avoid wrapping around extension size when reading, avoid walking off the end of the buffer when reading names.
* Fix rename detection to use actual blob sizeRussell Belfer2013-07-251-26/+8
| | | | | | | | | | | | | | | | | | The size data in the index may not reflect the actual size of the blob data from the ODB when content filtering comes into play. This commit fixes rename detection to use the actual blob size when calculating data signatures instead of the value from the index. Because of a misunderstanding on my part, I first converted the git_index_add_bypath API to use the post-filtered blob data size in creating the index entry. I backed that change out, but I kept the overall refactoring of that routine and the new internal git_blob__create_from_paths API because it eliminates an extra stat() call from the code that adds a file to the index. The existing tests actually cover this code path, at least when running on Windows, so at this point I'm not adding new tests to cover the changes.
* index: fix potential memory leaksRémi Duraffort2013-07-151-3/+9
|
* Add API to get path to index fileRussell Belfer2013-07-101-0/+6
|
* Add public API for pathspec matchingRussell Belfer2013-07-101-20/+22
| | | | | | | | | | | | | | | This adds a new public API for compiling pathspecs and matching them against the working directory, the index, or a tree from the repository. This also reworks the pathspec internals to allow the sharing of code between the existing internal usage of pathspec matching and the new external API. While this is working and the new API is ready for discussion, I think there is still an incorrect behavior in which patterns are always matched against the full path of an entry without taking the subdirectories into account (so "s*" will match "subdir/file" even though it wouldn't with core Git). Further enhancements are coming, but this was a good place to take a functional snapshot.
* Be more thread aware with some index updatesRussell Belfer2013-07-031-40/+34
| | | | | | | | The index isn't really thread safe for the most part, but we can easily be more careful and avoid double frees and the like, which are serious problems (as opposed to a lookup which might return the incorrect value but if the index in being updated, that is much harder to avoid).
* Add status flags to force output sort orderRussell Belfer2013-06-201-5/+5
| | | | | | | | | | | | | | | | 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.
* Add tests and fix use of freed memoryRussell Belfer2013-06-191-3/+9
| | | | | | | | | | | This adds some tests for updating the index and having it remove items to make sure that the iteration over the index still works even as earlier items are removed. In testing with valgrind, this found a path that would use the path string from the index entry after it had been freed. The bug fix is simply to copy the path of the index entry before doing any actual index manipulation.