summaryrefslogtreecommitdiff
path: root/src/fileops.c
Commit message (Collapse)AuthorAgeFilesLines
* nsec: support NDK's crazy nanosecondsEdward Thomson2016-02-251-9/+8
| | | | | | | | Android NDK does not have a `struct timespec` in its `struct stat` for nanosecond support, instead it has a single nanosecond member inside the struct stat itself. We will use that and use a macro to expand to the `st_mtim` / `st_mtimespec` definition on other systems (much like the existing `st_mtime` backcompat definition).
* xplat: use st_mtimespec everywhere on macEdward Thomson2016-02-091-6/+0
|
* Detect stat's structureJacques Germishuys2015-11-201-8/+6
|
* Merge pull request #3170 from CmdrMoozy/nsec_fixCarlos Martín Nieto2015-11-121-4/+24
|\ | | | | git_index_entry__init_from_stat: set nsec fields in entry stats
| * index: don't populate nsec values if GIT_USE_NSEC is offAxel Rasmussen2015-10-011-0/+3
| |
| * apple: work around non-POSIX struct stat on OS X.Axel Rasmussen2015-09-181-6/+17
| |
| * diff/index: respect USE_NSEC for racily clean file detectionAxel Rasmussen2015-09-181-3/+9
| |
* | filebuf: use an internal buffercmn/config-checksumCarlos Martín Nieto2015-10-301-6/+10
| | | | | | | | | | | | This reduces the chances of a crash in the thread tests. This shouldn't affect general usage too much, since the main usage of these functions are to read into an empty buffer.
* | filebuf: use a checksum to detect file changesCarlos Martín Nieto2015-10-301-23/+26
|/ | | | | | Instead of relying on the size and timestamp, which can hide changes performed in the same second, hash the file content's when we care about detecting changes.
* `mkdir`: cope with root path on win32Edward Thomson2015-09-171-3/+4
|
* mkdir: chmod existing paths with `GIT_MKDIR_CHMOD`Edward Thomson2015-09-171-42/+49
|
* mkdir: find component paths for mkdir_relativeEdward Thomson2015-09-171-44/+134
| | | | | | | | | | | | `git_futils_mkdir` does not blindly call `git_futils_mkdir_relative`. `git_futils_mkdir_relative` is used when you have some base directory and want to create some path inside of it, potentially removing blocking symlinks and files in the process. This is not suitable for a general recursive mkdir within the filesystem. Instead, when `mkdir` is being recursive, locate the first existent parent directory and use that as the base for `mkdir_relative`.
* git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-171-11/+14
| | | | | | | | | | | | Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter assumes that we own everything beneath the base, as if it were being called with a base of the repository or working directory, and is tailored towards checkout and ensuring that there is no bogosity beneath the base that must be cleaned up. This is (at best) slow and (at worst) unsafe in the larger context of a filesystem where we do not own things and cannot do things like unlink symlinks that are in our way.
* fileops: set an error on write error for file copycmn/path-direach-cberrorCarlos Martín Nieto2015-05-171-0/+3
| | | | | | We set an error if we get an error when reading, but we don't bother setting an error message for write failing. This causes a cryptic error to be shown to the user when the target filesystem is full.
* fileops: set an error message if we fail to link a fileCarlos Martín Nieto2015-05-151-1/+2
| | | | | Now that `git_path_direach` lets us specify an error message to report, set an appropriate error message while linking.
* centralizing all IO buffer size valuesJ Wyman2015-05-111-1/+1
|
* mkdir-ext: Retry lstat on EEXIST racevmg/mkdir-extVicent Marti2015-03-191-5/+14
|
* Remove extra semicolon outside of a functionStefan Widgren2015-02-151-1/+1
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* Merge pull request #2895 from ethomson/alloc_overflowCarlos Martín Nieto2015-02-151-3/+20
|\ | | | | allocations: test for overflow of requested size
| * Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-5/+13
| | | | | | | | | | | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
| * p_read: ensure requested len is ssize_tEdward Thomson2015-02-121-0/+5
| | | | | | | | | | Ensure that the given length to `p_read` is of ssize_t and ensure that callers test the return as if it were an `ssize_t`.
| * allocations: test for overflow of requested sizeEdward Thomson2015-02-121-1/+5
| | | | | | | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* | Merge pull request #2897 from leoyanggit/fix_fileop_warningCarlos Martín Nieto2015-02-131-1/+1
|\ \ | |/ |/| Fix build warning on Android
| * Fix build warning on AndroidLeo Yang2015-02-121-1/+1
| | | | | | | | | | | | Always do a time_t cast on st_mtime. st_mtime on Android is not the type of time_t but has the same meaning which is the number of seconds past epoch.
* | Merge pull request #2866 from ethomson/checkout_perf2Carlos Martín Nieto2015-02-121-9/+26
|\ \ | | | | | | Checkout performance
| * | checkout: hold seen dir paths in a mapEdward Thomson2015-02-041-9/+26
| | |
* | | mkdir: respect the root pathEdward Thomson2015-02-051-11/+18
|/ / | | | | | | | | Don't try to strip trailing paths from the root directory on Windows (trying to create `C:` will fail).
* | checkout: remove files before writing new onesEdward Thomson2015-01-201-17/+48
| | | | | | | | | | | | | | On case insensitive filesystems, we may have files in the working directory that case fold to a name we want to write. Remove those files (by default) so that we will not end up with a filename that has the unexpected case.
* | mkdir: walk up tree to mkdirEdward Thomson2015-01-201-11/+25
| | | | | | | | | | | | Walk up the tree to mkdir, which is less immediately efficient, but allows us to look at intermediate directories that may need attention.
* | checkout: introduce git_checkout_perfdataEdward Thomson2015-01-201-16/+39
|/ | | | | Checkout can now provide performance data about the number of (some) syscalls performed using an optional callback.
* path: Fix `git_path_walk_up` to work with non-rooted pathsThe rugged tests are fragile2014-09-171-4/+4
|
* Allow mkdir helper to skip parent errorsrb/mkdir-allow-parent-failuresRussell Belfer2014-08-221-3/+5
| | | | | | | Our mkdir helper was failing is a parent directory was not accessible even if the child directory could be created. This changes the helper to keep trying child directories even when the parent is unwritable.
* fileops: allow linking files when copying directory structuresCarlos Martín Nieto2014-05-281-2/+4
| | | | | When passed the LINK_FILES flag, the recursive copy will hardlink files instead of copying them.
* 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
| | |