summaryrefslogtreecommitdiff
path: root/src/fileops.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix broken logic for attr cache invalidationRussell Belfer2014-04-171-0/+14
| | | | | | | The checks to see if files were out of date in the attibute cache was wrong because the cache-breaker data wasn't getting stored correctly. Additionally, when the cache-breaker triggered, the old file data was being leaked.
* Attribute file cache refactorRussell Belfer2014-04-171-3/+1
| | | | | | | This is a big refactoring of the attribute file cache to be a bit simpler which in turn makes it easier to enforce a lock around any updates to the cache so that it can be used in a threaded env. Tons of changes to the attributes and ignores code.
* Move system directory cache out of utilsEdward Thomson2014-02-241-220/+0
|
* Cleanups, renames, and leak fixesRussell Belfer2013-12-121-3/+10
| | | | | | | | | This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-30/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-39/+36
| | | | | | | | | | | 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.
* Plug configuration file search paths leaksnulltoken2013-11-051-1/+1
|
* move mode_t to filebuf_open instead of _commitEdward Thomson2013-11-041-1/+10
|
* preserve windows error numbers as wellEdward Thomson2013-11-011-2/+2
|
* Merge pull request #1562 from libgit2/cmn/refs-namespace-lookupVicent Martí2013-10-111-1/+7
|\ | | | | Provide the user with a more useful error code when a looking up a reference which name points to a namepace
| * futils: return GIT_ENOTFOUND when trying to read a directoryCarlos Martín Nieto2013-10-111-1/+7
| | | | | | | | | | This lets the reference code return not-found when the user asks to look up a reference when in fact they pass a namespace.
* | More filemode cleanups for FAT on MacOSRussell Belfer2013-10-081-52/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Initial iconv hookup for precomposed unicodeRussell Belfer2013-10-031-44/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #1858 from linquize/win32-template-dirVicent Martí2013-09-171-3/+20
|\ \ | | | | | | Configurable template dir for Win32
| * | Can load default template directoryLinquize2013-09-181-1/+8
| | |
| * | Can guess win32 git template dirLinquize2013-09-171-1/+11
| | |
| * | Refactor git_win32__find_system_dirs() to extract "etc\\" as subpath parameterLinquize2013-09-171-1/+1
| | |
* | | Add clar helpers for testing file equalityRussell Belfer2013-09-171-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | These are a couple of new clar helpers for testing that a file has expected contents that I extracted from the checkout code. Actually wrote this as part of an abandoned earlier attempt at a new filters API, but it will be useful now for some of the tests I'm going to write.
* | | Add simple global shutdown hooksRussell Belfer2013-09-171-7/+10
|/ / | | | | | | | | | | | | | | | | | | Increasingly there are a number of components that want to do some cleanup at global shutdown time (at least if there are not going to be memory leaks). This creates a very simple system of shutdown hooks that will be invoked by git_threads_shutdown. Right now, the maximum number of hooks is hardcoded, but since adding a hook is not a public API, it should be fine and I thought it was better to start off with really simple code.
* | path: Make direach() return EUSER on callback errornulltoken2013-09-101-9/+21
| |
* | Add more file mode permissions macrosRussell Belfer2013-09-051-2/+2
| | | | | | | | | | | | This adds some more macros for some standard operations on file modes, particularly related to permissions, and then updates a number of places around the code base to use the new macros.
* | index: report when it's lockedCarlos Martín Nieto2013-08-191-1/+1
|/ | | | | | | Report the index being locked with its own error code in order to be able to differentiate, as a locked index is typically the result of a crashed process or concurrent access, both of which often require user intervention to fix.
* Merge pull request #1781 from brodie/brodie/stat-before-openVicent Martí2013-08-141-5/+12
|\ | | | | fileops: stat() before open()ing in git_futils_readbuffer_updated()
| * fileops: stat() before open()ing in git_futils_readbuffer_updated()Brodie Rao2013-08-131-5/+12
| | | | | | | | | | | | | | | | | | | | | | This reverts refactoring done in 13224ea4aad9a1b3c9cc4c992ceaea9af623e047 that introduces a performance regression for NFS when reading files that don't exist. open() forces a cache invalidation on NFS, while stat()ing a file just uses the cache and is very quick. To give a specific example, say you have a repo with a thousand packed refs. Before this change, looking up every single one ould incur a thousand slow open() calls. With this change, it's a thousand fast stat() calls.
* | Rename git__win32_path fns to git_win32_pathRussell Belfer2013-08-131-1/+1
| |
* | 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.
* Fix possible double closeSven Strickroth2013-07-271-0/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Fix warning message about mismatched typesRussell Belfer2013-07-221-5/+3
|
* preload configuration pathsEdward Thomson2013-07-111-0/+14
|
* Revert "Work around reparse point stat issues"Sven Strickroth2013-06-251-2/+1
| | | | This reverts commit 32c12ea6a9cafd76a746af2e2be9366c95752f5b.
* Merge pull request #1670 from arrbee/open-cloexecVicent Martí2013-06-241-2/+4
|\ | | | | Add O_CLOEXEC to open calls
| * Add O_CLOEXEC to open callsRussell Belfer2013-06-221-2/+4
| |
* | Work around reparse point stat issuesRussell Belfer2013-06-241-1/+2
|/ | | | | | | | | In theory, p_stat should never return an S_ISLNK result, but due to the current implementation on Windows with mount points it is possible that it will. For now, work around that by allowing a link in the path to a directory being created. If it is really a problem, then the issue will be caught on the next iteration of the loop, but typically this will be the right thing to do.
* fileops: fix invalid readyorah2013-06-141-1/+1
|
* Make mkdir early exit cases clearerRussell Belfer2013-06-051-35/+30
| | | | | | | | | | | | There are two places where git_futils_mkdir should exit early or at least do less. The first is when using GIT_MKDIR_SKIP_LAST and having that flag leave no directory left to create; it was being handled previously, but the behavior was subtle. Now I put in a clear explicit check that exits early in that case. The second is when there is no directory to create, but there is a valid path that should be verified. I shifted the logic a bit so we'll be better about not entering the loop than that happens.
* Simplify git_futils_mkdirRussell Belfer2013-06-051-46/+36
| | | | | This routine was (is) pretty complicated, but given the recent changes, it seemed like it could be simplified a bit.
* I'm a dickVicent Marti2013-06-051-7/+7
|
* Ensure git_futils_mkdir won't mkdir rootRussell Belfer2013-06-051-13/+14
| | | | | | | This makes sure that git_futils_mkdir always skips over the root directory at a minimum, even on platforms where the root is not simply '/'. Also, this removes the GIT_WIN32 ifdef in favor of making EACCES as a potentially recoverable error on all platforms.
* Allow creation of directories under the volume root in Win32Jameson Miller2013-06-051-5/+13
| | | | | | | | | | | We ran into an issue where cloning a repository to a folder directly underneath the root of a volume (e.g. 'd:\libgit2') would fail with an access denied error. This was traced down to a call to make a directory that is the root (e.g. 'd:') could return an error indicated access denied instead of an error indicating the path already exists. This change now handles the access denied error on Win32 and checks for the existence of the folder.
* Add more diff rename detection testsRussell Belfer2013-05-201-0/+26
| | | | | | | | | | This adds a bunch more rename detection tests including checks vs the working directory, the new exact match options, some more whitespace variants, etc. This also adds a git_futils_writebuffer helper function and uses it in checkout. This is mainly added because I wanted an easy way to write out a git_buf to disk inside my test code.
* Merge pull request #1526 from arrbee/cleanup-error-return-without-msgVicent Martí2013-05-061-1/+3
|\ | | | | Make sure error messages are set for most error returns
| * Report stat error when checking if file modifiedRussell Belfer2013-05-011-1/+3
| |
* | allow checkout to proceed when a dir to be removed is in use (win32)Edward Thomson2013-05-031-2/+2
|/
* Merge pull request #1417 from arrbee/opts-for-pathsVicent Martí2013-03-181-49/+160
|\ | | | | Implement opts interface for global/system file search paths
| * Fixes and cleanupsRussell Belfer2013-03-181-3/+3
| | | | | | | | | | Get rid of some dead code, tighten things up a bit, and fix a bug with core::env test.
| * Switch search paths to classic delimited stringsRussell Belfer2013-03-181-38/+88
| | | | | | | | | | | | | | | | | | | | | | | | This switches the APIs for setting and getting the global/system search paths from using git_strarray to using a simple string with GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment PATH variable would contain. This makes it simpler to get and set the value. I also added code to expand "$PATH" when setting a new value to embed the old value of the path. This means that I no longer require separate actions to PREPEND to the value.