summaryrefslogtreecommitdiff
path: root/src/path.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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.
* | Move is_dot_or_dotdotW into path.h.Ben Straub2012-07-111-8/+1
| |
* | Fix compile and workings on msvc.Ben Straub2012-07-111-5/+23
| | | | | | | | Signed-off-by: Ben Straub <bstraub@github.com>
* | Add git_path_is_empty_dir.Ben Straub2012-07-111-0/+52
| |
* | Add git_path_is_dot_or_dotdot.Ben Straub2012-07-111-10/+2
|/ | | | Also, remove some duplication in the clone test suite.
* tree: Proper path comparison logicVicent Marti2012-06-191-7/+12
|
* Better fix for isalpha in drive letter detectionRussell Belfer2012-06-081-4/+7
| | | | Missed a place that used this and missed git__isalpha
* isalpha is not great for UTF-8Russell Belfer2012-06-081-1/+2
| | | | | | | When checking for a drive letter on windows, instead of using isalpha(), it is better to just check for a..z and A..Z, I think, particularly because the MS isalpha implementation appears to assert when given an 0xFF byte.
* Fix readdir_r() usage for SolarisScott J. Goldman2012-05-121-6/+27
| | | | | | | | On Solaris, struct dirent is defined differently than Linux. The field containing the path name is of size 0, rather than NAME_MAX. So, we need to use a properly sized buffer on Solaris to avoid a stack overflow. Also fix some DIR* leaks on cleanup.
* compat: make p_realpath Windows implementation be a bit more POSIX compliant ↵nulltoken2012-05-081-1/+5
| | | | and fail if the provided path does not lead to an existing entry
* path: Make git_path_prettify() properly handle ENOTDIR errno valuenulltoken2012-05-081-1/+1
|
* Merge branch 'new-error-handling' into developmentVicent Martí2012-05-021-129/+138
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * buf: deploy git_buf_len()nulltoken2012-04-301-7/+7
| |
| * Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-7/+8
| | | | | | | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
| * Refactor git_repository_open with new optionsRussell Belfer2012-04-111-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new command `git_repository_open_ext` with extended options that control how searching for a repository will be done. The existing `git_repository_open` and `git_repository_discover` are reimplemented on top of it. We may want to change the default behavior of `git_repository_open` but this commit does not do that. Improve support for "gitdir" files where the work dir is separate from the repo and support for the "separate-git-dir" config. Also, add support for opening repos created with `git-new-workdir` script (although I have only confirmed that they can be opened, not that all functions work correctly). There are also a few minor changes that came up: - Fix `git_path_prettify` to allow in-place prettifying. - Fix `git_path_root` to support backslashes on Win32. This fix should help many repo open/discover scenarios - it is the one function called when opening before prettifying the path. - Tweak `git_config_get_string` to set the "out" pointer to NULL if the config value is not found. Allows some other cleanup. - Fix a couple places that should have been calling `git_repository_config__weakptr` and were not. - Fix `cl_git_sandbox_init` clar helper to support bare repos.
| * Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-1/+1
| | | | | | | | | | Also cleaned up some previously converted code that still had little things to polish.
| * Make git_path_root() cope with windows network pathsnulltoken2012-03-161-0/+9
| | | | | | | | Fix libgit2/libgit2sharp#125
| * Continue error conversionRussell Belfer2012-03-141-15/+22
| | | | | | | | | | | | | | This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
| * Convert attr and other files to new errorsRussell Belfer2012-03-141-67/+60
| | | | | | | | | | | | | | | | This continues to add other files to the new error handling style. I think the only real concerns here are that there are a couple of error return cases that I have converted to asserts, but I think that it was the correct thing to do given the new error style.
| * Migrating diff to new error handlingRussell Belfer2012-03-061-1/+1
| | | | | | | | | | | | Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
| * error-handling: RepositoryVicent Martí2012-03-071-17/+22
| | | | | | | | | | | | | | | | 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.
| * error-handling: ReferencesVicent Martí2012-03-061-41/+33
| | | | | | | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
| * refs: Error handling rework. WIPVicent Martí2012-03-031-11/+16
| |
* | GetFileAttributes does not work for utf-8 encoded pathsSven Strickroth2012-04-201-9/+1
|/ | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Fixing memory leaks indicated by valgrindRussell Belfer2012-03-021-0/+2
| | | | | This clears up the memory leaks that valgrind seems to find on my machine.
* Update diff to use iteratorsRussell Belfer2012-03-021-0/+43
| | | | | | | | | | | | | This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options.
* Fix readdir usage across platformsRussell Belfer2012-02-231-3/+3
| | | | | | This fixes the missing readdir_r from win32 and fixes other platforms to always use the reentrant readdir_r form for reading directory contents.
* Fix iterators based on pull request feedbackRussell Belfer2012-02-221-12/+8
| | | | | | | | | | This update addresses all of the feedback in pull request #570. The biggest change was to create actual linked list stacks for storing the tree and workdir iterator state. This cleaned up the code a ton. Additionally, all of the static functions had their 'git_' prefix removed, and a lot of other unnecessary changes were removed from the original patch.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-211-0/+65
| | | | | | | | | | | | | | | This create a new git_iterator type of object that provides a uniform interface for iterating over the index, an arbitrary tree, or the working directory of a repository. As part of this, git ignore support was extended to support push and pop of directory-based ignore files as the working directory is being traversed (so the array of ignores does not have to be recreated at each directory during traveral). There are a number of other small utility functions in buffer, path, vector, and fileops that are included in this patch that made the iterator implementation cleaner.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Move path related functions from fileops to pathRussell Belfer2012-01-171-1/+174
| | | | | | | | | | | 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).