summaryrefslogtreecommitdiff
path: root/src/index.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Add index pathspec-based operationsRussell Belfer2013-06-191-2/+213
| | | | | | | | | | | | | This adds three new public APIs for manipulating the index: 1. `git_index_add_all` is similar to `git add -A` and will add files in the working directory that match a pathspec to the index while honoring ignores, etc. 2. `git_index_remove_all` removes files from the index that match a pathspec. 3. `git_index_update_all` updates entries in the index based on the current contents of the working directory, either added the new information or removing the entry from the index.
* Make index_insert keep existing caseRussell Belfer2013-06-171-2/+3
| | | | | | | | In a case insensitive index, if you attempt to add a file from disk with a different case pattern, the old case pattern in the index should be preserved. This fixes that (and a couple of minor warnings).
* util: It's called `memzero`Vicent Marti2013-06-121-1/+1
|
* Merge remote-tracking branch 'arrbee/minor-paranoia' into developmentVicent Marti2013-06-121-0/+2
|\
| * Add safe memset and use itRussell Belfer2013-06-071-1/+1
| | | | | | | | | | | | This adds a `git__memset` routine that will not be optimized away and updates the places where I memset() right before a free() call to use it.
| * Zero memory for major objects before freeingRussell Belfer2013-05-311-0/+2
| | | | | | | | | | | | | | By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
* | Fix some memory leaksRussell Belfer2013-06-101-0/+2
| |
* | Make git_index_read_tree preserve stat cacheRussell Belfer2013-05-311-14/+54
|/ | | | | | | | Instead of just blowing away the stat cache data when loading a new tree into the index, this checks if each loaded item has a corresponding existing item with the same OID and if so, copies the stat data from the old item to the new one so it will not be blown away.
* improve test for index extension truncationEdward Thomson2013-05-311-2/+3
|
* Ensure reuc vector is always validRussell Belfer2013-05-241-6/+8
| | | | | | | | | In theory, if there was a problem reading the REUC data, the read_reuc() routine could have left uninitialized and invalid data in the git_index vector. This moves the line that inserts a new entry into the vector down to the bottom of the routine so we know all the content is already valid. Also, per @linquize, this uses calloc to ensure no uninitialized data.
* introduce git_conflict_iteratorEdward Thomson2013-05-171-30/+118
|
* Ensure reuc vector is always validRussell Belfer2013-05-161-6/+8
| | | | | | | | | In theory, if there was a problem reading the REUC data, the read_reuc() routine could have left uninitialized and invalid data in the git_index vector. This moves the line that inserts a new entry into the vector down to the bottom of the routine so we know all the content is already valid. Also, per @linquize, this uses calloc to ensure no uninitialized data.
* Merge pull request #1588 from arrbee/fixes-for-checkout-and-diffVicent Martí2013-05-151-16/+11
|\ | | | | Bug fixes for checkout and diff
| * Use GIT_IDXENTRY_STAGE macroRussell Belfer2013-05-151-16/+11
| | | | | | | | | | | | Since I added the GIT_IDXENTRY_STAGE macro to extract the stage from a git_index_entry, we probably don't need an internal inline function to do the same thing.
| * Fix checkout of submodules with no .gitmodulesRussell Belfer2013-05-151-1/+1
| | | | | | | | | | | | | | | | | | It is possible for there to be a submodule in a repository with no .gitmodules file (for example, if the user forgot to commit the .gitmodules file). In this case, core Git will just create an empty directory as a placeholder for the submodule but otherwise ignore it. We were generating an error and stopping the checkout. This makes our behavior match that of core git.
* | Fix trailing whitespacesnulltoken2013-05-151-19/+19
|/
* Merge pull request #1526 from arrbee/cleanup-error-return-without-msgVicent Martí2013-05-061-2/+7
|\ | | | | Make sure error messages are set for most error returns