summaryrefslogtreecommitdiff
path: root/src/refdb.c
Commit message (Collapse)AuthorAgeFilesLines
* refdb: use GIT_ASSERTEdward Thomson2020-11-271-13/+30
|
* refdb: avoid unlimited spinning in case of symref cyclespks/refdb-refactoringsPatrick Steinhardt2020-07-121-13/+6
| | | | | | | | | | | | To determine whether another reflog entry needs to be written for HEAD on a reference update, we need to see whether HEAD directly or indirectly points to the reference we're updating. The resolve logic is currently completely unbounded except an error occurs, which effectively means that we'd be spinning forever in case we have a symref loop in the repository refdb. Let's fix the issue by using `git_refdb_resolve` instead, which is always bounded.
* refdb: return resolved symbolic refs pointing to nonexistent refsPatrick Steinhardt2020-07-121-1/+9
| | | | | | | | | | | | | In some cases, resolving references requires us to also know about the final symbolic reference that's pointing to a nonexistent branch, e.g. in an empty repository where the main branch is yet unborn but HEAD already points to it. Right now, the resolving logic is thus split up into two, where one is the new refdb implementation and the second one is an ad-hoc implementation inside "refs.c". Let's extend `git_refdb_resolve` to also return such final dangling references pointing to nonexistent branches so we can deduplicate the resolving logic.
* refs: move resolving of references into the refdbPatrick Steinhardt2020-07-121-0/+48
| | | | | | | | | Resolving of symbolic references is currently implemented inside the "refs" layer. As a result, it's hard to call this function from low-level parts that only have a refdb available, but no repository, as the "refs" layer always operates on the repository-level. So let's move the function into the generic "refdb" implementation to lift this restriction.
* refdb: extract function to check whether to append HEAD to the reflogPatrick Steinhardt2020-07-121-0/+49
| | | | | | | | | | | | The logic to determine whether a reflog entry should be for the HEAD reference is non-trivial. Currently, the only user of this is the filesystem-based refdb, but with the advent of the reftable refdb we're going to add a second user that's interested in having the same behaviour. Let's pull out a new function that checks whether a given reference should cause a entry to be written to the HEAD reflog as a preparatory step.
* refdb: extract function to check whether a reflog should be writtenPatrick Steinhardt2020-07-121-0/+37
| | | | | | | | | | The logic to determine whether a reflog should be written is non-trivial. Currently, the only user of this is the filesystem-based refdb, but with the advent of the reftable refdb we're going to add a second user that's interested in having the same behaviour. Let's pull out a new function that checks whether a given reference should cause a reflog to be written as a preparatory step.
* refdb: ensure all mandatory functions are provided at setup timeEtienne Samson2019-09-051-0/+10
|
* refdb: check the version of the backend we're about to setEtienne Samson2019-09-051-0/+2
|
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-3/+3
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-3/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* refdb: bubble up locked files on the read sideCarlos Martín Nieto2016-11-141-2/+4
| | | | | | On Windows we can find locked files even when reading a reference or the packed-refs file. Bubble up the error in this case as well to allow callers on Windows to retry more intelligently.
* refdb and odb backends must provide `free` functionArthur Schreiber2015-10-011-6/+2
| | | | | | | | | As refdb and odb backends can be allocated by client code, libgit2 can’t know whether an alternative memory allocator was used, and thus should not try to call `git__free` on those objects. Instead, odb and refdb backend implementations must always provide their own `free` functions to ensure memory gets freed correctly.
* Introduce reference transactionsCarlos Martín Nieto2014-09-301-0/+19
| | | | | | | | | A transaction allows you to lock multiple references and set up changes for them before applying the changes all at once (or as close as the backend supports). This can be used for replication purposes, or for making sure some operations run when the reference is locked and thus cannot be changed.
* Fix remaining init_options inconsistenciesRussell Belfer2014-05-021-9/+4
| | | | | There were a couple of "init_opts()" functions a few more cases of structure initialization that I somehow missed.
* Added function-based initializers for every options struct.Matthew Bowen2014-03-051-0/+12
| | | | The basic structure of each function is courtesy of arrbee.
* refs: placeholder conditional deleteCarlos Martín Nieto2014-02-051-2/+2
| | | | We don't actually pass the old value yet.
* refdb: add conditional symbolic updatesCarlos Martín Nieto2014-02-051-2/+2
| | | | | Add a parameter to the backend to allow checking for the old symbolic target.
* refs: conditional ref updatesCarlos Martín Nieto2014-02-051-2/+2
| | | | Allow updating references if the old value matches the given one.
* refs: expose has_log() on the backendCarlos Martín Nieto2013-12-091-0/+7
| | | | | | The frontend used to look at the file directly, but that's obviously not the right thing to do. Expose it on the backend and use that function instead.
* refs: expose a way to ensure a ref has a logCarlos Martín Nieto2013-12-091-0/+7
| | | | | | Sometimes (e.g. stash) we want to make sure that a log will be written, even if it's not in one of the standard locations. Let's make that easier.
* reflog: integrate into the ref writingCarlos Martín Nieto2013-11-231-3/+4
| | | | | | | | | | | | Whenever a reference is created or updated, we need to write to the reflog regardless of whether the user gave us a message, so we shouldn't leave that to the ref frontend, but integrate it into the backend. This also eliminates the race between ref update and writing to the reflog, as we protect the reflog with the ref lock. As an additional benefit, this reflog append on the backend happens by appending to the file instead of parsing and rewriting it.
* refdb: add a `message` parameter for appending to the logCarlos Martín Nieto2013-11-231-4/+5
| | | | This is as yet unused.
* reflog: move the reflog implementation into refdb_fsCarlos Martín Nieto2013-10-021-0/+16
| | | | | | | | | | References and their logs are logically coupled, let's make it so in the code by moving the fs-based reflog implementation to live next to the fs-based refs one. As part of the change, make the function take names rather than references, as only the names are relevant when looking up and handling reflogs.
* 'del' instead of 'delete' for the poor C++ usersEdward Thomson2013-09-241-1/+1
|
* util: It's called `memzero`Vicent Marti2013-06-121-1/+1
|
* Merge remote-tracking branch 'arrbee/minor-paranoia' into developmentVicent Marti2013-06-121-0/+1
|\
| * Add safe memset and use itRussell Belfer2013-06-071-1/+1
| | | | | | | | | | | | This adds a `git__memset` routine that will not be optimized away and updates the places where I memset() right before a free() call to use it.
| * Zero memory for major objects before freeingRussell Belfer2013-05-311-0/+1
| | | | | | | | | | | | | | By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
* | RefcountingVicent Marti2013-05-301-3/+3
| |
* | ...Aaaand this worksVicent Marti2013-05-301-4/+30
| |
* | What are the chances, reallyVicent Marti2013-05-291-57/+23
| |
* | Liike thisVicent Marti2013-05-281-5/+14
|/
* Introduce a glob-filtering iteratorCarlos Martín Nieto2013-05-111-6/+36
| | | | | If the backend doesn't provide support for it, the matching is done in refdb on top of a normal iterator.
* refs: remove the OID/SYMBOLIC filteringCarlos Martín Nieto2013-05-111-48/+0
| | | | | | | | | Nobody should ever be using anything other than ALL at this level, so remove the option altogether. As part of this, git_reference_foreach_glob is now implemented in the frontend using an iterator. Backends will later regain the ability of doing the glob filtering in the backend.
* Make sure the ref iterator works in an repo without physical presenceCarlos Martín Nieto2013-05-111-1/+5
|
* refs: introduce an iteratorCarlos Martín Nieto2013-05-111-0/+24
| | | | This allows us to get a list of reference names in a loop instead of callbacks.
* Move git_reference__alloc to include/git2/sysRussell Belfer2013-04-211-16/+12
| | | | | | Create a new include/git2/sys/refs.h and move the reference alloc functions there. Also fix some documentation issues and some minor code cleanups.
* Move refdb_backend to include/git2/sysRussell Belfer2013-04-211-4/+5
| | | | | | | | | This moves most of the refdb stuff over to the include/git2/sys directory, with some minor shifts in function organization. While I was making the necessary updates, I also removed the trailing whitespace in a few files that I modified just because I was there and it was bugging me.
* alloc doesn't take a refdb; git_refdb_free nicely in the testsEdward Thomson2013-04-191-2/+13
|
* dec refcount on refdb instead of always freeingEdward Thomson2013-04-121-1/+9
|
* immutable references and a pluggable ref databaseEdward Thomson2013-03-071-0/+177