src/repository.c


Log

Author Commit Date CI Message
Vicent Martí 0f49200c 2012-05-09T04:37:02 msvc: Do not use `isspace` Locale-aware bullshit bitting my ass again yo
nulltoken 464cf248 2012-05-07T17:25:16 repository: ensure git_repository_discover() returns ENOTFOUND when unable to find a repository given the constraints
Russell Belfer f917481e 2012-05-03T16:37:25 Support reading attributes from index Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
nulltoken fa6420f7 2012-04-29T21:46:33 buf: deploy git_buf_len()
Russell Belfer 2bc8fa02 2012-04-17T10:14:24 Implement git_pool paged memory allocator This adds a `git_pool` object that can do simple paged memory allocation with free for the entire pool at once. Using this, you can replace many small allocations with large blocks that can then cheaply be doled out in small pieces. This is best used when you plan to free the small blocks all at once - for example, if they represent the parsed state from a file or data stream that are either all kept or all discarded. There are two real patterns of usage for `git_pools`: either for "string" allocation, where the item size is a single byte and you end up just packing the allocations in together, or for "fixed size" allocation where you are allocating a large object (e.g. a `git_oid`) and you generally just allocation single objects that can be tightly packed. Of course, you can use it for other things, but those two cases are the easiest.
Vicent Martí f9f2344b 2012-04-23T17:28:11 Merge pull request #632 from arrbee/win64-cleanup Code clean up, including fixing warnings on Windows 64-bit build
Vicent Martí 4795807a 2012-04-23T17:25:11 Merge pull request #637 from nulltoken/issue/odb-refcount Fix git_repository_set_odb() refcount issue
nulltoken baf861a5 2012-04-23T11:07:19 Fix git_repository_set_odb() refcount issue git_repository_free() calls git_odb_free() if the owned odb is not null. According to the doc, when setting a new odb through git_repository_set_odb() the caller has to take care of releasing the odb by himself.
Vicent Martí 54e4d0f2 2012-04-18T17:34:52 Merge pull request #629 from nulltoken/issue/index-refcount Index refcount issue
Russell Belfer 44ef8b1b 2012-04-13T13:00:10 Fix warnings on 64-bit windows builds This fixes all the warnings on win64 except those in deps, which come from the regex code.
Russell Belfer f201d613 2012-04-13T10:33:14 Add git_reference_lookup_oid and lookup_resolved Adds a new public reference function `git_reference_lookup_oid` that directly resolved a reference name to an OID without returning the intermediate `git_reference` object (hence, no free needed). Internally, this adds a `git_reference_lookup_resolved` function that combines looking up and resolving a reference. This allows us to be more efficient with memory reallocation. The existing `git_reference_lookup` and `git_reference_resolve` are reimplmented on top of the new utility and a few places in the code are changed to use one of the two new functions.
Carlos Martín Nieto 146f5c75 2012-04-14T15:09:29 repo: plug a couple of leaks
nulltoken c1aefb35 2012-04-14T14:13:17 Fix git_repository_set_index() refcount issue git_repository_free() calls git_index_free() if the owned index is not null. According to the doc, when setting a new index through git_repository_set_index() the caller has still to take care of releasing the index by itself. In order to cope with this, this fix makes sure the index refcount is incremented when a new repository is being plugged a new index.
Russell Belfer 7784bcbb 2012-04-11T11:52:59 Refactor git_repository_open with new options Add a new command `git_repository_open_ext` with extended options that control how searching for a repository will be done. The existing `git_repository_open` and `git_repository_discover` are reimplemented on top of it. We may want to change the default behavior of `git_repository_open` but this commit does not do that. Improve support for "gitdir" files where the work dir is separate from the repo and support for the "separate-git-dir" config. Also, add support for opening repos created with `git-new-workdir` script (although I have only confirmed that they can be opened, not that all functions work correctly). There are also a few minor changes that came up: - Fix `git_path_prettify` to allow in-place prettifying. - Fix `git_path_root` to support backslashes on Win32. This fix should help many repo open/discover scenarios - it is the one function called when opening before prettifying the path. - Tweak `git_config_get_string` to set the "out" pointer to NULL if the config value is not found. Allows some other cleanup. - Fix a couple places that should have been calling `git_repository_config__weakptr` and were not. - Fix `cl_git_sandbox_init` clar helper to support bare repos.
nulltoken b78fb64d 2012-04-10T14:03:47 repository: make git_repository_set_workdir() prettify the path it is being passed
Russell Belfer bfc9ca59 2012-03-28T16:45:36 Added submodule API and use in status When processing status for a newly checked out repo, it is possible that there will be submodules that have not yet been initialized. The only way to distinguish these from untracked directories is to have some knowledge of submodules. This commit adds a new submodule API which, given a name or path, can determine if it appears to be a submodule and can give information about the submodule.
Russell Belfer 0d0fa7c3 2012-03-16T15:56:01 Convert attr, ignore, mwindow, status to new errors Also cleaned up some previously converted code that still had little things to polish.
Russell Belfer deafee7b 2012-03-14T17:36:15 Continue error conversion 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.
Vicent Martí cb8a7961 2012-03-07T00:02:55 error-handling: Repository 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.
Vicent Martí 9d160ba8 2012-03-06T01:37:56 diff: Fix rebase breackage
Vicent Martí 1a481123 2012-02-17T00:13:34 error-handling: References Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
Vicent Martí f2c25d18 2012-03-02T20:08:00 config: Implement a proper cvar cache
Vicent Martí 13224ea4 2012-02-27T04:28:31 buffer: Unify `git_fbuffer` and `git_buf` 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.
Russell Belfer 0534641d 2012-02-22T15:15:35 Fix iterators based on pull request feedback This update addresses all of the feedback in pull request #570. The biggest change was to create actual linked list stacks for storing the tree and workdir iterator state. This cleaned up the code a ton. Additionally, all of the static functions had their 'git_' prefix removed, and a lot of other unnecessary changes were removed from the original patch.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
nulltoken 99abb79d 2012-02-03T12:45:43 repository: ensure that the path to the .git directory ends with a forward slash when opening a repository through a working directory path This fixes an issue which was detected while using one of the libgit2 bindings [0]. The lack of the trailing forward slash led the name of references returned by git_reference_listall() to be prefixed with a forward slash. [0]: https://github.com/libgit2/libgit2sharp/pull/108
nulltoken 5663e61a 2012-01-25T16:44:21 repository: add minimal reinitialization of repository This currently only ensures that the version of the repository format isn't greater than zero.
Russell Belfer 1744fafe 2012-01-17T15:49:47 Move path related functions from fileops to path 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).
nulltoken 0b44c065 2012-01-17T14:35:04 repository: add the invalid repository path to the error message
Vicent Martí 7a704309 2012-01-02T09:58:39 Merge remote-tracking branch 'drizzd/diff-index-tests' into development Conflicts: tests-clay/clay.h tests-clay/clay_main.c
Clemens Buchacher e4592538 2011-12-29T13:12:51 allow opening index in bare repo The git.git implementation allows this, and there is no reason not to.
Russell Belfer 73b51450 2011-12-28T23:28:50 Add support for macros and cache flush API. 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.
Russell Belfer ee1f0b1a 2011-12-16T10:56:43 Add APIs for git attributes This adds APIs for querying git attributes. In addition to the new API in include/git2/attr.h, most of the action is in src/attr_file.[hc] which contains utilities for dealing with a single attributes file, and src/attr.[hc] which contains the implementation of the APIs that merge all applicable attributes files.
Russell Belfer 97769280 2011-11-30T11:27:15 Use git_buf for path storage instead of stack-based buffers 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.
Vicent Marti a5123ea8 2011-11-28T20:00:42 repository: Do not double-increment refcounts
Vicent Marti c94785a9 2011-11-26T08:35:56 repository: Use `git_config` when initializing Thanks @carlosmn!
Vicent Marti 9462c471 2011-11-25T08:16:26 repository: Change ownership semantics The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
Vicent Marti d4a0b124 2011-10-30T21:58:33 refs: Partial rewrite for read-only refs This new version of the references code is significantly faster and hopefully easier to read. External API stays the same. A new method `git_reference_reload()` has been added to force updating a memory reference from disk. In-memory references are no longer updated automagically -- this was killing us. If a reference is deleted externally and the user doesn't reload the memory object, nothing critical happens: any functions using that reference should fail gracefully (e.g. deletion, renaming, and so on). All generated references from the API are read only and must be free'd by the user. There is no reference counting and no traces of generated references are kept in the library. There is no longer an internal representation for references. There is only one reference struct `git_reference`, and symbolic/oid targets are stored inside an union. Packfile references are stored using an optimized struct with flex array for reference names. This should significantly reduce the memory cost of loading the packfile from disk.
schu 75abd2b9 2011-08-11T19:38:13 Free all used references in the source tree Since references are not owned by the repository anymore we have to free them manually now. Signed-off-by: schu <schu-github@schulog.org>
Vicent Martí 89fb8f02 2011-10-28T19:04:23 Merge pull request #456 from brodie/perm-fixes Create objects, indexes, and directories with the right file permissions
Vicent Marti 3286c408 2011-10-28T14:51:13 global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
Brodie Rao ce8cd006 2011-09-07T15:32:44 fileops/repository: create (most) directories with 0777 permissions 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.
Brodie Rao 33127043 2011-10-14T14:18:02 fileops/posix: replace usage of "int mode" with "mode_t mode" Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t.
Carlos Martín Nieto 40fe5fbe 2011-09-22T22:50:36 Make repo config loading automatic or completely explicit git_repository_config wants to take the global and system paths again so that one can be explicit if needed. The git_repository_config_autoload function is provided for the cases when it's good enough for the library to guess where those files are located. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Carlos Martín Nieto c3fe018b 2011-09-20T10:02:11 repsitory: use better error code if path is too short for discover GIT_EOVERFLOW means something different. Use GIT_ESHORTBUFFER. On the way, remove a redundant sizeof(char). Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Martí 71a4c1f1 2011-09-18T20:07:59 Merge pull request #384 from kiryl/warnings Add more -W flags to CFLAGS
Vicent Martí 6640266e 2011-09-18T19:58:22 Merge pull request #398 from carlosmn/config-autohome git_repository_config: open global config file automatically
Vicent Marti bb742ede 2011-09-19T01:54:32 Cleanup legal data 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.
nulltoken 3601c4bf 2011-08-08T13:40:17 repository: Add git_repository_head()
Carlos Martín Nieto f9d4b0c3 2011-09-12T17:25:46 git_repository_config: open global config file automatically If the global configuration file is missing, it is ignored. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Kirill A. Shutemov 51d00446 2011-08-30T23:33:59 CMakefile: add -Wstrict-prototypes and fix warnings Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti 6f1d23b2 2011-08-30T11:27:36 repository: Fix signed/unsigned comp.
Kirill A. Shutemov 932669b8 2011-08-25T14:22:57 Drop STRLEN() macros There is no need in STRLEN macros. Compilers can do this trivial optimization on its own. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Carlos Martín Nieto 44daec42 2011-08-03T22:03:57 Bind the configuration and remotes to a repository Configurations when taken from a repository and remotes should be identifiable as coming from a particular repository. This allows us to reduce the amount of variables that the user has to keep track of. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
schu cf7dc39b 2011-07-24T15:58:10 repository.c: remove obsolete TODO marker Signed-off-by: schu <schu-github@schulog.org>
nulltoken 7a44cc41 2011-07-05T11:00:32 repository: fix typo'ed assert
Vicent Marti 17837602 2011-07-05T15:38:26 repository: Fix unused parameter in Unix systems
nulltoken ed72182b 2011-07-05T01:09:37 Fix MSVC compilation issue
Vicent Marti 1bc83ff1 2011-07-05T01:33:39 repository: Cleanup initialization
Vicent Marti eec3fe39 2011-07-05T01:11:33 fileutils: Finish dropping the old `prettify_path`
Vicent Marti 19ac1ed7 2011-07-04T21:33:26 fileops: Fix stat() on directories for W32 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.
Vicent Marti 5ad739e8 2011-07-04T20:05:11 fileops: Drop `git_fileops_prettify_path` 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.
Vicent Marti f79026b4 2011-07-04T11:43:34 fileops: Cleanup Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.
Kirill A. Shutemov 932d1baf 2011-06-30T19:52:34 cleanup: remove trailing spaces Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
nulltoken 6ac91dfe 2011-06-29T14:06:18 Hide ".git" directory on Windows upon creation of a non bare repository Directory which name starts with a dot are hidden on Linux platforms. This patch makes libgit2 behaves similarly on Windows.
Vicent Marti 0f489fb2 2011-06-28T21:30:15 repo: Fix git_repository_is_empty
Vicent Marti c682886e 2011-06-28T21:09:22 repo: Rename HEAD-related methods
Vicent Martí ccd59372 2011-06-28T10:44:19 Merge pull request #279 from carlosmn/detached-orphan Add detached and orphan convenience functions
Vicent Marti d5afc039 2011-06-28T19:15:48 Remove redundant methods from the API A bunch of redundant methods have been removed from the external API. - All the reference/tag creation methods with `_f` are gone. The force flag is now passed as an argument to the normal create methods. - All the different commit creation methods are gone; commit creation now always requires a `git_commit` pointer for parents and a `git_tree` pointer for tree, to ensure that corrupted commits cannot be generated. - All the different tag creation methods are gone; tag creation now always requires a `git_object` pointer to ensure that tags are not created to inexisting objects.
Carlos Martín Nieto 35502d2e 2011-06-28T13:55:00 Add git_repository_is_detached, git_repository_is_orphan Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti 2a406ab5 2011-06-18T02:08:56 config: Fix sorting of repository config files
Vicent Marti 07ff8817 2011-06-18T00:39:39 config: Cleanup external API Do not mess with environment variables anymore. The new external API has more helper methods, and everything is explicit.
Carlos Martín Nieto b22d1479 2011-06-16T17:46:06 Add git_repository_config API This function puts the global and repository configurations in one git_config object and gives it to the user. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 9ba9e513 2011-06-16T19:54:37 Parse the repo's configuration when we load it It's not enough to load the config, we also need to explicitely parse it after we create it. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Martí fe79750b 2011-06-06T18:27:29 Merge pull request #236 from Jopie64/development Fix build errors on MSVC
Vicent Martí 7d170a4b 2011-06-06T18:11:15 Merge pull request #231 from Romain-Geissler/discovery-path-v2 [Discovery path] Fix and tests
Romain Geissler efcc87c9 2011-06-06T10:02:07 Repository: A little fix in error code. GIT_ENOTFOUND is returned when a gitfile is malformed and GIT_ENOTAREPO when the pointed dir is not a repo. Fixed tests so that it check the right error code.
Romain Geissler 5ec05d07 2011-06-06T01:26:01 Repository: Fixed retrieve_device return type.
Johan 't Hart 393a9f9e 2011-06-06T00:33:23 Fix build errors on MSVC
Romain Geissler f2a60854 2011-06-05T00:18:34 Repository: Fixed the path returned by read_gitfile (remove trailing slashes)
Romain Geissler 8b05e780 2011-06-05T00:17:26 Repository: Fixed a bug in read_gitfile (proprely remove trailings newlines)
Vicent Marti 602ee38b 2011-06-04T20:44:14 repository: Export all internal paths
Romain Geissler 9d9bab5c 2011-06-04T16:28:39 Repository: Fixed some errors with ceiling_dirs in git_repository_discover. Now the ceiling_dirs are compared with their symbolic free version (like base_path). The ceiling dirs check is now performed after getting the parent directory.
Romain Geissler fd0574e5 2011-06-04T01:01:20 Repository: Added the git_repository_discover function that finds by itself the git directory that manage a given directory path.
Romain Geissler 222cf1d4 2011-06-04T00:14:37 Repository: Splitted the repository destructor into a helper part (only free directories path) and the complete public destructor.
Romain Geissler 6a01b6bd 2011-06-04T00:10:55 Repository: Added read_gitfile that allows you to read a .git file and extract the git directory path.
Romain Geissler f2e6b877 2011-06-03T23:44:38 Repository: Added some util functions that we'll need to discover repository path. retrieve_device returns the file device for a given path (so that we can detect device change while walking through parent directories). abspath returns a canonicalized path, symbolic link free. retrieive_ceiling_directories_offset returns the biggest path offset that path match in the ceiling directory list (so that we can stop at ceiling directories).
unknown 26a98ec8 2011-06-03T20:47:56 Fileops: Added a fourth argument to the path prettifying functions to use an alternate basepath. Fixed a Windows TO-DO in the prettifying functions.
Vicent Martí 50b7334e 2011-06-01T09:58:21 Merge pull request #206 from nulltoken/topic/is-bare Add git_repository_is_bare() accessor
Vicent Marti f7e59c4d 2011-06-01T18:34:21 index: Change the memory management for repo indexes The `git_repository_index` call now returns a brand new index that must be manually free'd.
nulltoken fa9bcd81 2011-05-24T21:48:07 Add git_repository_is_bare() accessor
Jakob Pfender 4f664a1b 2011-05-19T14:51:16 repository.c: Move to new error handling mechanism
Vicent Marti b3d94069 2011-05-17T14:51:42 repository: Properly free the index on close
nulltoken 81201a4c 2011-05-15T06:57:34 Move cache.c to the new error handling
nulltoken 3abe3bba 2011-05-14T16:05:33 Move repository.c to the new error handling
schu 402a47a7 2011-04-26T11:29:05 Fix -Wunused-but-set-variable warnings As of gcc 4.6 -Wall includes -Wunused-but-set-variable. Use GIT_UNUSED or remove actually unused variables to prevent those warnings.
nulltoken 4a34b3a9 2011-04-09T15:49:44 Add two new accessors to the repository git_repository_path() and git_repository_workdir() respectively return the path to the git repository and the working directory. Those paths are absolute and normalized.
Vicent Marti 41233c40 2011-04-08T12:42:18 Add new method `git_repository_is_empty`
nulltoken b153589b 2011-04-03T18:31:45 Make reinitializing a repository return GIT_ENOTIMPLEMENTED instead of GIT_SUCCESS
nulltoken c90292ce 2011-03-18T16:56:43 Change gitfo_prettify_dir_path() and gitfo_prettify_file_path() behavior Those functions now return prettified rooted path.