src/path.c


Log

Author Commit Date CI Message
Russell Belfer 65025cb8 2013-03-18T17:24:13 Three submodule status bug fixes 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.
Russell Belfer 0c468633 2013-03-14T13:40:15 Improved tree iterator internals 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).
Philip Kelley 8c29dca6 2013-02-11T09:25:57 Fix some incorrect MSVC #ifdef's. Fixes #1305
Russell Belfer 23594c1d 2013-01-09T16:02:42 Add git_path_icmp to case-insensitive path cmp This adds git_path_icmp to complement git_path_cmp.
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Martin Woodward 9651fdc2 2013-01-03T22:28:59 Give proper license notice to code from Android 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
Martin Woodward 1c5b3a41 2013-01-03T22:28:59 Give proper license notice to code from Android 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
Michael Schubert 2e40c616 2013-01-02T16:27:22 path: ifdef GIT_WIN32 looks_like_network_computer_name()
nulltoken 50a762a5 2012-12-26T12:03:07 path: Teach UNC paths to git_path_dirname_r() Fix libgit2/libgit2sharp#256
Russell Belfer 91e7d263 2012-12-10T15:29:44 Fix iterator reset and add reset ranges 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.
Russell Belfer 7bf87ab6 2012-11-28T09:58:48 Consolidate text buffer functions 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).
Russell Belfer ad9a921b 2012-11-08T17:05:07 Rework checkout with new strategy options 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.
Vicent Marti 0f4c6175 2012-08-28T22:19:08 Add bounds checking to UTF-8 conversion
Russell Belfer ca1b6e54 2012-07-31T17:02:54 Add template dir and set gid to repo init 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.
Ben Straub bfc65634 2012-07-17T08:08:34 Merge branch 'development' into clone
Ben Straub 339f3d07 2012-07-11T19:17:07 Move is_dot_or_dotdotW into path.h.
Ben Straub 81167385 2012-07-11T15:33:19 Fix compile and workings on msvc. Signed-off-by: Ben Straub <bstraub@github.com>
Ben Straub d024419f 2012-07-11T10:40:53 Add git_path_is_empty_dir.
Ben Straub c3b5099f 2012-07-11T10:10:31 Add git_path_is_dot_or_dotdot. Also, remove some duplication in the clone test suite.
Russell Belfer b0fe1129 2012-07-10T15:13:30 Add path utilities to resolve relative paths 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.
Cyril Roelandt 296f60f5 2012-07-06T00:54:07 Fix libgit2 on GNU/Hurd. 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.
Vicent Marti 515a4c7c 2012-06-19T00:59:04 tree: Proper path comparison logic
Chris Young d043013f 2012-06-14T19:09:42 More changes resulting from pull request
Chris Young a8df98c6 2012-06-14T18:57:24 Updates from comments on OS4 compatibility pull request http://github.com/libgit2/libgit2/pull/766
Chris Young a21bb1aa 2012-06-13T23:28:51 Merge remote-tracking branch 'source/development' into development
Chris Young 96ef3d84 2012-06-13T23:16:14 Make this more generic and mergeable. Needs AmigaOS.cmake now from CMake package at OS4Depot, or contents below: --8<-- SET(AMIGA 1) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") --8<--
Chris Young 7d1983eb 2012-06-09T18:58:11 stop readdir parsing crashing
Russell Belfer ac971ecf 2012-06-08T14:08:34 Better fix for isalpha in drive letter detection Missed a place that used this and missed git__isalpha
Russell Belfer d17db71b 2012-06-08T13:56:53 isalpha is not great for UTF-8 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.
Chris Young aa5a92d1 2012-06-08T18:57:35 OS4 compatibility
Vicent Martí 904b67e6 2012-05-18T01:48:50 errors: Rename error codes
Vicent Martí e172cf08 2012-05-18T01:21:06 errors: Rename the generic return codes
Scott J. Goldman 6fb1c0b4 2012-05-09T23:45:55 Fix readdir_r() usage for Solaris 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.
nulltoken 9abb5bca 2012-05-07T13:58:01 compat: make p_realpath Windows implementation be a bit more POSIX compliant and fail if the provided path does not lead to an existing entry
nulltoken 46811561 2012-05-07T13:56:42 path: Make git_path_prettify() properly handle ENOTDIR errno value
Vicent Martí 40879fac 2012-05-02T15:59:02 Merge branch 'new-error-handling' into development 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
nulltoken fa6420f7 2012-04-29T21:46:33 buf: deploy git_buf_len()
Sven Strickroth eb6db16d 2012-04-20T20:00:59 GetFileAttributes does not work for utf-8 encoded paths Signed-off-by: Sven Strickroth <email@cs-ware.de>
Russell Belfer 44ef8b1b 2012-04-13T13:00:10 Fix warnings on 64-bit windows builds This fixes all the warnings on win64 except those in deps, which come from the regex code.
Russell Belfer 7784bcbb 2012-04-11T11:52:59 Refactor git_repository_open with new options 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.
Russell Belfer 0d0fa7c3 2012-03-16T15:56:01 Convert attr, ignore, mwindow, status to new errors Also cleaned up some previously converted code that still had little things to polish.
nulltoken 7b93079b 2012-03-16T15:16:52 Make git_path_root() cope with windows network paths Fix libgit2/libgit2sharp#125
Russell Belfer deafee7b 2012-03-14T17:36:15 Continue error conversion 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.
Russell Belfer ab43ad2f 2012-03-14T11:07:14 Convert attr and other files to new errors 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.
Russell Belfer ae9e29fd 2012-03-06T16:14:31 Migrating diff to new error handling Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
Vicent Martí cb8a7961 2012-03-07T00:02:55 error-handling: Repository 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.
Vicent Martí 1a481123 2012-02-17T00:13:34 error-handling: References Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
Vicent Martí 45d387ac 2012-02-15T16:54:17 refs: Error handling rework. WIP
Russell Belfer c19bc93c 2012-02-29T14:19:39 Fixing memory leaks indicated by valgrind This clears up the memory leaks that valgrind seems to find on my machine.
Russell Belfer 74fa4bfa 2012-02-28T16:14:47 Update diff to use iterators 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.
Russell Belfer 290f240e 2012-02-23T11:16:47 Fix readdir usage across platforms This fixes the missing readdir_r from win32 and fixes other platforms to always use the reentrant readdir_r form for reading directory contents.
Russell Belfer 0534641d 2012-02-22T15:15:35 Fix iterators based on pull request feedback 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.
Russell Belfer b6c93aef 2012-02-21T14:46:24 Uniform iterators for trees, index, and workdir 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.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
Russell Belfer 1744fafe 2012-01-17T15:49:47 Move path related functions from fileops to path 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).
Russell Belfer 1dbcc9fc 2012-01-11T21:07:16 Fix several memory issues This contains fixes for several issues discovered by MSVC and by valgrind, including some bad data access, some memory leakage (in where certain files were not being successfully added to the cache), and some code simplification.
Russell Belfer 0cfcff5d 2012-01-11T20:41:55 Convert git_path_walk_up to regular function This gets rid of the crazy macro version of git_path_walk_up and makes it into a normal function that takes a callback parameter. This turned out not to be too messy.
Russell Belfer 7e443f69 2012-01-09T15:46:06 Restore portability to git_path_prettify. It turns out that passing NULL for the second parameter of realpath(3) is not as portable as one might like. Notably, Mac OS 10.5 and earlier does not support it. So this moves us back to a large buffer to get the realpath info.
Vicent Martí f2114d0a 2012-01-04T22:40:59 Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into development Conflicts: tests-clay/clay.h tests-clay/clay_main.c
nulltoken 2017a15d 2011-12-27T16:03:28 path: add git_path_fromurl()
nulltoken 459e2dcd 2011-12-27T11:18:57 path: add git__percent_decode()
Russell Belfer 97769280 2011-11-30T11:27:15 Use git_buf for path storage instead of stack-based buffers 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.
Vicent Marti 3286c408 2011-10-28T14:51:13 global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
Vicent Marti 87d9869f 2011-09-19T03:34:49 Tabify everything There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
Vicent Marti bb742ede 2011-09-19T01:54:32 Cleanup legal data 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.
Jerome Lambourg 13bc2016 2011-09-02T13:00:27 Fix for issue #387
Vicent Marti 5ad739e8 2011-07-04T20:05:11 fileops: Drop `git_fileops_prettify_path` The old `git_fileops_prettify_path` has been replaced with `git_path_prettify`. This is a much simpler method that uses the OS's `realpath` call to obtain the full path for directories and resolve symlinks. The `realpath` syscall is the original POSIX call in Unix system and an emulated version under Windows using the Windows API.
Vicent Marti f79026b4 2011-07-04T11:43:34 fileops: Cleanup 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.