summaryrefslogtreecommitdiff
path: root/src/fileops.c
Commit message (Collapse)AuthorAgeFilesLines
* Add bounds checking to UTF-8 conversionutf8-winVicent Marti2012-08-281-4/+5
|
* windows: Keep UTF-8 on the stack yoVicent Marti2012-08-281-21/+10
|
* Fix memory leak in cp_rRussell Belfer2012-08-241-0/+1
|
* Fix errors on Win32 with new repo initRussell Belfer2012-08-241-1/+1
|
* Some cleanup suggested during reviewRussell Belfer2012-08-221-17/+10
| | | | | | | | | | This cleans up a number of items suggested during code review with @vmg, including: * renaming "outside repo" config API to `git_config_open_default` * killing the `git_config_open_global` API * removing the `git_` prefix from the static functions in fileops * removing some unnecessary functionality from the "cp" command
* fix missing validation and type cast warningRussell Belfer2012-08-221-1/+4
|
* Add template dir and set gid to repo initRussell Belfer2012-08-221-68/+270
| | | | | | | | | | | | | | | | | 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.
* Add git_repository_init_ext for power inittersRussell Belfer2012-08-221-0/+10
| | | | | | | The extended version of repository init adds support for many of the things that you can do with `git init` and sets up structures that will make it easier to extend further in the future.
* Merge pull request #778 from ben/cloneVicent Martí2012-08-191-0/+11
|\ | | | | Clone
| * Checkout: obey core.symlinks.Ben Straub2012-07-171-0/+11
| |
* | config: set the error code if we can't find the global/system configCarlos Martín Nieto2012-07-231-0/+4
|/
* refs: deep unfound ref returns ENOTFOUNDnulltoken2012-07-071-1/+1
|
* Make errors for system and global files consistentRussell Belfer2012-05-251-4/+16
| | | | | | | The error codes from failed lookups of system and global files on Windows were not consistent with the codes returned on other platforms. This makes the error detection patterns match and adds a unit test for the various errors.
* 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.