summaryrefslogtreecommitdiff
path: root/src/odb.c
Commit message (Collapse)AuthorAgeFilesLines
* Honor `core.fsyncObjectFiles`ethomson/fsyncEdward Thomson2017-03-021-5/+23
|
* giterr_set: consistent error messagesEdward Thomson2016-12-291-12/+12
| | | | | | | | 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
* common: cast precision specifiers to intPatrick Steinhardt2016-11-141-1/+1
|
* odb: only provide the empty treeEdward Thomson2016-08-051-5/+0
| | | | | | | Only provide the empty tree internally, which matches git's behavior. If we provide the empty blob then any users trying to write it with libgit2 would omit it from actually landing in the odb, which appear to git proper as a broken repository (missing that object).
* odb: freshen existing objects when writingEdward Thomson2016-08-041-3/+44
| | | | | | When writing an object, we calculate its OID and see if it exists in the object database. If it does, we need to freshen the file that contains it.
* Merge pull request #3223 from ethomson/applyEdward Thomson2016-06-251-1/+1
|\ | | | | Reading patch files
| * delta: move delta application to delta.cEdward Thomson2016-05-261-1/+1
| | | | | | | | | | | | | | Move the delta application functions into `delta.c`, next to the similar delta creation functions. Make the `git__delta_apply` functions adhere to other naming and parameter style within the library.
* | fix error message SHA truncation in git_odb__error_notfound()Sim Domingo2016-06-201-1/+1
|/
* odb: Try to lookup headers in all backends before passthroughvmg/expand-fixesVicent Marti2016-03-091-5/+20
|
* odb: Refactor `git_odb_expand_ids`Vicent Marti2016-03-091-21/+26
|
* odb: Implement new helper to read types without refreshingVicent Marti2016-03-091-45/+104
|
* odb: Handle corner cases in `git_odb_expand_ids`Vicent Marti2016-03-091-22/+27
| | | | | | | | | | The old implementation had two issues: 1. OIDs that were too short as to be ambiguous were not being handled properly. 2. If the last OID to expand in the array was missing from the ODB, we would leak a `GIT_ENOTFOUND` error code from the function.
* git_odb_expand_ids: accept git_odb_expand_id arrayEdward Thomson2016-03-081-32/+19
| | | | Take (and write to) an array of a struct, `git_odb_expand_id`.
* git_odb_expand_ids: rename func, return the typeEdward Thomson2016-03-081-5/+11
|
* git_odb_exists_many_prefixes: query odb for multiple short idsEdward Thomson2016-03-071-12/+68
| | | | | Query the object database for multiple objects at a time, given their object ID (which may be abbreviated) and optional type.
* odb: improved not found error messagesEdward Thomson2016-03-071-7/+10
| | | | | When looking up an abbreviated oid, show the actual (abbreviated) oid the caller passed instead of a full (but ambiguously truncated) oid.
* odb: Prioritize alternate backendsvmg/odb-lookupsVicent Marti2015-10-141-4/+8
| | | | | | | | | | | | For most real use cases, repositories with alternates use them as main object storage. Checking the alternate for objects before the main repository should result in measurable speedups. Because of this, we're changing the sorting algorithm to prioritize alternates *in cases where two backends have the same priority*. This means that the pack backend for the alternate will be checked before the pack backend for the main repository *but* both of them will be checked before any loose backends.
* odb: Be smarter when refreshing backendsVicent Marti2015-10-141-75/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the current implementation of ODB backends, each backend is tasked with refreshing itself after a failed lookup. This is standard Git behavior: we want to e.g. reload the packfiles on disk in case they have changed and that's the reason we can't find the object we're looking for. This behavior, however, becomes pathological in repositories where multiple alternates have been loaded. Given that each alternate counts as a separate backend, a miss in the main repository (which can potentially be very frequent in cases where object storage comes from the alternate) will result in refreshing all its packfiles before we move on to the alternate backend where the object will most likely be found. To fix this, the code in `odb.c` has been refactored as to perform the refresh of all the backends externally, once we've verified that the object is nowhere to be found. If the refresh is successful, we then perform the lookup sequentially through all the backends, skipping the ones that we know for sure weren't refreshed (because they have no refresh API). The on-disk pack backend has been adjusted accordingly: it no longer performs refreshes internally.
* refdb and odb backends must provide `free` functionArthur Schreiber2015-10-011-2/+1
| | | | | | | | | 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.
* odb: cast to long long for printfEdward Thomson2015-06-291-1/+1
|
* Fixed build warnings on Xcode 6.1Pierre-Olivier Latour2015-06-021-1/+1
|
* Merge pull request #3118 from libgit2/cmn/stream-sizeEdward Thomson2015-05-131-4/+9
|\ | | | | odb: make the writestream's size a git_off_t
| * odb: make the writestream's size a git_off_tcmn/stream-sizeCarlos Martín Nieto2015-05-131-4/+9
| | | | | | | | | | | | | | | | | | | | Restricting files to size_t is a silly limitation. The loose backend writes to a file directly, so there is no issue in using 63 bits for the size. We still assume that the header is going to fit in 64 bytes, which does mean quite a bit smaller files due to the run-length encoding, but it's still a much larger size than you would want Git to handle.
* | odb: reverse the default backend prioritiescmn/backends-prioCarlos Martín Nieto2015-05-131-3/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | We currently first look in the loose object dir and then in the packs for objects. When performing operations on recent history this has a higher likelihood of hitting, but when we deal with operations which look further back into the past, we start spending a large amount of time getting ENOTENT from `access`. Reversing the priorities means that long-running operations can get to their objects faster, as we can look at the index data we have in memory (or rather mapped) to figure out whether we have an object, which is faster than going out to the filesystem. The packed backend already implements an optimistic read algorithm by first looking at the packs we know about and only going out to disk to referesh if the object is not found which means that in the case where we do have the object (which will be in the majority for anything that traverses the graph) we can avoid going to to disk entirely to determine whether an object exists. Operations which look at recent history may take a slight impact, but these would be operations which look a lot less at object and thus take less time regardless.
* centralizing all IO buffer size valuesJ Wyman2015-05-111-1/+1
|
* Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-7/+8
| | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
* odb__hashlink: check st.st_size before castingEdward Thomson2015-02-121-9/+9
|
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-0/+1
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* win32: remember to cleanup our hash_ctxEdward Thomson2014-12-091-0/+1
|
* odb: `git_odb_object` contents are never NULLvmg/emptyVicent Marti2014-11-211-2/+2
| | | | | | | This is a contract that we made in the library and that we need to uphold. The contents of a blob can never be NULL because several parts of the library (including the filter and attributes code) expect `git_blob_rawcontent` to always return a valid pointer.
* odb: hardcode the empty blob and treecmn/empty-objectsCarlos Martín Nieto2014-11-081-1/+23
| | | | | | | | | | | | | | | | | | | | | git hardocodes these as objects which exist regardless of whether they are in the odb and uses them in the shell interface as a way of expressing the lack of a blob or tree for one side of e.g. a diff. In the library we use each language's natural way of declaring a lack of value which makes a workaround like this unnecessary. Since git uses it, it does however mean each shell application would need to perform this check themselves. This makes it common work across a range of applications and an issue with compatibility with git, which fits right into what the library aims to provide. Thus we introduce the hard-coded empty blob and tree in the odb frontend. These hard-coded objects are checked for before going to the backends, but after the cache check, which means the second time they're used, they will be treated as normal cached objects instead of creating new ones.
* odb: clear backend errors on successful readCarlos Martín Nieto2014-05-231-0/+1
| | | | | We go through the different backends in order, so it's not an error if at least one of the backends has the data we want.
* 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.
* Don't redefine the same callback types, their signatures may changeJacques Germishuys2014-04-211-1/+1
|
* Merge pull request #2178 from libgit2/rb/fix-short-idEdward Thomson2014-03-311-7/+17
|\ | | | | Fix git_odb_short_id and git_odb_exists_prefix bugs
| * Fix a number of git_odb_exists_prefix bugsRussell Belfer2014-03-101-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The git_odb_exists_prefix API was not dealing correctly when a later backend returned GIT_ENOTFOUND even if an earlier backend had found the object. Additionally, the unit tests were not properly exercising the API and had a couple mistakes in checking the results. Lastly, since the backends are not expected to behavior correctly unless all bytes of the short id are zero except for the prefix, this makes the ODB prefix APIs explicitly clear out the extra bytes so the user doesn't have to be as careful.
* | Fix wrong assertionLinquize2014-03-211-1/+1
|/ | | | Fixes issue #2196
* Added function-based initializers for every options struct.Matthew Bowen2014-03-051-0/+11
| | | | The basic structure of each function is courtesy of arrbee.
* Merge pull request #2159 from libgit2/rb/odb-exists-prefixVicent Marti2014-03-061-1/+55
|\ | | | | Add ODB API to check for existence by prefix and object id shortener
| * Check short OID len in odb, not in backendsRussell Belfer2014-03-051-1/+0
| |
| * Add exists_prefix to ODB backend and ODB APIRussell Belfer2014-03-041-0/+55
| |
* | ODB writing fails gracefully when unsupportedEdward Thomson2014-03-051-6/+12
|/ | | | If no ODB backends support writing, we should fail gracefully.
* odb: handle NULL pointers passed to git_odb_stream_freeBrodie Rao2014-01-121-0/+3
| | | | Signed-off-by: Brodie Rao <brodie@sf.io>
* Allow backend consumers to specify file modeEdward Thomson2013-11-041-1/+1
|
* Merge pull request #1891 from libgit2/cmn/fix-thin-packsVicent Martí2013-10-281-1/+1
|\ | | | | Add support for thin packs
| * indexer: fix thin packsCarlos Martín Nieto2013-10-041-1/+1
| | | | | | | | | | | | When given an ODB from which to read objects, the indexer will attempt to inject the missing bases at the end of the pack and update the header and trailer to reflect the new contents.
* | Implement `git_odb_object_dup`Vicent Marti2013-10-221-0/+7
|/
* Merge pull request #1840 from linquize/warningVicent Martí2013-09-211-2/+1
|\ | | | | Fix warning
| * Fix warningLinquize2013-09-191-2/+1
| |
* | Merge git_buf and git_bufferRussell Belfer2013-09-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | This makes the git_buf struct that was used internally into an externally available structure and eliminates the git_buffer. As part of that, some of the special cases that arose with the externally used git_buffer were blended into the git_buf, such as being careful about git_buf objects that may have a NULL ptr and allowing for bufs with a valid ptr and size but zero asize as a way of referring to externally owned data.