summaryrefslogtreecommitdiff
path: root/src/revwalk.c
Commit message (Collapse)AuthorAgeFilesLines
...
* really reset walker with git_revwalk_resetNico von Geyso2012-05-151-0/+3
| | | | | | | | From the description of git_revwalk_reset in revwalk.h the function should clear all pushed and hidden commits, and leave the walker in a blank state (just like at creation). Apparently everything gets reseted appart of pushed commits (walk->one and walk->twos) This fix should reset the walker properly.
* Remove old and unused error codesVicent Martí2012-05-021-1/+1
|
* Fix Win32 warningsRussell Belfer2012-04-261-1/+1
|
* Merge pull request #642 from arrbee/mem-poolsRussell Belfer2012-04-251-73/+32
|\ | | | | Memory pools and khash hashtables
| * Rename git_khash_str to git_strmap, etc.Russell Belfer2012-04-251-5/+5
| | | | | | | | | | | | This renamed `git_khash_str` to `git_strmap`, `git_hash_oid` to `git_oidmap`, and deletes `git_hashtable` from the tree, plus adds unit tests for `git_strmap`.
| * Convert hashtable usage over to khashRussell Belfer2012-04-251-21/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 revwalk to use git_poolRussell Belfer2012-04-251-53/+16
| | | | | | | | | | This removes the custom paged allocator from revwalk and replaces it with a `git_pool`.
* | revwalk: return GIT_EREVWALKER earlier if no references were pushedCarlos Martín Nieto2012-04-251-0/+7
|/ | | | | In the case that walk->one is NULL, we know that we have no positive references, so we already know that the revwalk is over.
* Rename to git_reference_name_to_oidRussell Belfer2012-04-231-1/+1
|
* Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-39/+36
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* Add git_reference_lookup_oid and lookup_resolvedRussell Belfer2012-04-171-12/+3
| | | | | | | | | | | | | | Adds a new public reference function `git_reference_lookup_oid` that directly resolved a reference name to an OID without returning the intermediate `git_reference` object (hence, no free needed). Internally, this adds a `git_reference_lookup_resolved` function that combines looking up and resolving a reference. This allows us to be more efficient with memory reallocation. The existing `git_reference_lookup` and `git_reference_resolve` are reimplmented on top of the new utility and a few places in the code are changed to use one of the two new functions.
* error-handling: revwalkCarlos Martín Nieto2012-04-121-100/+104
|
* Move git_merge_base() to is own header and document itCarlos Martín Nieto2012-04-121-0/+1
|
* revwalk: use a priority queue for calculating merge basesCarlos Martín Nieto2012-04-121-37/+36
| | | | | | | | | As parents are older than their children, we're appending to the commit list most of the time, which makes an ordered linked list quite inefficient. While we're there, don't sort the results list in the main loop, as we're sorting them afterwards and it creates extra work.
* revwalk: use merge bases to speed up processingCarlos Martín Nieto2012-04-121-2/+39
| | | | | | | There is no need walk down the parents of a merge base to mark them as uninteresting because we'll never see them. Calculate the merge bases in prepare_walk() so mark_uninteresting() can stop at a merge base instead of walking all the way to the root.
* Implement git_merge_base()Carlos Martín Nieto2012-04-121-9/+167
| | | | | | It's implemented in revwalk.c so it has access to the revision walker's commit cache and related functions. The algorithm is the one used by git, modified so it fits better with the library's functions.
* revwalk: allow pushing/hiding a reference by nameCarlos Martín Nieto2012-04-121-38/+33
| | | | | | The code was already there, so factor it out and let users push an OID by giving it a reference name. Only refs to commits are supported. Annotated tags will throw an error.
* revwalk: don't assume malloc succeedsCarlos Martín Nieto2012-04-121-3/+9
|
* Clean up GIT_UNUSED macros on all platformsRussell Belfer2012-03-021-4/+2
| | | | | | | | | | | | | | | | | | | It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
* revwalk: add convenience function to push/hide HEADCarlos Martín Nieto2012-02-271-0/+33
| | | | | | It's not unusual to want the walker to act on HEAD, so add a convencience function for the case that the user doesn't already have a resolved HEAD reference.
* revwalk: introduce pushing and hiding by globCarlos Martín Nieto2012-02-271-0/+87
| | | | | | | git_revwalk_{push,hide}_glob() lets you push the OIDs of references that match the specified glob. This is the basics for what git.git does with the rev-list options --branches, --tags, --remotes and --glob.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* revwalk: unmark commits as uninteresting on resetCarlos Martín Nieto2012-02-071-0/+1
| | | | Not doing so hides commits we want to get at during a second walk.
* Rename all `_close` methodsVicent Marti2011-11-261-2/+2
| | | | | There's no difference between `_free` and `_close` semantics: keep everything with the same name to avoid confusions.
* repository: Change ownership semanticsVicent Marti2011-11-261-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-7/+7
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* config: make git_config_[get|set]_long() able to properly deal with 8 bytes ↵nulltoken2011-09-221-1/+1
| | | | | | | | wide values Should fix issue #419. Signed-off-by: nulltoken <emeric.fermas@gmail.com>
* Merge pull request #384 from kiryl/warningsVicent Martí2011-09-181-3/+3
|\ | | | | Add more -W flags to CFLAGS
| * CMakefile: add -Wmissing-prototypes and fix warningsKirill A. Shutemov2011-08-301-3/+3
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* | Cleanup legal dataVicent Marti2011-09-191-21/+3
|/ | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* Drop STRLEN() macrosKirill A. Shutemov2011-08-251-4/+4
| | | | | | | There is no need in STRLEN macros. Compilers can do this trivial optimization on its own. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* revwalk: fix cast warningKirill A. Shutemov2011-07-251-2/+1
| | | | | | | /home/kas/git/public/libgit2/src/revwalk.c: In function ‘object_table_hash’: /home/kas/git/public/libgit2/src/revwalk.c:120:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* revwalk: Properly mark uninteresting commitsVicent Marti2011-07-061-8/+6
|
* revwalk: Do not set error string on revwalk overVicent Marti2011-06-241-4/+7
|
* oid: Rename methodsVicent Marti2011-06-161-1/+1
| | | | | Yeah. Finally. Fuck the old names, this ain't POSIX and they don't make any sense at all.
* revwalk.c: Move to new error handling mechanismJakob Pfender2011-05-231-12/+12
|
* Do not set error message on `GIT_EREVWALKOVER`Vicent Marti2011-05-151-3/+3
| | | | | This is not really an error, just a special return code to mark the end of an iteration.
* Move revwalk.c to the new error handlingschu2011-05-111-10/+10
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Fix -Wunused-but-set-variable warningsschu2011-04-261-2/+2
| | | | | As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Use GIT_UNUSED or remove actually unused variables to prevent those warnings.
* Properly check `strtol` for errorsVicent Marti2011-04-091-2/+3
| | | | | We are now using a custom `strtol` implementation to make sure we're not missing any overflow errors.
* Always free the parents of a revwalk commitVicent Marti2011-03-221-0/+11
| | | | Thanks to Carlos Martín Nieto for spotting this.
* I broke your bindingsVicent Marti2011-03-201-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hey. Apologies in advance -- I broke your bindings. This is a major commit that includes a long-overdue redesign of the whole object-database structure. This is expected to be the last major external API redesign of the library until the first non-alpha release. Please get your bindings up to date with these changes. They will be included in the next minor release. Sorry again! Major features include: - Real caching and refcounting on parsed objects - Real caching and refcounting on objects read from the ODB - Streaming writes & reads from the ODB - Single-method writes for all object types - The external API is now partially thread-safe The speed increases are significant in all aspects, specially when reading an object several times from the ODB (revwalking) and when writing big objects to the ODB. Here's a full changelog for the external API: blob.h ------ - Remove `git_blob_new` - Remove `git_blob_set_rawcontent` - Remove `git_blob_set_rawcontent_fromfile` - Rename `git_blob_writefile` -> `git_blob_create_fromfile` - Change `git_blob_create_fromfile`: The `path` argument is now relative to the repository's working dir - Add `git_blob_create_frombuffer` commit.h -------- - Remove `git_commit_new` - Remove `git_commit_add_parent` - Remove `git_commit_set_message` - Remove `git_commit_set_committer` - Remove `git_commit_set_author` - Remove `git_commit_set_tree` - Add `git_commit_create` - Add `git_commit_create_v` - Add `git_commit_create_o` - Add `git_commit_create_ov` tag.h ----- - Remove `git_tag_new` - Remove `git_tag_set_target` - Remove `git_tag_set_name` - Remove `git_tag_set_tagger` - Remove `git_tag_set_message` - Add `git_tag_create` - Add `git_tag_create_o` tree.h ------ - Change `git_tree_entry_2object`: New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)` - Remove `git_tree_new` - Remove `git_tree_add_entry` - Remove `git_tree_remove_entry_byindex` - Remove `git_tree_remove_entry_byname` - Remove `git_tree_clearentries` - Remove `git_tree_entry_set_id` - Remove `git_tree_entry_set_name` - Remove `git_tree_entry_set_attributes` object.h ------------ - Remove `git_object_new - Remove `git_object_write` - Change `git_object_close`: This method is now *mandatory*. Not closing an object causes a memory leak. odb.h ----- - Remove type `git_rawobj` - Remove `git_rawobj_close` - Rename `git_rawobj_hash` -> `git_odb_hash` - Change `git_odb_hash`: New signature is `(git_oid *id, const void *data, size_t len, git_otype type)` - Add type `git_odb_object` - Add `git_odb_object_close` - Change `git_odb_read`: New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)` - Change `git_odb_read_header`: New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)` - Remove `git_odb_write` - Add `git_odb_open_wstream` - Add `git_odb_open_rstream` odb_backend.h ------------- - Change type `git_odb_backend`: New internal signatures are as follows int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype) int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *) - Add type `git_odb_stream` - Add enum `git_odb_streammode` Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix headers for the new Revision WalkerVicent Marti2011-03-161-1/+2
| | | | | | The "oid.h" header is now included instead of "object.h". The old "revwalk.h" header has been removed; it was empty.
* Change the Revwalk reset behavior to the old versionVicent Marti2011-03-161-94/+85
| | | | | The `reset` call now removes the pushed commits so we can reuse the revwalker. The API documentation has been updated with the details.
* Properly free commit a commit list in revwalkVicent Marti2011-03-161-4/+8
| | | | | The commit list was not being properly free'd when a walk was stopped halfway through.
* Rewrite the Revision WalkerVicent Marti2011-03-141-255/+363
| | | | | | | | | | | | | | | | | | | | | The new revision walker uses an internal Commit object storage system, custom memory allocator and much improved topological and time sorting algorithms. It's about 20x times faster than the previous implementation when browsing big repositories. The following external API calls have changed: `git_revwalk_next` returns an OID instead of a full commit object. The initial call to `git_revwalk_next` is no longer blocking when iterating through a repo with a time-sorting mode. Iterating with Topological or inverted modes still makes the initial call blocking to preprocess the commit list, but this block should be mostly unnoticeable on most repositories (topological preprocessing times at 0.3s on the git.git repo). `git_revwalk_push` and `git_revwalk_hide` now take an OID instead of a full commit object.
* Fix segmentation fault when freeing a repositoryVicent Marti2011-03-051-3/+3
| | | | | | | | Disable garbage collection of cross-references to prevent double-freeing. Internal reference management is now done with a separate method. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Implement reference counting for git_objectsVicent Marti2011-03-031-0/+3
| | | | | | | | All `git_object` instances looked up from the repository are reference counted. User is expected to use the new `git_object_close` when an object is no longer needed to force freeing it. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Rewrite git_hashtable internalsVicent Marti2011-02-221-18/+10
| | | | | | | | | | | | | | | | The old hash table with chained buckets has been replaced by a new one using Cuckoo hashing, which offers guaranteed constant lookup times. This should improve speeds on most use cases, since hash tables in libgit2 are usually used as caches where the objects are stored once and queried several times. The Cuckoo hash implementation is based off the one in the Basekit library [1] for the IO language, but rewritten to support an arbritrary number of hashes. We currently use 3 to maximize the usage of the nodes pool. [1]: https://github.com/stevedekorte/basekit/blob/master/source/CHash.c Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix segfault when iterating a revlist backwardsVicent Marti2011-02-181-0/+4
| | | | | | | The `prev` and `next` pointers were not being updated after popping one of the list elements. Signed-off-by: Vicent Marti <tanoku@gmail.com>