summaryrefslogtreecommitdiff
path: root/src/iterator.c
Commit message (Collapse)AuthorAgeFilesLines
* Make enum in src,tests and examples C90 compliant by removing trailing comma.Peter Pettersson2021-11-151-1/+1
|
* path: use new length validation functionsEdward Thomson2021-11-091-5/+12
|
* path: separate git-specific path functions from utilEdward Thomson2021-11-091-14/+15
| | | | | | Introduce `git_fs_path`, which operates on generic filesystem paths. `git_path` will be kept for only git-specific path functionality (for example, checking for `.git` in a path).
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-171-41/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
* iterator: validate workdir pathsEdward Thomson2021-04-281-4/+8
| | | | | | | Supply the repository for the filesystem and workdir iterators - for workdir iterators, this is non-null and we can lookup the core.longpaths configuration option. (For regular filesystem iterators, this is NULL, so core.longpaths does not apply.)
* iterator: use GIT_ASSERTEdward Thomson2020-11-271-20/+28
|
* git_pool_init: handle failure casesethomson/poolinitEdward Thomson2020-06-011-4/+4
| | | | Propagate failures caused by pool initialization errors.
* iterator: update enum type name for consistencyEdward Thomson2020-01-181-13/+13
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_iterator_type_t` to `git_iterator_t` for consistency.
* iterator: remove duplicate memsetPatrick Steinhardt2019-08-271-5/+3
| | | | | When allocating new tree iterator frames, we zero out the allocated memory twice. Remove one of the `memset` calls.
* iterator: avoid leaving partially initialized frame on stackPatrick Steinhardt2019-08-271-2/+5
| | | | | | | | | | When allocating tree iterator entries, we use GIT_ERROR_ALLOC_CHECK` to check whether the allocation has failed. The macro will cause the function to immediately return, though, leaving behind a partially initialized iterator frame. Fix the issue by manually checking for memory allocation errors and using `goto done` in case of an error, popping the iterator frame.
* configuration: cvar -> configmapPatrick Steinhardt2019-07-181-1/+1
| | | | | `cvar` is an unhelpful name. Refactor its usage to `configmap` for more clarity.
* iterator: make use the `GIT_CONTAINER_OF` macroEtienne Samson2019-04-161-14/+18
|
* iterator: cast filesystem iterator entry values explicitlyEdward Thomson2019-01-251-3/+10
| | | | | | | | | | | | The filesystem iterator takes `stat` data from disk and puts them into index entries, which use 32 bit ints for time (the seconds portion) and filesize. However, on most systems these are not 32 bit, thus will typically invoke a warning. Most users ignore these fields entirely. Diff and checkout code do use the values, however only for the cache to determine if they should check file modification. Thus, this is not a critical error (and will cause a hash recomputation at worst).
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-22/+22
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-2/+2
| | | | Use the new object_type enumeration names within the codebase.
* iterator: remove unused function `tree_iterator_entry_cmp`Patrick Steinhardt2018-11-281-8/+0
| | | | | | | The function `tree_iterator_entry_cmp` has been introduced in commit be30387e8 (iterators: refactored tree iterator, 2016-02-25), but in fact it has never been used at all. Remove it to avoid unused function warnings as soon as we re-enable "-Wunused-functions".
* iterator: introduce `git_iterator_foreach`Edward Thomson2018-11-041-0/+29
| | | | | Introduce a `git_iterator_foreach` helper function which invokes a callback on all files for a given iterator.
* iterator: optionally hash filesystem iteratorsEdward Thomson2018-11-031-11/+50
| | | | | | | | | Optionally hash the contents of files encountered in the filesystem or working directory iterators. This is not expected to be used in production code paths, but may allow us to simplify some test contexts. For working directory iterators, apply filters as appropriate, since we have the context able to do it.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-8/+8
|
* Set ctime/mtime nanosecs to 0 if USE_NSEC is not definedTomás Pollak2018-01-311-0/+3
|
* Honor 'GIT_USE_NSEC' option in `filesystem_iterator_set_current`Tomás Pollak2018-01-301-2/+4
| | | | | | This should have been part of PR #3638. Without this we still get nsec-related errors, even when using -DGIT_USE_NSEC: error: ‘struct stat’ has no member named ‘st_mtime_nsec’
* iterator: cleanups with symlink dir handlingEdward Thomson2017-12-301-14/+29
| | | | Perform some error checking when examining symlink directories.
* branches: Check symlinked subdirectoriesAndy Doan2017-12-291-1/+21
| | | | | | | | Native Git allows symlinked directories under .git/refs. This change allows libgit2 to also look for references that live under symlinked directories. Signed-off-by: Andy Doan <andy@opensourcefoundries.com>
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* common: use PRIuZ for size_t in `giterr_set` callsPatrick Steinhardt2016-11-141-1/+1
|
* filesystem_iterator: fixed double free on errorJason Haslam2016-08-221-5/+3
|
* iterator: ignore submodule in has_endedEdward Thomson2016-04-211-4/+3
|
* iterator: support trailing `/` in start for submodEdward Thomson2016-04-021-10/+26
| | | | | | Allow callers to specify a start path with a trailing slash to match a submodule, instead of just a directory. This is for some legacy behavior that's sort of dumb, but there it is.
* Merge pull request #3719 from libgit2/ethomson/submodule_statusCarlos Martín Nieto2016-04-011-1/+1
|\ | | | | WD iterator: properly identify submodules
| * iterator: use correct search functionethomson/submodule_statusEdward Thomson2016-03-311-1/+1
| |
* | leaks: fix some iterator leaksEdward Thomson2016-03-311-6/+22
| |
* | Plug a few leaksCarlos Martín Nieto2016-03-311-0/+14
|/
* iterator: comment fixedMarc Strapetz2016-03-241-2/+2
|
* iterator: unused includes removedMarc Strapetz2016-03-241-4/+0
|
* iterator: cleanupsEdward Thomson2016-03-241-345/+48
| | | | Remove some unused functions, refactor some ugliness.
* iterator: refactor empty iterator to new styleEdward Thomson2016-03-241-15/+36
|
* iterator: mandate `advance_over`Edward Thomson2016-03-241-1/+10
| | | | | Since the three iterators implement `advance_over` differently, mandate it and implement each.
* iterator: refactor index iteratorEdward Thomson2016-03-241-200/+194
|
* iterator: move the index into the iterator itselfEdward Thomson2016-03-241-33/+8
|
* iterator: test that we're at the end of iterationEdward Thomson2016-03-231-1/+3
| | | | | | | Ensure that we have hit the end of iteration; previously we tested that we saw all the values that we expected to see. We did not then ensure that we were at the end of the iteration (and that there were subsequently values in the iteration that we did *not* expect.)
* iterator: combine fs+workdir iterators more completelyEdward Thomson2016-03-231-905/+1029
| | | | | | | | | | | | | Drop some of the layers of indirection between the workdir and the filesystem iterators. This makes the code a little bit easier to follow, and reduces the number of unnecessary allocations a bit as well. (Prior to this, when we filter entries, we would allocate them, filter them and then free them; now we do the filtering before allocation.) Also, rename `git_iterator_advance_over_with_status` to just `git_iterator_advance_over`. Mostly because it's a fucking long-ass function name otherwise.
* iterators: refactored tree iteratorEdward Thomson2016-03-231-391/+627
| | | | | | | | Refactored the tree iterator to never recurse; simply process the next entry in order in `advance`. Additionally, reduce the number of allocations and sorting as much as possible to provide a ~30% speedup on case-sensitive iteration. (The gains for case-insensitive iteration are less majestic.)
* git_object_dup: introduce typesafe versionsEdward Thomson2016-03-231-2/+2
|
* iterator: disambiguate reset and reset_rangeEdward Thomson2016-03-231-19/+50
| | | | | | Disambiguate the reset and reset_range functions. Now reset_range with a NULL path will clear the start or end; reset will leave the existing start and end unchanged.
* iterator: drop unused/unimplemented `seek`Edward Thomson2016-03-231-29/+0
|
* tree: re-use the id and filename in the odb objectCarlos Martín Nieto2016-03-201-2/+2
| | | | | Instead of copying over the data into the individual entries, point to the originals, which are already in a format we can use.
* Merge pull request #3619 from ethomson/win32_forbiddenCarlos Martín Nieto2016-02-181-3/+9
|\ | | | | win32: allow us to read indexes with forbidden paths on win32
| * iterator: assert tree_iterator has a frameEdward Thomson2016-02-171-7/+11
| | | | | | | | | | | | | | Although a `tree_iterator` that failed to be properly created does not have a frame, all other `tree_iterator`s should. Do not call `pop` in the failure case, but assert that in all other cases there is a frame.
| * Validate pointer before access the member.Colin Xu2016-02-171-3/+5
| | | | | | | | | | | | | | | | When Git repository at network locations, sometimes git_iterator_for_tree fails at iterator__update_ignore_case so it goes to git_iterator_free. Null pointer will crash the process if not check. Signed-off-by: Colin Xu <colin.xu@gmail.com>
* | Horrible fix for #3173.Arthur Schreiber2016-02-111-2/+3
|/