summaryrefslogtreecommitdiff
path: root/src/pack-objects.c
Commit message (Collapse)AuthorAgeFilesLines
* indexer: use git_indexer_progress throughoutEdward Thomson2019-02-221-3/+3
| | | | | Update internal usage of `git_transfer_progress` to `git_indexer_progreses`.
* oidmap: introduce high-level setter for key/value pairsPatrick Steinhardt2019-02-151-13/+15
| | | | | | | | | | | | | | | Currently, one would use either `git_oidmap_insert` to insert key/value pairs into a map or `git_oidmap_put` to insert a key only. These function have historically been macros, which is why their syntax is kind of weird: instead of returning an error code directly, they instead have to be passed a pointer to where the return value shall be stored. This does not match libgit2's common idiom of directly returning error codes.Furthermore, `git_oidmap_put` is tightly coupled with implementation details of the map as it exposes the index of inserted entries. Introduce a new function `git_oidmap_set`, which takes as parameters the map, key and value and directly returns an error code. Convert all trivial callers of `git_oidmap_insert` and `git_oidmap_put` to make use of it.
* oidmap: introduce high-level getter for valuesPatrick Steinhardt2019-02-151-10/+3
| | | | | | | | | | | | | | The current way of looking up an entry from a map is tightly coupled with the map implementation, as one first has to look up the index of the key and then retrieve the associated value by using the index. As a caller, you usually do not care about any indices at all, though, so this is more complicated than really necessary. Furthermore, it invites for errors to happen if the correct error checking sequence is not being followed. Introduce a new high-level function `git_oidmap_get` that takes a map and a key and returns a pointer to the associated value if such a key exists. Otherwise, a `NULL` pointer is returned. Adjust all callers that can trivially be converted.
* maps: use uniform lifecycle management functionsPatrick Steinhardt2019-02-151-4/+2
| | | | | | | | | | | | | | | | Currently, the lifecycle functions for maps (allocation, deallocation, resize) are not named in a uniform way and do not have a uniform function signature. Rename the functions to fix that, and stick to libgit2's naming scheme of saying `git_foo_new`. This results in the following new interface for allocation: - `int git_<t>map_new(git_<t>map **out)` to allocate a new map, returning an error code if we ran out of memory - `void git_<t>map_free(git_<t>map *map)` to free a map - `void git_<t>map_clear(git<t>map *map)` to remove all entries from a map This commit also fixes all existing callers.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-28/+28
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-16/+16
| | | | Use the new object_type enumeration names within the codebase.
* khash: remove intricate knowledge of khash typesPatrick Steinhardt2018-11-281-6/+4
| | | | | | | Instead of using the `khiter_t`, `git_strmap_iter` and `khint_t` types, simply use `size_t` instead. This decouples code from the khash stuff and makes it possible to move the khash includes into the implementation files.
* fix check if blob is uninteresting when inserting tree to packbuilderAnders Borum2018-10-011-1/+1
| | | | | | | | Blobs that have been marked as uninteresting should not be inserted into packbuilder when inserting a tree. The check as to whether a blob was uninteresting looked at the status for the tree itself instead of the blob. This could cause significantly larger packfiles.
* indexer: introduce options struct to `git_indexer_new`Patrick Steinhardt2018-06-221-1/+5
| | | | | | | | | | We strive to keep an options structure to many functions to be able to extend options in the future without breaking the API. `git_indexer_new` doesn't have one right now, but we want to be able to add an option for enabling strict packfile verification. Add a new `git_indexer_options` structure and adjust callers to use that.
* pack-objects: make `git_walk_object` internal to pack-objectsPatrick Steinhardt2018-06-221-10/+16
| | | | | | | | | | | The `git_walk_objects` structure is currently only being used inside of the pack-objects.c file, but being declared in its header. This has actually been the case since its inception in 04a36feff (pack-objects: fill a packbuilder from a walk, 2014-10-11) and has never really changed. Move the struct declaration into pack-objects.c to improve code encapsulation.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-2/+2
|
* Merge pull request #4028 from chescock/improve-local-fetchEdward Thomson2017-12-301-1/+5
|\ | | | | Transfer fewer objects on push and local fetch
| * Don't fetch objects we don't need in local transport.Chris Hescock2016-12-201-1/+5
| | | | | | | | | | Hide all local refs in the revwalk. Packbuilder should not add hidden trees or blobs.
* | Honor `core.fsyncObjectFiles`ethomson/fsyncEdward Thomson2017-03-021-0/+4
| |
* | oidmap: remove GIT__USE_OIDMAP macroPatrick Steinhardt2017-02-171-2/+0
| |
* | khash: avoid using macro magic to get return addressPatrick Steinhardt2017-02-171-1/+1
| |
* | khash: avoid using `kh_key`/`kh_val` as lvaluePatrick Steinhardt2017-02-171-2/+2
| |
* | khash: avoid using `kh_put` directlyPatrick Steinhardt2017-02-171-2/+2
| |
* | khash: avoid using `kh_val`/`kh_value` directlyPatrick Steinhardt2017-02-171-3/+3
| |
* | khash: avoid using `kh_clear` directlyPatrick Steinhardt2017-02-171-1/+1
| |
* | khash: avoid using `kh_get` directlyPatrick Steinhardt2017-02-171-1/+1
| |
* | khash: avoid using `kh_end` directlyPatrick Steinhardt2017-02-171-1/+1
| |
* | khash: use `git_map_exists` where applicablePatrick Steinhardt2017-02-171-2/+1
| |
* | pack: report revwalk errorEtienne Samson2017-01-131-1/+1
| |
* | giterr_set: consistent error messagesEdward Thomson2016-12-291-5/+5
|/ | | | | | | | 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
* packbuilder: `size_t` all the thingsEdward Thomson2016-07-241-63/+85
| | | | | | | | After 1cd65991, we were passing a pointer to an `unsigned long` to a function that now expected a pointer to a `size_t`. These types differ on 64-bit Windows, which means that we trash the stack. Use `size_t`s in the packbuilder to avoid this.
* Merge pull request #3223 from ethomson/applyEdward Thomson2016-06-251-14/+21
|\ | | | | Reading patch files
| * patch: formatting cleanupsEdward Thomson2016-05-261-1/+1
| |
| * zstream: offer inflating, `git_zstream_inflatebuf`Edward Thomson2016-05-261-1/+1
| | | | | | | | Introduce `git_zstream_inflatebuf` for simple uses.
| * delta: refactor git_delta functions for consistencyEdward Thomson2016-05-261-13/+20
| | | | | | | | | | Refactor the git_delta functions to have consistent naming and parameters with the rest of the library.
* | threads: split up OS-dependent thread codePatrick Steinhardt2016-06-201-1/+1
|/
* pack-objects: fix memory leak on overflowPatrick Steinhardt2016-03-111-1/+3
|
* pack-objects: return early when computing write order failsPatrick Steinhardt2016-02-231-4/+2
| | | | | | | | | | | The function `compute_write_order` may return a `NULL`-pointer when an error occurs. In such cases we jump to the `done`-label where we try to clean up allocated memory. Unfortunately we try to deallocate the `write_order` array, though, which may be NULL here. Fix this error by returning early instead of jumping to the `done` label. There is no data to be cleaned up anyway.
* pack-objects: check realloc in try_delta with GITERR_CHECK_ALLOCPatrick Steinhardt2016-02-231-2/+4
|
* pack-objects: fix memory leak in packbuilder_configPatrick Steinhardt2016-02-091-4/+7
|
* pack-objects: fix memory leak in compute_write_orderPatrick Steinhardt2016-02-091-0/+1
|
* pool: Simplify implementationVicent Marti2015-10-281-2/+1
|
* Remove extra semicolon outside of a functionStefan Widgren2015-07-311-1/+1
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* packbuilder: report progress during deltificationcmn/pack-objects-reportCarlos Martín Nieto2015-05-131-0/+28
| | | | | | | | This is useful to send to the client while we're performing the work. The reporting function has a force parameter which makes sure that we do send out the message of 100% completed, even if this comes before the next udpate window.
* packbuilder: introduce git_packbuilder_insert_recur()Carlos Martín Nieto2015-03-171-0/+36
| | | | | | This function recursively inserts the given object and any referenced ones. It can be thought of as a more general version of the functions to insert a commit or tree.
* pack-objects: fill a packbuilder from a walkCarlos Martín Nieto2015-03-111-1/+242
| | | | | | | | | | | Most use-cases for the object packer communicate in terms of commits which each side has. We already have an object to specify this relationship between commits, namely git_revwalk. By knowing which commits we want to pack and which the other side already has, we can perform similar optimisations to git, by marking each tree as interesting or uninteresting only once, and not sending those trees which we know the other side has.
* Reorder some khash declarationsCarlos Martín Nieto2015-03-111-0/+2
| | | | | | Keep the definitions in the headers, while putting the declarations in the C files. Putting the function definitions in headers causes them to be duplicated if you include two headers with them.
* pack-objects: unlock the cache on integer overflowEdward Thomson2015-02-131-4/+5
|
* Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-4/+3
| | | | | | | | | 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.
* Introduce git__add_sizet_overflow and friendsEdward Thomson2015-02-121-2/+2
| | | | | Add some helper functions to check for overflow in a type-specific manner.
* Use `size_t` to hold size of arraysEdward Thomson2015-02-121-1/+9
| | | | | | Use `size_t` to hold the size of arrays to ease overflow checking, lest we check for overflow of a `size_t` then promptly truncate by packing the length into a smaller type.
* overflow checking: don't make callers set oomEdward Thomson2015-02-121-3/+1
| | | | | | Have the ALLOC_OVERFLOW testing macros also simply set_oom in the case where a computation would overflow, so that callers don't need to.
* git__*allocarray: safer realloc and mallocEdward Thomson2015-02-121-9/+5
| | | | | | | | Introduce git__reallocarray that checks the product of the number of elements and element size for overflow before allocation. Also introduce git__mallocarray that behaves like calloc, but without the `c`. (It does not zero memory, for those truly worried about every cycle.)
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-3/+19
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Win32: Fix object::cache::threadmania test on x64Philip Kelley2014-06-071-1/+1
|