summaryrefslogtreecommitdiff
path: root/src/tree.c
Commit message (Collapse)AuthorAgeFilesLines
* Convert pqueue to just be a git_vectorRussell Belfer2014-02-041-2/+4
| | | | | | | | | | | | | 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.
* tree: remove legacy 'oid' namingCarlos Martín Nieto2014-01-251-3/+3
| | | | Rename git_tree_entry_byoid() to _byid() as per the convention.
* index: rename an entry's id to 'id'Carlos Martín Nieto2014-01-251-1/+1
| | | | This was not converted when we converted the rest, so do it now.
* Align git_tree_entry_dup.Arthur Schreiber2014-01-141-9/+8
|
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-5/+11
|
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+4
| | | | | | | | | | | | | 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.
* tree: allow retrieval of raw attributesCarlos Martín Nieto2013-10-081-3/+6
| | | | | | When a tool needs to recreate the tree object (for example an interface to another VCS), it needs to use the raw attributes, forgoing any normalization.
* Fix memory leak in git_tree_walk on error or when stopping the walk from the ↵wilke2013-09-131-1/+2
| | | | supplied callback
* Prevent git_tree_walk 'skip entry' callback return code from leaking through ↵wilke2013-09-131-1/+3
| | | | as the return value of git_tree_walk
* Better macro name for is-exec-bit-set testRussell Belfer2013-09-051-1/+1
|
* Add more file mode permissions macrosRussell Belfer2013-09-051-6/+6
| | | | | | 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.
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+3
| | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* Add cat-file example and increase const use in APIRussell Belfer2013-05-161-8/+15
| | | | | | | | | | | | | | | | This adds an example implementation that emulates git cat-file. It is a convenient and relatively simple example of getting data out of a repository. Implementing this also revealed that there are a number of APIs that are still not using const pointers to objects that really ought to be. The main cause of this is that `git_vector_bsearch` may need to call `git_vector_sort` before doing the search, so a const pointer to the vector is not allowed. However, for tree objects, with a little care, we can ensure that the vector of tree entries is always sorted and allow lookups to take a const pointer. Also, the missing const in commit objects just looks like an oversight.
* clarify error propogationRussell Belfer2013-05-011-1/+1
|
* object: Explicitly define helper API methods for all obj typesVicent Marti2013-04-301-2/+0
|
* Some cleanupsRussell Belfer2013-04-291-1/+1
| | | | | Removed useless prototype and renamed object typecast functions declaration macro.
* Standardize cast versions of git_object accessorsRussell Belfer2013-04-291-10/+2
| | | | | | This removes the GIT_INLINE versions of the simple git_object accessors and standardizes them with a helper macro in src/object.h to build the function bodies.
* clean up tree pointer castingRussell Belfer2013-04-221-8/+8
|
* Simplify object table parse functionsRussell Belfer2013-04-221-1/+3
| | | | | This unifies the object parse functions into one signature that takes an odb_object.
* Add callback to git_objects_tableRussell Belfer2013-04-221-18/+9
| | | | | | | | | | This adds create and free callback to the git_objects_table so that more of the creation and destruction of objects can be table driven instead of using switch statements. This also makes the semantics of certain object creation functions consistent so that we can make better use of function pointers. This also fixes a theoretical error case where an object allocation fails and we end up storing NULL into the cache.
* Use git_odb_object_data/_size whereever possibleRussell Belfer2013-04-221-5/+9
| | | | | This uses the odb object accessors so we can change the internals more easily...
* What has science done.Vicent Marti2013-04-221-1/+3
|
* treebuilder: don't overwrite the error messageCarlos Martín Nieto2013-04-181-1/+0
|
* Improved tree iterator internalsRussell Belfer2013-03-141-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | This updates the tree iterator internals to be more efficient. The tree_iterator_entry objects are now kept as pointers that are allocated from a git_pool, so that we may use git__tsort_r for sorting (which is better than qsort, given that the tree is likely mostly ordered already). Those tree_iterator_entry objects now keep direct pointers to the data they refer to instead of keeping indirect index values. This simplifies a lot of the data structure traversal code. This also adds bsearch to find the start item position for range- limited tree iterators, and is more explicit about using git_path_cmp instead of reimplementing it. The git_path_cmp changed a bit to make it easier for tree_iterators to use it (but it was barely being used previously, so not a big deal). This adds a git_pool_free_array function that efficiently frees a list of pool allocated pointers (which the tree_iterator keeps). Also, added new tests for the git_pool free list functionality that was not previously being tested (or used).
* Rename function to __ prefixPhilip Kelley2013-03-011-3/+3
|
* Disable ignore_case when writing the index to a treePhilip Kelley2013-03-011-1/+15
|
* Some code cleanups in tree.cRussell Belfer2013-02-201-54/+44
| | | | | | | This replaces most of the explicit vector iteration with calls to git_vector_foreach, adds in some git__free and giterr_clear calls to clean up during some error paths, and a couple of other code simplifications.
* Store treebuilder length separately from entries vecRussell Belfer2013-02-201-3/+12
| | | | | | | The treebuilder entries vector flags removed items which means we can't rely on the entries vector length to accurately get the number of entries. This adds an entrycount value and maintains it while updating the treebuilder entries.
* Fix MSVC compilation warningsnulltoken2013-02-051-1/+1
| | | | Fix #1308
* Merge pull request #1285 from phkelley/vectorRussell Belfer2013-01-291-32/+38
|\ | | | | Vector improvements and their fallout
| * Vector improvements and their falloutPhilip Kelley2013-01-271-32/+38
| |
* | Added git_treebuilder_entrycountJohn Wiegley2013-01-281-0/+6
|/ | | | | Conflicts: src/tree.c
* Add git_tree_entry_cmp and git_tree_entry_icmpRussell Belfer2013-01-151-6/+15
| | | | | | | This adds a new external API git_tree_entry_cmp and a new internal API git_tree_entry_icmp for sorting tree entries. The case insensitive one is internal only because general users should never be seeing case-insensitively sorted trees.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix iterator reset and add reset rangesRussell Belfer2012-12-101-0/+3
| | | | | | | The `git_iterator_reset` command has not been working in all cases particularly when there is a start and end range. This fixes it and adds tests for it, and also extends it with the ability to update the start/end range strings when an iterator is reset.
* Clean up iterator APIsRussell Belfer2012-12-101-2/+7
| | | | | | | | This removes the need to explicitly pass the repo into iterators where the repo is implied by the other parameters. This moves the repo to be owned by the parent struct. Also, this has some iterator related updates to the internal diff API to lay the groundwork for checkout improvements.
* tree: relax the filemode parserCarlos Martín Nieto2012-12-071-19/+26
| | | | | | | | | | | There are many different broken filemodes in the wild so we need to protect against them and give something useful up the chain. Don't fail when reading a tree from the ODB but normalize the mode as best we can. As 664 is no longer a mode that we consider to be valid and gets normalized to 644, we can stop accepting it in the treebuilder. The library won't expose it to the user, so any invalid modes are a bug.
* Merge pull request #1090 from arrbee/ignore-invalid-by-defaultVicent Martí2012-11-291-19/+23
|\ | | | | Ignore invalid entries by default
| * Minor optimization to tree entry validity checkRussell Belfer2012-11-191-19/+23
| | | | | | | | | | | | | | | | | | | | This checks for a leading '.' before looking for the invalid tree entry names. Even on pretty high levels of optimization, this seems to make a measurable improvement. I accidentally used && in the check initially instead of || and while debugging ended up improving the error reporting of issues with adding tree entries. I thought I'd leave those changes, too.
* | Fix warnings on Win64 buildRussell Belfer2012-11-271-11/+7
| |
* | Fix up some missing consts in tree & indexRussell Belfer2012-11-271-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some missed places where we can apply const-ness to various public APIs. There are still some index and tree APIs that cannot take const pointers because we sort our `git_vectors` lazily and so we can't reliably bsearch the index and tree content without applying a `git_vector_sort()` first. This also fixes some missed places where size_t can be used and where const can be applied to a couple internal functions.
* | API updates for index.hBen Straub2012-11-271-4/+4
| |
* | API review / update for tree.hRussell Belfer2012-11-271-13/+21
|/
* Catch invalid filenames in append_entry()Scott J. Goldman2012-11-181-0/+3
| | | | | This prevents the index api from calling write_tree() with a bogus tree.
* Prevent creating `..`, `.`, and `.git` with tree builderScott J. Goldman2012-11-181-1/+3
| | | | As per core git.
* index: prevent tree creation from a non merged statenulltoken2012-11-091-0/+6
| | | | Fix libgit2/libgit2sharp#243
* index: Fix testsVicent Marti2012-11-011-1/+0
|
* index: Add git_index_write_treeVicent Marti2012-11-011-6/+2
|
* index refactoringEdward Thomson2012-10-291-2/+2
|