summaryrefslogtreecommitdiff
path: root/src/tree.c
Commit message (Collapse)AuthorAgeFilesLines
...
* tree: Kill the `git_tree_diff` functionsVicent Martí2012-05-161-270/+0
| | | | These are deprecated and replaced with the diffing code in git2/diff.h
* Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-0/+27
| | | | | | | | | | | | | | | | | | | | | The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
* Remove old and unused error codesVicent Martí2012-05-021-1/+1
|
* Merge branch 'new-error-handling' into developmentVicent Martí2012-05-021-151/+136
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .travis.yml include/git2/diff.h src/config_file.c src/diff.c src/diff_output.c src/mwindow.c src/path.c tests-clar/clar_helpers.c tests-clar/object/tree/frompath.c tests/t00-core.c tests/t03-objwrite.c tests/t08-tag.c tests/t10-refs.c tests/t12-repo.c tests/t18-status.c tests/test_helpers.c tests/test_main.c
| * Merge remote-tracking branch 'carlosmn/remaining-errors' into new-error-handlingVicent Martí2012-05-011-148/+132
| |\ | | | | | | | | | | | | Conflicts: src/refspec.c
| | * error handling: move the missing parts over to the new error handlingCarlos Martín Nieto2012-04-261-148/+132
| | |
| * | buf: deploy git_buf_len()nulltoken2012-04-301-1/+1
| |/
| * Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-1/+1
| | | | | | | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
| * error-handling: RepositoryVicent Martí2012-03-071-4/+5
| | | | | | | | | | | | | | | | This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
* | tree: Fix homing entry searchVicent Martí2012-03-281-2/+2
|/
* tree: break out on write errorCarlos Martín Nieto2012-02-231-0/+1
| | | | | If write_tree() returs an error, we used to set the error message and continued looping. Exit the loop so we return the error.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* treebuilder: remove needless variable entry_countschu2012-02-051-8/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* diff-index: fix leakCarlos Martín Nieto2012-01-191-0/+1
| | | | The buffer wasn't getting freed if the last difference was a deletion.
* Move path related functions from fileops to pathRussell Belfer2012-01-171-1/+1
| | | | | | | | | | | This takes all of the functions that look up simple data about paths (such as `git_futils_isdir`) and moves them over to path.h (becoming `git_path_isdir`). This leaves fileops.h just with functions that actually manipulate the filesystem or look at the file contents in some way. As part of this, the dir.h header which is really just for win32 support was moved into win32 (with some minor changes).
* do not use full path in diff-indexClemens Buchacher2011-12-301-10/+15
| | | | | | | | | | Currently, diff_index passes the full relative path from the repository root to the callback. In case of an addition, it passes the tree entry instead of the index entry. This change fixes the path used for addition, and it passes only the basename of the path. This mimics the current behavior of git_tree_diff.
* move entry_is_tree to tree.hClemens Buchacher2011-12-301-6/+4
|
* Fix tree-diff with the new path APIVicent Marti2011-12-141-2/+2
|
* Merge remote-tracking branch 'arrbee/git-buf-for-paths' into developmentVicent Marti2011-12-091-34/+46
|\ | | | | | | | | Conflicts: tests-clay/clay_main.c
| * Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-34/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
* | tree: recursive diff-indexVicent Marti2011-12-031-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk> Signed-off-by: Vicent Marti <tanoku@gmail.com> # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Author: Carlos Martín Nieto <carlos@cmartin.tk> # # On branch development # Your branch is ahead of 'origin/development' by 11 commits. # # Changes to be committed: # (use "git reset HEAD^1 <file>..." to unstage) # # modified: include/git2/tree.h # modified: src/tree.c # modified: tests-clay/clay_main.c # modified: tests-clay/object/tree/diff.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # 0001-remote-Cleanup-the-remotes-code.patch # 466.patch # 466.patch.1 # 488.patch # Makefile # libgit2.0.15.0.dylib # libgit2.0.dylib # libgit2.dylib # libgit2_clay # libgit2_test # tests-clay/object/tree/
* | tree: implement tree diffingCarlos Martín Nieto2011-12-031-0/+174
|/ | | | | | | | For each difference in the trees, the callback gets called with the relevant information so the user can fill in their own data structures. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* 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-7/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tree: Add payload to `git_tree_walk`Vicent Marti2011-11-181-5/+9
|
* Rename `git_tree_frompath` to `git_tree_get_subtree`Vicent Marti2011-11-181-14/+42
| | | | That makes more sense to me.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-8/+8
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* tree: Add traversal in post-orderVicent Marti2011-10-271-2/+54
|
* tree: Fix name lookups once and for allVicent Marti2011-10-201-45/+85
| | | | Double-pass binary search. Jeez.
* tree: Fix lookups by entry nameVicent Marti2011-10-191-2/+11
|
* tree: Add git_tree_frompath() which, given a relative path to a tree entry, ↵nulltoken2011-10-131-0/+45
| | | | retrieves the tree object containing this tree entry
* tree: Fix check for valid attributesVicent Marti2011-09-271-2/+4
|
* tree: Use an internal append functiont to add new entriesVicent Marti2011-09-271-19/+25
|
* Make use of the tree cacheCarlos Martín Nieto2011-09-271-0/+30
| | | | | | | Taking advantage of the tree cache, git_tree_create_fromindex becomes comparable in speed to git write-tree when the cache is available. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* 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/+6
|\ | | | | Add more -W flags to CFLAGS
| * CMakefile: add -Wmissing-prototypes and fix warningsKirill A. Shutemov2011-08-301-2/+2
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
| * CMakefile: add -Wstrict-aliasing=2 and fix warningsKirill A. Shutemov2011-08-301-1/+4
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* | Merge pull request #394 from carlosmn/tree-fromindexVicent Martí2011-09-181-70/+83
|\ \ | | | | | | Use git_treebuilder to write the index as a tree
| * | tree: use git_treebuilder to write the index as a treeCarlos Martín Nieto2011-09-101-70/+83
| |/ | | | | | | | | | | | | There is no point in reinventing the wheel when using the treebuilder is much more straightforward and makes the code more readable. There is no optimisation, and the performance is no worse than when writing the tree object ourselves.
* | 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.
* Remove duplicated sortLuc Bertrand2011-08-031-1/+0
|
* tree: fix cast warningsKirill A. Shutemov2011-07-251-4/+9
| | | | | | | | | /home/kas/git/public/libgit2/src/tree.c: In function ‘entry_search_cmp’: /home/kas/git/public/libgit2/src/tree.c:47:36: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/tree.c: In function ‘git_treebuilder_remove’: /home/kas/git/public/libgit2/src/tree.c:443:31: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* tree: fix insertion of entries with invalid filenamesnulltoken2011-07-131-3/+5
|
* tree: More accurate matching on entriesVicent Marti2011-07-131-11/+28
| | | | | | | | The old matcher was returning fake matches when given stupid entry names. E.g. `git2` could be matched by `git2 /`, `git2/foobar`, git2/////` and other stupid stuff
* tree: Fix wrong sort order when querying entriesVicent Marti2011-07-131-15/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #127 (that was quite an outstanding issue). Rationale: The tree objects on Git are stored and read following a very specific sorting algorithm that places folders before files. That original sort was the sort we were storing on memory, but this sort was being queried with a binary search that used a simple `strcmp` for comparison, so there were many instances where the search was failing. Obviously, the most straightforward way to fix this is changing the binary search CB to use the same comparison method as the sorting CB. The problem with this is that the binary search callback compares a path and an entry, so there is no way to know if the given path is a folder or a standard file. How do we work around this? Instead of splitting the `entry_byname` method in two (one for searching directories and one for searching normal files), we just assume that the path we are searching for is of the same kind as the path it's being compared at the moment. return git_futils_cmp_path( ksearch->filename, ksearch->filename_len, entry->attr & 040000, entry->filename, entry->filename_len, entry->attr & 040000); Since there cannot be a folder and a regular file with the same name on the same tree, the most basic equality check will always fail for all comparsions, until our path is compared with the actual entry we are looking for; in this case, the matching will succeed with the file type of the entry -- whatever it was initially. I hope that makes sense. PS: While I was at it, I switched the cmp methods to use cached values for the length of each filename. That makes searches and sorts retardedly fast -- I was wondering the reason of the performance hiccups on massive trees; it's because of 2*strlen for each comparsion call.
* odb: Direct writes are backVicent Marti2011-07-091-22/+13
| | | | | | | | | | | | | | | | | | | | | | DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the ODB was an overkill for the smaller objects like Commit and Tags; most of the streaming logic was taking too long. This commit makes Commits, Tags and Trees to be built-up in memory, and then written to disk in 2 pushes (header + data), instead of streaming everything. This is *always* faster, even for big files (since the git_filebuf class still does streaming writes when the memory cache overflows). This is also a gazillion lines of code smaller, because we don't have to precompute the final size of the object before starting the stream (this was kind of defeating the point of streaming, anyway). Blobs are still written with full streaming instead of loading them in memory, since this is still the fastest way. A new `git_buf` class has been added. It's missing some features, but it'll get there.
* vector: Timsort all of the thingsVicent Marti2011-07-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Drop the GLibc implementation of Merge Sort and replace it with Timsort. The algorithm has been tuned to work on arrays of pointers (void **), so there's no longer a need to abstract the byte-width of each element in the array. All the comparison callbacks now take pointers-to-elements, not pointers-to-pointers, so there's now one less level of dereferencing. E.g. int index_cmp(const void *a, const void *b) { - const git_index_entry *entry_a = *(const git_index_entry **)(a); + const git_index_entry *entry_a = (const git_index_entry *)(a); The result is up to a 40% speed-up when sorting vectors. Memory usage remains lineal. A new `bsearch` implementation has been added, whose callback also supplies pointer-to-elements, to uniform the Vector API again.
* fileops: CleanupVicent Marti2011-07-051-1/+1
| | | | | | | | | | | | | | | | Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.
* cleanup: remove trailing spacesKirill A. Shutemov2011-07-011-10/+10
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>