summaryrefslogtreecommitdiff
path: root/src/path.c
Commit message (Collapse)AuthorAgeFilesLines
* React to feedback for UTF-8 <-> WCHAR and reparse workPhilip Kelley2014-04-231-1/+1
|
* Win32: UTF-8 <-> WCHAR conversion overhaulPhilip Kelley2014-04-191-25/+26
|
* Pop ignore only if whole relative path matchesRussell Belfer2014-04-181-1/+1
| | | | | | | | | | | When traversing the directory structure, the iterator pushes and pops ignore files using a vector. Some directories don't have ignore files, so it uses a path comparison to decide when it is right to actually pop the last ignore file. This was only comparing directory suffixes, though, so a subdirectory with the same name as a parent could result in the parent's .gitignore being popped off the list ignores too early. This changes the logic to compare the entire relative path of the ignore file.
* vmg is always rightRussell Belfer2014-04-071-1/+1
|
* Fix bug with multiple iconv conversions in one dirRussell Belfer2014-04-071-0/+2
| | | | | | | | The internal buffer in the `git_path_iconv_t` structure was not being reset before the calls to `iconv` were made to convert data, so if there were multiple decomposed Unicode paths in a single directory, paths after the first one were being appended to the first instead of treated as independent data.
* Update behavior for untracked sub-reposRussell Belfer2014-03-251-9/+2
| | | | | | | | | | | When a directory containing a .git directory (or even just a plain gitlink) was found, libgit2 was going out of its way to treat it specially. This seemed like it was necessary because the diff code was not originally emulating Git's behavior for untracked directories correctly (i.e. scanning for ignored vs untracked items inside). Now that libgit2 diff mimics Git's untracked directory behavior, the special handling for contained Git repos is actually incorrect and this commit rips it out.
* refdb: catch a directory disappearingCarlos Martín Nieto2014-03-051-0/+3
| | | | | | | | If a directory disappears between the time we look up the entries of its parent and the time when we go to look at it, we should ignore the error and move forward. This fixes #2046.
* Remove now-duplicated stdarg.h includeEdward Thomson2014-02-241-1/+0
|
* Fix up some valgrind leaks and warningsRussell Belfer2013-12-111-1/+1
|
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-2/+2
|
* Some callback error check style cleanupsRussell Belfer2013-12-111-4/+9
| | | | I find this easier to read...
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-4/+7
| | | | | | | | | | | This adds giterr_user_cancel to return GIT_EUSER and clear any error message that is sitting around. As a result of using that in places, we need to be more thorough with capturing errors that happen inside a callback when used internally. To help with that, this also adds giterr_capture and giterr_restore so that when we internally use a foreach-type function that clears errors and converts them to GIT_EUSER, it is easier to restore not just the return value, but the actual error message text.
* iconv: Do not fake an API when iconv is not availableVicent Marti2013-11-011-2/+28
|
* More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-7/+26
| | | | | | | | | | | | | | | | | | | | | | This cleans up some additional issues. The main change is that on a filesystem that doesn't support mode bits, libgit2 will now create new blobs with GIT_FILEMODE_BLOB always instead of being at the mercy to the filesystem driver to report executable or not. This means that if "core.filemode" lies and claims that filemode is not supported, then we will ignore the executable bit from the filesystem. Previously we would have allowed it. This adds an option to the new git_repository_reset_filesystem to recurse through submodules if desired. There may be other types of APIs that would like a "recurse submodules" option, but this one is particularly useful. This also has a number of cleanups, etc., for related things including trying to give better error messages when problems come up from the filesystem. For example, the FAT filesystem driver on MacOS appears to return errno EINVAL if you attempt to write a filename with invalid UTF-8 in it. We try to capture that with a better error message now.
* Wrap iconv stuff and write testsRussell Belfer2013-10-031-58/+47
| | | | | | | | This adds a simple wrapper around the iconv APIs and uses it instead of the old code that was inlining the iconv stuff. This makes it possible for me to test the iconv logic in isolation. A "no iconv" version of the API was defined with macros so that I could have fewer ifdefs in the code itself.
* Simplify git_path_is_empty_dir implementationRussell Belfer2013-10-031-28/+23
| | | | | | | This simplifies git_path_is_empty_dir on both Windows (getting rid of git_buf allocation inside the function) and other platforms (by just using git_path_direach), and adds tests for the function, and uses the function to simplify some existing tests.
* Initial iconv hookup for precomposed unicodeRussell Belfer2013-10-031-47/+139
| | | | | | | | | | | | | | | | | | | | This hooks up git_path_direach and git_path_dirload so that they will take a flag indicating if directory entry names should be tested and converted from decomposed unicode to precomposed form. This code will only come into play on the Apple platform and even then, only when certain types of filesystems are used. This involved adding a flag to these functions which involved changing a lot of places in the code. This was an opportunity to do a bit of code cleanup here and there, for example, getting rid of the git_futils_cleanupdir_r function in favor of a simple flag to git_futils_rmdir_r to not remove the top level entry. That ended up adding depth tracking during rmdir_r which led to a safety check for infinite directory recursion. Yay. This hasn't actually been tested on the Mac filesystems where the issue occurs. I still need to get test environment for that.
* Put hooks in place for precompose in dirload fnRussell Belfer2013-10-031-3/+11
| | | | | | This doesn't actual do string precompose but it puts the hooks in place into the iterators and the git_path_dirload function so that the actual precompose work is ready to go.
* Ignore files that disappear while iteratingEdward Thomson2013-09-241-1/+9
| | | | | | On occasion, files can disappear while we're iterating the filesystem, between calls to readdir and stat. Let's pretend those didn't exist in the first place.
* Merge git_buf and git_bufferRussell Belfer2013-09-171-1/+1
| | | | | | | | | | | This makes the git_buf struct that was used internally into an externally available structure and eliminates the git_buffer. As part of that, some of the special cases that arose with the externally used git_buffer were blended into the git_buf, such as being careful about git_buf objects that may have a NULL ptr and allowing for bufs with a valid ptr and size but zero asize as a way of referring to externally owned data.
* path: Make direach() return EUSER on callback errornulltoken2013-09-101-2/+2
|
* Fix resolving relative windows network pathsRussell Belfer2013-09-031-2/+2
|
* path: properly resolve relative pathsNikolai Vladimirov2013-09-031-5/+26
|
* Merge pull request #1767 from libgit2/win32-bigger-utf8-bufferVicent Martí2013-08-131-3/+4
|\ | | | | Bigger buffer for utf-8 parsing in win32
| * Minor win32 fixes and improvementsRussell Belfer2013-08-131-0/+2
| | | | | | | | | | | | | | | | This is just a bunch of small fixes that I noticed while looking at the UTF8 and UTF16 path stuff. It fixes a slowdown in looking for an empty directory (not exiting loop asap), makes the dir name in the git__DIR structure be a GIT_FLEX_ARRAY to save an allocation, and fixes some slightly odd assumptions in the cl_getenv helper.
| * Rename git__win32_path fns to git_win32_pathRussell Belfer2013-08-131-1/+1
| |
| * windows: Require orderVicent Marti2013-08-131-1/+0
| |
| * windows: Path conversion with better semanticsVicent Marti2013-08-131-2/+2
| |
| * Discriminate path-specific and general UTF-X conversionsBen Straub2013-08-081-1/+1
| |
| * Rename git_win_str_utf* to git_win32_path_utf*Ben Straub2013-08-071-1/+1
| |
| * Add typedefs for win32 utf-8 and utf-16 buffersBen Straub2013-08-071-2/+2
| | | | | | | | ...and normalize the signatures of the two conversion functions.
| * Split UTF-16 and UTF-8 buffer sizes for win32Ben Straub2013-08-051-2/+2
| | | | | | | | | | Also fixed up call-sites to use the correct buffer sizes, especially when converting to utf-8.
* | Improve building ignore file listsRussell Belfer2013-08-091-1/+1
|/ | | | | | | | | | | | | | | | | The routines to push and pop ignore files while traversing a directory had some issues. In particular, setting up the initial list would sometimes push an ignore file before it ought to be applied if the starting path was a directory containing an ignore file. Also, the pop function was not always matching the right part of the path and would fail to pop ignores from the list in some cases. This adds some tests that exercise a particular problematic case and then fixes the problems that I could find related to this. At some point, I'd like to isolate this ignore rule management code and rewrite it, but that's a larger project and right now, I'll opt to just try to fix the broken behaviors.
* Three submodule status bug fixesRussell Belfer2013-03-181-4/+11
| | | | | | | | | | | | | | | | 1. Fix sort order problem with submodules where "mod" was sorting after "mod-plus" because they were being sorted as "mod/" and "mod-plus/". This involved pushing the "contains a .git entry" test significantly lower in the stack. 2. Reinstate behavior that a directory which contains a .git entry will be treated as a submodule during iteration even if it is not yet added to the .gitmodules. 3. Now that any directory containing .git is reported as submodule, we have to be more careful checking for GIT_EEXISTS when we do a submodule lookup, because that is the error code that is returned by git_submodule_lookup when you try to look up a directory containing .git that has no record in gitmodules or the index.
* Improved tree iterator internalsRussell Belfer2013-03-141-26/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix some incorrect MSVC #ifdef's. Fixes #1305Philip Kelley2013-02-111-1/+1
|
* Add git_path_icmp to case-insensitive path cmpRussell Belfer2013-01-151-0/+24
| | | | This adds git_path_icmp to complement git_path_cmp.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Give proper license notice to code from AndroidMartin Woodward2013-01-031-1/+27
| | | | | | | The usage of the Android derrived code contains a full notice which must be provided with the source code as per the terms given at: https://android.googlesource.com/platform/bionic/+/android-4.0.3_r1.1/libc/bionic/dirname_r.c
* path: ifdef GIT_WIN32 looks_like_network_computer_name()Michael Schubert2013-01-021-0/+2
|
* path: Teach UNC paths to git_path_dirname_r()nulltoken2012-12-261-0/+25
| | | | Fix libgit2/libgit2sharp#256
* Fix iterator reset and add reset rangesRussell Belfer2012-12-101-4/+31
| | | | | | | 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.
* Consolidate text buffer functionsRussell Belfer2012-11-281-1/+1
| | | | | | | | | | | | | There are many scattered functions that look into the contents of buffers to do various text manipulations (such as escaping or unescaping data, calculating text stats, guessing if content is binary, etc). This groups all those functions together into a new file and converts the code to use that. This has two enhancements to existing functionality. The old text stats function is significantly rewritten and the BOM detection code was extended (although largely we can't deal with anything other than a UTF8 BOM).
* Rework checkout with new strategy optionsRussell Belfer2012-11-091-2/+3
| | | | | | | | | | | | | | | | | | This is a major reworking of checkout strategy options. The checkout code is now sensitive to the contents of the HEAD tree and the new options allow you to update the working tree so that it will match the index content only when it previously matched the contents of the HEAD. This allows you to, for example, to distinguish between removing files that are in the HEAD but not in the index, vs just removing all untracked files. Because of various corner cases that arise, etc., this required some additional capabilities in rmdir and other utility functions. This includes the beginnings of an implementation of code to read a partial tree into the index based on a pathspec, but that is not enabled because of the possibility of creating conflicting index entries.
* Add bounds checking to UTF-8 conversionutf8-winVicent Marti2012-08-281-3/+2
|
* Add template dir and set gid to repo initRussell Belfer2012-08-221-6/+40
| | | | | | | | | | | | | | | | | This extends git_repository_init_ext further with support for initializing the repository from an external template directory and with support for the "create shared" type flags that make a set GID repository directory. This also adds tests for much of the new functionality to the existing `repo/init.c` test suite. Also, this adds a bunch of new utility functions including a very general purpose `git_futils_mkdir` (with the ability to make paths and to chmod the paths post-creation) and a file tree copying function `git_futils_cp_r`. Also, this includes some new path functions that were useful to keep the code simple.
* Merge branch 'development' into cloneBen Straub2012-07-171-5/+68
|\
| * Add path utilities to resolve relative pathsRussell Belfer2012-07-101-3/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easy to take a buffer containing a path with relative references (i.e. .. or . path segments) and resolve all of those into a clean path. This can be applied to URLs as well as file paths which can be useful. As part of this, I made the drive-letter detection apply on all platforms, not just windows. If you give a path that looks like "c:/..." on any platform, it seems like we might as well detect that as a rooted path. I suppose if you create a directory named "x:" on another platform and want to use that as the beginning of a relative path under the root directory of your repo, this could cause a problem, but then it seems like you're asking for trouble.
| * Fix libgit2 on GNU/Hurd.Cyril Roelandt2012-07-061-2/+2
| | | | | | | | | | On GNU, the d_name field of the dirent structure is defined as "char d_name[1]", so we must allocate more than sizeof(struct dirent) bytes, just like on Sun.