summaryrefslogtreecommitdiff
path: root/src/refs.c
Commit message (Collapse)AuthorAgeFilesLines
* branch: Change `git_branch_delete` to take a refbranch-delete-refVicent Marti2012-08-261-1/+6
|
* oid: Explicitly include `oid.h` for the inlined CMPVicent Marti2012-08-091-0/+1
|
* trim whitespace when parsing loose refsRussell Belfer2012-08-091-36/+13
|
* Merge remote-tracking branch 'arrbee/tree-walk-fixes' into developmentVicent Marti2012-08-061-7/+15
|\ | | | | | | | | | | | | | | | | Conflicts: src/notes.c src/transports/git.c src/transports/http.c src/transports/local.c tests-clar/odb/foreach.c
| * Update iterators for consistency across libraryRussell Belfer2012-08-031-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
* | refs: drop git_reference_remote_tracking_from_branch()nulltoken2012-07-241-74/+0
| |
* | branch: introduce git_reference_is_branch()nulltoken2012-07-241-0/+7
|/
* refs: fix a memory leaknulltoken2012-07-121-0/+3
|
* refs: introduce git_reference_remote_tracking_from_branch()nulltoken2012-07-121-0/+74
|
* refs: remove seemingly useless giterr_clear() callnulltoken2012-07-071-2/+0
|
* refs: deploy git_reference_has_log()nulltoken2012-07-071-9/+3
|
* refs: add git_reference_has_log()nulltoken2012-07-071-0/+17
|
* refs: fix moving of the reflog when renaming a refnulltoken2012-07-071-0/+1
|
* references: introduce git_reference_foreach_glob()nulltoken2012-06-221-0/+37
|
* Add git_reset()nulltoken2012-06-071-0/+59
| | | | Currently supports Soft and Mixed modes.
* errors: Rename error codesbreaking-changesVicent Martí2012-05-181-4/+4
|
* errors: Rename the generic return codesVicent Martí2012-05-181-4/+4
|
* Properly tag all `enums` with a `_t`Vicent Martí2012-05-181-3/+3
|
* refs: git_reference_listall -> git_reference_listVicent Martí2012-05-181-1/+1
|
* buf: deploy git_buf_len()nulltoken2012-04-301-2/+2
|
* refs: fix unused-but-set warningMichael Schubert2012-04-271-0/+1
|
* Rename git_khash_str to git_strmap, etc.Russell Belfer2012-04-251-23/+23
| | | | | | This renamed `git_khash_str` to `git_strmap`, `git_hash_oid` to `git_oidmap`, and deletes `git_hashtable` from the tree, plus adds unit tests for `git_strmap`.
* Convert hashtable usage over to khashRussell Belfer2012-04-251-27/+45
| | | | | | | | | | | | | | | This updates khash.h with some extra features (like error checking on allocations, ability to use wrapped malloc, foreach calls, etc), creates two high-level wrappers around khash: `git_khash_str` and `git_khash_oid` for string-to-void-ptr and oid-to-void-ptr tables, then converts all of the old usage of `git_hashtable` over to use these new hashtables. For `git_khash_str`, I've tried to create a set of macros that yield an API not too unlike the old `git_hashtable` API. Since the oid hashtable is only used in one file, I haven't bother to set up all those macros and just use the khash APIs directly for now.
* Implement git_pool paged memory allocatorRussell Belfer2012-04-251-1/+1
| | | | | | | | | | | | | | | | | | 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.
* Rename to git_reference_name_to_oidRussell Belfer2012-04-231-1/+1
|
* Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-7/+7
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* Add git_reference_lookup_oid and lookup_resolvedRussell Belfer2012-04-171-51/+88
| | | | | | | | | | | | | | 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.
* branch: add git_branch_move()nulltoken2012-04-101-0/+9
|
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-4/+4
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-2/+2
| | | | | | | | | | | | | | 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.
* Migrating diff to new error handlingRussell Belfer2012-03-061-2/+1
| | | | | | 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: ReferencesVicent Martí2012-03-061-434/+374
| | | | | Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
* refs: Error handling rework. WIPVicent Martí2012-03-031-272/+239
|
* Clean up GIT_UNUSED macros on all platformsRussell Belfer2012-03-021-16/+13
| | | | | | | | | | | | | | | | | | | It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
* buffer: Unify `git_fbuffer` and `git_buf`Vicent Martí2012-02-271-24/+24
| | | | | | | | | | | | | | 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.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* refs: don't leak the packref when deleting/renamingCarlos Martín Nieto2012-01-191-2/+4
| | | | | When we remove the ref from the hashtable, we need to free the packref.
* Move path related functions from fileops to pathRussell Belfer2012-01-171-11/+11
| | | | | | | | | | | 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).
* Merge remote-tracking branch 'arrbee/git-attributes' into developmentVicent Martí2012-01-021-14/+1
|\ | | | | | | | | Conflicts: tests-clay/clay_main.c
| * Add APIs for git attributesRussell Belfer2011-12-201-14/+1
| | | | | | | | | | | | | | | | | | 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.
* | refs: Fix double freeVicent Martí2011-12-251-9/+11
|/ | | | Includes relevant Clay test
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-64/+119
| | | | | | | | | | | | | | | | | | | | 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.
* Rename all `_close` methodsVicent Marti2011-11-261-1/+1
| | | | | There's no difference between `_free` and `_close` semantics: keep everything with the same name to avoid confusions.
* repository: Change ownership semanticsVicent Marti2011-11-261-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #491 from schu/refs-cleanupVicent Martí2011-11-251-23/+13
|\ | | | | reference_rename() cleanup
| * reference_rename: don't delete the reflogschu2011-11-211-22/+9
| | | | | | | | | | | | | | | | reference_rename used to delete an old reflog file when renaming a reference to not confuse git.git. Don't do this anymore but let the user take care of writing a reflog entry. Signed-off-by: schu <schu-github@schulog.org>
| * reference_rename: make sure to rollbackschu2011-11-211-1/+4
| | | | | | | | | | | | | | Actually rollback when we can't create the new reference. Mark the rolled back reference as loose. Signed-off-by: schu <schu-github@schulog.org>
* | filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanupsRussell Belfer2011-11-221-2/+2
|/ | | | | | | | Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT and make git_filebuf_open and git_filebuf_cleanup safe to be called multiple times on the same buffer. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* refs: move GIT_PACKED_REFS_FILE_MODE to refs.h as GIT_PACKEDREFS_FILE_MODEBrodie Rao2011-11-161-3/+1
| | | | | This groups the #define with the other ref-related file modes, and it makes the name consistent with the other packed-refs definitions.
* refs: use 0666 permissions when writing packed-refs, not 0644Brodie Rao2011-11-161-1/+1
| | | | This matches stock Git's behavior.