summaryrefslogtreecommitdiff
path: root/src/fileops.c
Commit message (Collapse)AuthorAgeFilesLines
* Clean up system file finding tests on Win32env-expansionRussell Belfer2012-05-241-1/+1
|
* windows: Properly expand all environment variablesVicent Martí2012-05-241-103/+51
|
* Merge pull request #726 from arrbee/utf16-home-dirRussell Belfer2012-05-241-3/+42
|\ | | | | Get user's home dir in UTF-16 clean manner
| * Get user's home dir in UTF-16 clean mannerRussell Belfer2012-05-241-3/+42
| | | | | | | | | | | | | | On Windows, we are having problems with home directories that have non-ascii characters in them. This rewrites the relevant code to fetch environment variables as UTF-16 and then explicitly map then into UTF-8 for our internal usage.
* | fileops: Make git_futils_mkdir_r() able to cope with Windows network pathsnulltoken2012-05-231-7/+15
|/ | | | Partially fix libgit2/libgit2sharp#153
* Merge pull request #681 from scottjg/solaris-fixesVicent Martí2012-05-141-1/+1
|\ | | | | Fix build/runtime issues on Solaris
| * Fix rmdir() usage on SolarisScott J. Goldman2012-05-101-1/+1
| | | | | | | | | | On Solaris, rmdir() throws EEXIST if the folder is not empty, so just add one more case to check for that, alongside ENOTEMPTY.
* | Add cache busting to attribute cacheRussell Belfer2012-05-101-3/+0
|/ | | | | | | | | | | This makes the git attributes and git ignores cache check stat information before using the file contents from the cache. For cached files from the index, it checks the SHA of the file instead. This should reduce the need to ever call `git_attr_cache_flush()` in most situations. This commit also fixes the `git_status_should_ignore` API to use the libgit2 standard parameter ordering.
* Typedefs don't have enum in frontCarlos Martín Nieto2012-04-111-2/+2
|
* fileops: Make git_futils_mkdir_r() able to skip non-empty directoriesnulltoken2012-04-101-6/+17
|
* reference: Fix creation of references with extended ASCII characters in ↵nulltoken2012-04-011-1/+12
| | | | their name
* Migrate index, oid, and utils to new errorsRussell Belfer2012-03-191-2/+2
| | | | | | | | | | | | This includes a few cleanups that came up while converting these files. This commit introduces a could new git error classes, including the catchall class: GITERR_INVALID which I'm using as the class for invalid and out of range values which are detected at too low a level of library to use a higher level classification. For example, an overflow error in parsing an integer or a bad letter in parsing an OID string would generate an error in this class.
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-2/+8
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Continue error conversionRussell Belfer2012-03-141-27/+56
| | | | | | | 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.
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-5/+5
| | | | | | | | | | | | | | This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
* Merge pull request #590 from arrbee/new-error-handlingRussell Belfer2012-03-071-11/+6
|\ | | | | Migrating diff to new error handling
| * Migrating diff to new error handlingRussell Belfer2012-03-061-11/+6
| | | | | | | | | | | | 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: ConfigVicent Martí2012-03-071-7/+8
|/
* error-handling: RepositoryVicent Martí2012-03-071-18/+20
| | | | | | | | 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-29/+44
| | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
* Fix a win32 warning messageRussell Belfer2012-03-021-2/+5
|
* Update diff to use iteratorsRussell Belfer2012-03-021-4/+9
| | | | | | | | | | | | | 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.
* buffer: Unify `git_fbuffer` and `git_buf`Vicent Martí2012-02-271-42/+32
| | | | | | | | | | | | | | This makes so much sense that I can't believe it hasn't been done before. Kill the old `git_fbuffer` and read files straight into `git_buf` objects. Also: In order to fully support 4GB files in 32-bit systems, the `git_buf` implementation has been changed from using `ssize_t` for storage and storing negative values on allocation failure, to using `size_t` and changing the buffer pointer to a magical pointer on allocation failure. Hopefully this won't break anything.
* Uniform iterators for trees, index, and workdirRussell Belfer2012-02-211-0/+18
| | | | | | | | | | | | | | | 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-175/+6
| | | | | | | | | | | 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 bug in dir_for_pathRussell Belfer2012-01-111-1/+2
| | | | | The last checkin accidentally broke dir_for_path by propogating the dirname return code even when there was no error.
* Allow ignores (and attribs) for nonexistent filesRussell Belfer2012-01-111-6/+18
| | | | | | This fixes issue 532 that attributes (and gitignores) could not be checked for files that don't exist. It should be possible to query such things regardless of the existence of the file.
* Initial implementation of gitignore supportRussell Belfer2012-01-111-0/+12
| | | | | | | | Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).
* Fix Windows specific off-by-one errornulltoken2012-01-041-1/+1
| | | | The value returned by MultiByteToWideChar includes the NULL termination character.
* Add support for macros and cache flush API.Russell Belfer2011-12-291-0/+131
| | | | | | | | | | | | | | Add support for git attribute macro definitions. Also, add support for cache flush API to clear the attribute file content cache when needed. Additionally, improved the handling of global and system files, making common utility functions in fileops and converting config and attr to both use the common functions. Adds a bunch more tests and fixed some memory leaks. Note that adding macros required me to use refcounted attribute assignment definitions, which complicated, but probably improved memory usage.
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-67/+114
| | | | | | | | | | | | | | | | | | | | 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.
* Implement p_renameCarlos Martín Nieto2011-11-071-24/+1
| | | | | | Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Merge pull request #456 from brodie/perm-fixesVicent Martí2011-10-281-10/+9
|\ | | | | Create objects, indexes, and directories with the right file permissions
| * fileops/repository: create (most) directories with 0777 permissionsBrodie Rao2011-10-141-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To further match how Git behaves, this change makes most of the directories libgit2 creates in a git repo have a file mode of 0777. Specifically: - Intermediate directories created with git_futils_mkpath2file() have 0777 permissions. This affects odb_loose, reflog, and refs. - The top level folder for bare repos is created with 0777 permissions. - The top level folder for non-bare repos is created with 0755 permissions. - /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are created with 0777 permissions. Additionally, the following changes have been made: - fileops functions that create intermediate directories have grown a new dirmode parameter. The only exception to this is filebuf's lock_file(), which unconditionally creates intermediate directories with 0777 permissions when GIT_FILEBUF_FORCE is set. - The test runner now sets the umask to 0 before running any tests. This ensurses all file mode checks are consistent across systems. - t09-tree.c now does a directory permissions check. I've avoided adding this check to other tests that might reuse existing directories from the prefabricated test repos. Because they're checked into the repo, they have 0755 permissions. - Other assorted directories created by tests have 0777 permissions.
| * fileops/posix: replace usage of "int mode" with "mode_t mode"Brodie Rao2011-10-141-5/+5
| | | | | | | | | | Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t.
* | global: Properly use `git__` memory wrappersVicent Marti2011-10-281-3/+3
|/ | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Implment p_access and use it in git_fileutils_existsCarlos Martín Nieto2011-09-231-1/+1
| | | | Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Tabify everythingVicent Marti2011-09-191-6/+6
| | | | | | 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.
* compat: Move `mkstemp` to the POSIX compat layerVicent Marti2011-08-301-11/+3
|
* Add git_futils_readbuffer_updatedCarlos Martín Nieto2011-07-231-8/+35
| | | | | | | | | | | | | | This extends the git_fuitls_readbuffer function to only read in if the file's modification date is later than the given one. Some code paths want to check a file's modification date in order to decide whether they should read it or not. If they do want to read it, another stat call is done by futils. This function combines these two operations so we avoid one stat call each time we read a new or updated file. The git_futils_readbuffer functions is now a wrapper around the new function. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* refs: Cleanup reference renamingVicent Marti2011-07-061-12/+18
| | | | | | | `git_futils_rmdir_r`: rename, clean up. `git_reference_rename`: cleanup. Do not use 3x4096 buffers on the stack or things will get ugly very fast. We can reuse the same buffer.
* Remove duplicated recursive directory removal related codenulltoken2011-07-061-5/+8
|
* Fix windows specific issuesnulltoken2011-07-061-0/+2
| | | | | - msvc compilation warnings - not released file handle that prevents file removal
* fileops: add git_futils_rmdir_recurs()schu2011-07-061-0/+25
| | | | | | | git_futils_rmdir_recurs() shall remove the given directory and all subdirectories. This happens only if the directories are empty. Signed-off-by: schu <schu-github@schulog.org>
* fileops: add convenience function is_dot_or_dotdot()schu2011-07-061-7/+2
| | | | Signed-off-by: schu <schu-github@schulog.org>
* fileutils: Finish dropping the old `prettify_path`Vicent Marti2011-07-051-147/+0
|
* fileops: Fix stat() on directories for W32Vicent Marti2011-07-051-21/+10
| | | | | | | | The `stat` methods were having issues when called with a trailing slash in Windows platforms. We now use GetFileAttributes() where possible, which doesn't have this restriction.
* fileops: Drop `git_fileops_prettify_path`Vicent Marti2011-07-051-28/+10
| | | | | | | | | | 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.