summaryrefslogtreecommitdiff
path: root/src/path.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3332 from phatblat/ben/doc-warningsCarlos Martín Nieto2015-08-011-1/+1
|\ | | | | Resolve documentation warnings
| * Fix remaining documentation warningsBen Chatelain2015-07-271-1/+1
| |
* | submodule, path: extract slash conversioncmn/submodule-backslashCarlos Martín Nieto2015-07-131-0/+5
|/ | | | Extract the backslash-to-slash conversion into a helper function.
* path: remove unnecessary readdir_r usagecmn/readdirCarlos Martín Nieto2015-06-151-1/+1
| | | | | | Arguably all uses of readdir_r are unnecessary, but in this case especially so, as the directory handle only exists within this function, so we don't race with anybody.
* diriter: actually use iconv on macEdward Thomson2015-05-011-84/+91
|
* git_path_diriter: use FindFirstFile in win32Edward Thomson2015-05-011-0/+26
| | | | | | | Using FindFirstFile and FindNextFile in win32 allows us to use the directory information that is returned, instead of us having to get the file attributes all over again, which is a distinct cost savings on win32.
* git_path_diriter: next shouldn't take path ptrEdward Thomson2015-05-011-1/+48
| | | | | | | | The _next method shouldn't take a path pointer (and a path_len pointer) as 100% of current users use the full path and ignore the filename. Plus let's add some docs and a unit test.
* git_path_dirload_with_stat: moved to fs_iteratorEdward Thomson2015-05-011-36/+0
|
* git_path_dirload: use git_path_diriterEdward Thomson2015-05-011-7/+3
|
* git_path: introduce 'git_path_diriter'Edward Thomson2015-05-011-0/+32
| | | | | Introduce a new `git_path_diriter` that can iterate directories efficiently for each platform.
* git_path_join_unrooted: return base lenEdward Thomson2015-01-201-3/+17
| | | | | | | The documentation for `git_path_join_unrooted` states that the base length will be returned, so that consumers like checkout know where to start creating directories instead of always creating directories at the directory root.
* Introduce core.protectHFS and core.protectNTFSEdward Thomson2014-12-171-10/+10
| | | | | | Validate HFS ignored char ".git" paths when `core.protectHFS` is specified. Validate NTFS invalid ".git" paths when `core.protectNTFS` is specified.
* checkout: disallow bad paths on HFSEdward Thomson2014-12-161-0/+5
| | | | | | | | HFS filesystems ignore some characters like U+200C. When these characters are included in a path, they will be ignored for the purposes of comparison with other paths. Thus, if you have a ".git" folder, a folder of ".git<U+200C>" will also match. Protect our ".git" folder by ensuring that ".git<U+200C>" and friends do not match it.
* checkout: disallow bad paths on win32Edward Thomson2014-12-161-0/+38
| | | | | | | | | | | | | | | Disallow: 1. paths with trailing dot 2. paths with trailing space 3. paths with trailing colon 4. paths that are 8.3 short names of .git folders ("GIT~1") 5. paths that are reserved path names (COM1, LPT1, etc). 6. paths with reserved DOS characters (colons, asterisks, etc) These paths would (without \\?\ syntax) be elided to other paths - for example, ".git." would be written as ".git". As a result, writing these paths literally (using \\?\ syntax) makes them hard to operate with from the shell, Windows Explorer or other tools. Disallow these.
* Spelling fixesWill Stamper2014-12-041-1/+1
|
* path: Fix `git_path_walk_up` to work with non-rooted pathsThe rugged tests are fragile2014-09-171-1/+1
|
* Introduce git_path_make_relativeEdward Thomson2014-09-021-0/+11
|
* Fix rejection of parent dir of negated ignoresRussell Belfer2014-08-081-0/+8
| | | | | | | While scanning through a directory hierarchy, this prevents a positive ignore match on a parent directory from blocking the scan of a directory when a negative match rule exists for files inside the directory.
* Merge pull request #2471 from jacquesg/compatibility-cleanupVicent Marti2014-08-071-0/+1
|\ | | | | Compatibility/Portability cleanup
| * Cleanup portability/compatibility layerJacques Germishuys2014-08-051-0/+1
| | | | | | | | | | | | | | * Removes mingw-compat.h * Cleans up separation of compiler/platform idiosyncrasies * Unifies mingw/msvc stat structures and functions * (Tries to) hide more compiler specific implementation details (even in our internal API)
* | Handle local file:/// paths on WindowsEdward Thomson2014-07-111-0/+1
|/ | | | | Windows can't handle a path like `/c:/foo`; when turning file:/// URIs into local paths, we must strip the leading slash.
* clone: re-use the local transport's path resolutioncmn/path-to-pathCarlos Martín Nieto2014-06-031-0/+3
| | | | | | Whe already worked out the kinks with the function used in the local transport. Expose it and make use of it in the local clone method instead of trying to work it out again.
* Pass unconverted data when iconv doesn't like itRussell Belfer2014-05-081-0/+2
| | | | | | | | | | | | | | When using Iconv to convert unicode data and iconv doesn't like the source data (because it thinks that it's not actual UTF-8), instead of stopping the operation, just use the unconverted data. This will generally do the right thing on the filesystem, since that is the source of the non-UTF-8 path data anyhow. This adds some tests for creating and looking up branches with messy Unicode names. Also, this takes the helper function that was previously internal to `git_repository_init` and makes it into `git_path_does_fs_decompose_unicode` which is a useful in tests to understand what the expected results should be.
* Submodule sync refactoringRussell Belfer2014-04-011-0/+8
| | | | | | Turns out there was already a helper to do what I wanted to do, so I just made it so that I could use it for sync and switched to that instead.
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* iconv: Do not fake an API when iconv is not availableVicent Marti2013-11-011-10/+0
|
* Move path prefixed help to path.hEdward Thomson2013-10-161-0/+28
|
* Make reference lookups apply precomposeunicodeRussell Belfer2013-10-081-5/+0
| | | | | | | | | | | | | | | | | | | | | Before these changes, looking up a reference would return the same precomposed or decomposed form of the reference name that was used to look it up, so on MacOS which ignores the difference between the two, a single reference could be looked up either way and git_reference_name would return the form of the name that was used to look it up! This change makes lookup always return the precomposed name if core.precomposeunicode is set regardless of which version was used to look it up. The reference iterator was already returning the precomposed form from earlier work. This also updates the CMakeLists.txt rules for enabling iconv usage because the clar tests for this code were actually not being activated properly with the old version. Finally, this moves git_repository_reset_filesystem from include/ git2/repository.h to include/git2/sys/repository.h since it is not really a function that normal library users should have to think about very often.
* More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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-0/+52
| | | | | | | | 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.
* Initial iconv hookup for precomposed unicodeRussell Belfer2013-10-031-23/+26
| | | | | | | | | | | | | | | | | | | | 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-2/+8
| | | | | | 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.
* Clean up some documentationCarlos Martín Nieto2013-07-231-2/+0
| | | | clang's docparser highlighted these.
* Improved tree iterator internalsRussell Belfer2013-03-141-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* Add git_path_icmp to case-insensitive path cmpRussell Belfer2013-01-151-1/+6
| | | | This adds git_path_icmp to complement git_path_cmp.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix iterator reset and add reset rangesRussell Belfer2012-12-101-4/+19
| | | | | | | 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.
* Add template dir and set gid to repo initRussell Belfer2012-08-221-0/+14
| | | | | | | | | | | | | | | | | 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 pull request #778 from ben/cloneVicent Martí2012-08-191-0/+22
|\ | | | | Clone
| * Merge branch 'development' into cloneBen Straub2012-07-171-0/+23
| |\
| * | Move is_dot_or_dotdotW into path.h.Ben Straub2012-07-111-0/+7
| | |
| * | Add git_path_is_empty_dir.Ben Straub2012-07-111-1/+8
| | |
| * | Add git_path_is_dot_or_dotdot.Ben Straub2012-07-111-0/+8
| | | | | | | | | | | | Also, remove some duplication in the clone test suite.
* | | Update iterators for consistency across libraryRussell Belfer2012-08-031-0/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
* | Add path utilities to resolve relative pathsRussell Belfer2012-07-101-0/+23
|/ | | | | | | | | | | | | | | | 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 warnings on 64-bit windows buildsRussell Belfer2012-04-171-2/+2
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-2/+2
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Continue error conversionRussell Belfer2012-03-141-0/+5
| | | | | | | 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.
* error-handling: ReferencesVicent Martí2012-03-061-11/+13
| | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
* Update diff to use iteratorsRussell Belfer2012-03-021-0/+22
| | | | | | | | | | | | | 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.