summaryrefslogtreecommitdiff
path: root/src/path.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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).
* Fix several memory issuesRussell Belfer2012-01-111-1/+3
| | | | | | | 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.
* Convert git_path_walk_up to regular functionRussell Belfer2012-01-111-0/+42
| | | | | | 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.
* Restore portability to git_path_prettify.Russell Belfer2012-01-091-11/+5
| | | | | | | 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.
* Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into developmentVicent Martí2012-01-041-0/+74
|\ | | | | | | | | | | Conflicts: tests-clay/clay.h tests-clay/clay_main.c
| * path: add git_path_fromurl()nulltoken2011-12-281-0/+35
| |
| * path: add git__percent_decode()nulltoken2011-12-281-0/+35
|/
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-99/+68
| | | | | | | | | | | | | | | | | | | | 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.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-2/+2
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Tabify everythingVicent Marti2011-09-191-66/+66
| | | | | | 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.
* Cleanup legal dataVicent Marti2011-09-191-0/+6
| | | | | | | | | | 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.
* Fix for issue #387Jerome Lambourg2011-09-021-0/+10
|
* fileops: Drop `git_fileops_prettify_path`Vicent Marti2011-07-051-0/+50
| | | | | | | | | | 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.
* fileops: CleanupVicent Marti2011-07-051-0/+204
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.