summaryrefslogtreecommitdiff
path: root/src/revwalk.c
Commit message (Collapse)AuthorAgeFilesLines
* peel: reject bad queries with EINVALIDSPECcmn/peeling-errorsCarlos Martín Nieto2014-11-221-1/+1
| | | | | | | | | | There are some combination of objects and target types which we know cannot be fulfilled. Return EINVALIDSPEC for those to signify that there is a mismatch in the user-provided data and what the object model is capable of satisfying. If we start at a tag and in the course of peeling find out that we cannot reach a particular type, we return EPEEL.
* revwalk: clear first-parent flag on resetcmn/revwalk-merge-baseCarlos Martín Nieto2014-10-081-0/+1
| | | | | This should have been included when implementing the feature but was missed.
* revwalk: catch no-push and no-hide casesCarlos Martín Nieto2014-10-081-10/+14
| | | | | | | If there have been no pushes, we can immediately return ITEROVER. If there have been no hides, we must not run the uninteresting pre-mark phase, as we do not want to hide anything and this would simply cause us to spend time loading objects.
* revwalk: mark uninteresting only up to the common ancestorsCarlos Martín Nieto2014-10-081-1/+73
| | | | | | | | | | | | | | | | | | | | This introduces a phase at the start of preparing a walk which pre-marks uninteresting commits, but only up to the common ancestors. We do this in a similar way to git, by walking down the history and marking (which is what we used to do), but we keep a time-sorted priority queue of commits and stop marking as soon as there are only uninteresting commits in this queue. This is a similar rule to the one used to find the merge-base. As we keep inserting commits regardless of the uninteresting bit, if there are only uninteresting commits in the queue, it means we've run out of interesting commits in our walk, so we can stop. The old mark_unintesting() logic is still in place, but that stops walking if it finds an already-uninteresting commit, so it will stop on the ones we've pre-marked; but keeping it allows us to also hide those that are hidden via the callback.
* revwalk: keep a single list of user inputsCarlos Martín Nieto2014-10-081-24/+20
| | | | | The old separation was due to the old merge-base finding, so it's no longer necessary.
* revwalk: clear the flags on resetCarlos Martín Nieto2014-10-081-0/+1
| | | | These store merge-base information which is only valid for a single run.
* revwalk: remove preallocation of the uninteresting commitsCarlos Martín Nieto2014-07-241-3/+0
| | | | | | | | | | Preallocating two commits doesn't make much sense as leaving allocation to the first array usage will allocate a sensible size with room for growth. This preallocation has also been hiding issues with strict aliasing in the tests, as we have fairly simple histories and never trigger the growth.
* revwalk: more sensible array handlingcmn/revwalk-array-fixCarlos Martín Nieto2014-06-111-2/+2
| | | | | | | | | Instead of using a sentinel empty value to detect the last commit, let's check for when we get a NULL from popping the stack, which lets us know when we're done. The current code causes us to read uninitialized data, although only on RHEL/CentOS 6 in release mode. This is a readability win overall.
* No need to find merge base.Anurag Gupta2014-03-311-35/+17
|
* Conforming to libgit2 coding style.Anurag Gupta2014-03-241-4/+1
|
* Remove unused push_cb_dataAnurag Gupta2014-03-241-5/+0
|
* Callback to hide commits in revision walker.Anurag Gupta2014-03-241-0/+28
|
* revwalk: don't try to find merge bases when there can be noneCarlos Martín Nieto2014-03-201-4/+14
| | | | | | | | | | | | | | | | | | | As a way to speed up the cases where we need to hide some commits, we find out what the merge bases are so we know to stop marking commits as uninteresting and avoid walking down a potentially very large amount of commits which we will never see. There are however two oversights in current code. The merge-base finding algorithm fails to recognize that if it is only given one commit, there can be no merge base. It instead walks down the whole ancestor chain needlessly. Make it return an empty list immediately in this situation. The revwalk does not know whether the user has asked to hide any commits at all. In situation where the user pushes multiple commits but doesn't hide any, the above fix wouldn't do the trick. Keep track of whether the user wants to hide any commits and only run the merge-base finding algorithm when it's needed.
* Merge pull request #2100 from libgit2/rb/update-pqueueVicent Marti2014-02-071-1/+2
|\ | | | | Replace priority queue code with implementation from hashsig
| * Convert pqueue to just be a git_vectorRussell Belfer2014-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Replace pqueue with code from hashsig heapRussell Belfer2014-02-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | I accidentally wrote a separate priority queue implementation when I was working on file rename detection as part of the file hash signature calculation code. To simplify licensing terms, I just adapted that to a general purpose priority queue and replace the old priority queue implementation that was borrowed from elsewhere. This also removes parts of the COPYING document that no longer apply to libgit2.
* | revwalk: remove usage of foreachCarlos Martín Nieto2014-02-051-11/+14
| |
* | revwalk: ignore wrong object type in glob pushesCarlos Martín Nieto2014-02-051-12/+16
| | | | | | | | | | Pushing a whole namespace can cause us to attempt to push non-committish objects. Catch this situation and special-case it for ignoring this.
* | revwalk: accept committish objectsCarlos Martín Nieto2014-02-051-8/+13
|/ | | | | | | | | | | Let the user push committish objects and peel them to figure out which commit to push to our queue. This is for convenience and for allowing uses of git_revwalk_push_glob(w, "tags") with annotated tags.
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-8/+13
| | | | | | | | | | | | | 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.
* Remove regex usage from places that don't need itRussell Belfer2013-09-231-29/+14
| | | | | | | | | | | In revwalk, we are doing a very simple check to see if a string contains wildcard characters, so a full regular expression match is not needed. In remote listing, now that we have git_config_foreach_match with full regular expression matching, we can take advantage of that and eliminate the regex here, replacing it with much simpler string manipulation.
* revwalk: allow simplifying by first-parentCarlos Martín Nieto2013-09-091-4/+18
| | | | | When enabled, only the first parent of each commit will be queued, enabling a simple way of using first-parent simplification.
* revwalk: make mark_unintersting use a loopCarlos Martín Nieto2013-09-061-10/+32
| | | | | | | Using a recursive function can blow the stack when dealing with long histories. Use a loop instead to limit the call chain depth. This fixes #1223.
* refs: remove the OID/SYMBOLIC filteringCarlos Martín Nieto2013-05-111-1/+1
| | | | | | | | | Nobody should ever be using anything other than ALL at this level, so remove the option altogether. As part of this, git_reference_foreach_glob is now implemented in the frontend using an iterator. Backends will later regain the ability of doing the glob filtering in the backend.
* git_revision -> git_revspecVicent Marti2013-04-151-7/+7
|
* Is this crazy?Vicent Marti2013-04-151-9/+10
|
* Change git_revparse to output git_object pointersBen Straub2013-04-151-3/+5
| | | | This will probably prevent many lookup/free operations in calling code.
* Deprecate git_revparse_single and _rangelikeBen Straub2013-04-091-8/+6
|
* revwalk: Parse revision rangesGreg Price2013-04-061-0/+25
| | | | | | All the hard work is already in revparse. Signed-off-by: Greg Price <price@mit.edu>
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix function name and add real error checkRussell Belfer2012-11-291-2/+3
| | | | | | | `revwalk.h:commit_lookup()` -> `git_revwalk__commit_lookup()` and make `git_commit_list_parse()` do real error checking that the item in the list is an actual commit object. Also fixed an apparent typo in a test name.
* Move merge functions to merge.cBen Straub2012-11-271-467/+38
| | | | | In so doing, promote commit_list to git_commit_list, with its own internal API header.
* Rename ref and reflog apis for consistencyBen Straub2012-11-271-1/+1
|
* revwalk: fix off-by-one errorMichael Schubert2012-09-271-1/+2
| | | | Fixes #921.
* git_mergebase: Constness-Fix for consistencySascha Cunz2012-09-091-1/+1
|
* Diff iteratorsRussell Belfer2012-09-051-11/+19
| | | | | | | | | | | This refactors the diff output code so that an iterator object can be used to traverse and generate the diffs, instead of just the `foreach()` style with callbacks. The code has been rearranged so that the two styles can still share most functions. This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses that as a common error code for marking the end of iteration when using a iterator style of object.
* revwalk: refuse push of non-commit objectsMichael Schubert2012-08-271-6/+14
| | | | | Check the type of the pushed object immediately instead of starting the walk and failing in between.
* revwalk: relax the parsing of the commit timenulltoken2012-07-111-7/+24
|
* revwalk: make git_revwalk_(push|hide)_glob() leverage ↵nulltoken2012-06-221-8/+3
| | | | git_reference_foreach_glob()
* Merge pull request #753 from nulltoken/topic/merge-base-manyVicent Martí2012-06-181-0/+56
|\ | | | | Expose git_merge_base_many()
| * merge: Expose git_merge_base_many()nulltoken2012-06-071-0/+56
| |
* | Fix fragile commit parsing in revwalkRussell Belfer2012-06-111-15/+21
|/
* errors: Rename error codesbreaking-changesVicent Martí2012-05-181-1/+1
|
* errors: Rename the generic return codesVicent Martí2012-05-181-11/+11
|
* 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`.