summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | diff: stop processing nitem when its removedEdward Thomson2016-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | When a directory is removed out from underneath us, stop trying to manipulate it.
| * | | iterator: drop `advance_into_or_over`Edward Thomson2016-03-232-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | Now that iterators do not return `GIT_ENOTFOUND` when advancing into an empty directory, we do not need a special `advance_into_or_over` function.
| * | | iterator: test that we're at the end of iterationEdward Thomson2016-03-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure that we have hit the end of iteration; previously we tested that we saw all the values that we expected to see. We did not then ensure that we were at the end of the iteration (and that there were subsequently values in the iteration that we did *not* expect.)
| * | | iterator: combine fs+workdir iterators more completelyEdward Thomson2016-03-234-944/+1082
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Drop some of the layers of indirection between the workdir and the filesystem iterators. This makes the code a little bit easier to follow, and reduces the number of unnecessary allocations a bit as well. (Prior to this, when we filter entries, we would allocate them, filter them and then free them; now we do the filtering before allocation.) Also, rename `git_iterator_advance_over_with_status` to just `git_iterator_advance_over`. Mostly because it's a fucking long-ass function name otherwise.
| * | | checkout: provide internal func to compute target pathEdward Thomson2016-03-231-32/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many code paths in checkout need the final, full on-disk path of the file they're writing. (No surprise). However, they all munge the `data->path` buffer themselves to get there. Provide a nice helper method for them. Plus, drop the use `git_iterator_current_workdir_path` which does the same thing but different. Checkout is the only caller of this silly function, which lets us remove it.
| * | | iterators: refactored tree iteratorEdward Thomson2016-03-232-392/+630
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactored the tree iterator to never recurse; simply process the next entry in order in `advance`. Additionally, reduce the number of allocations and sorting as much as possible to provide a ~30% speedup on case-sensitive iteration. (The gains for case-insensitive iteration are less majestic.)
| * | | git_object_dup: introduce typesafe versionsEdward Thomson2016-03-234-5/+23
| | | |
| * | | iterator: disambiguate reset and reset_rangeEdward Thomson2016-03-234-28/+65
| | | | | | | | | | | | | | | | | | | | | | | | Disambiguate the reset and reset_range functions. Now reset_range with a NULL path will clear the start or end; reset will leave the existing start and end unchanged.
| * | | iterator: drop unused/unimplemented `seek`Edward Thomson2016-03-232-37/+0
| | | |
* | | | Merge pull request #3574 from chescock/buffer-sideband-pack-dataCarlos Martín Nieto2016-03-241-17/+61
|\ \ \ \ | |/ / / |/| | | Buffer sideband packet data
| * | | Only buffer if necessary.Chris Hescock2016-03-081-18/+39
| | | |
| * | | Buffer sideband packet dataChris Hescock2016-01-121-18/+41
| | |/ | |/| | | | | | | The inner packet may be split across multiple sideband packets.
* | | array: fix search for empty arraysCarlos Martín Nieto2016-03-231-1/+1
| | | | | | | | | | | | | | | When the array is empty `cmp` never gets set by the comparison function. Initialize it so we return ENOTFOUND in those cases.
* | | Merge pull request #3704 from ethomson/tree-reuseCarlos Martín Nieto2016-03-233-46/+70
|\ \ \ | | | | | | | | tree: drop the now-unnecessary entries vector
| * | | tree: drop the now-unnecessary entries vectorEdward Thomson2016-03-223-46/+70
| | | | | | | | | | | | | | | | | | | | Remove the now-unnecessary entries vector. Add `git_array_search` to binary search through an array to accomplish this.
* | | | blob: remove _fromchunks()cmn/createblob-streamCarlos Martín Nieto2016-03-221-60/+0
| | | | | | | | | | | | | | | | | | | | | | | | The callback mechanism makes it awkward to write data from an IO source; move to `_fromstream()` which lets the caller remain in control, in the same vein as we prefer iterators over foreach callbacks.
* | | | blob: introduce creating a blob by writing into a streamCarlos Martín Nieto2016-03-221-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pair of `git_blob_create_frombuffer()` and `git_blob_create_frombuffer_commit()` is meant to replace `git_blob_create_fromchunks()` by providing a way for a user to write a new blob when they want filtering or they do not know the size. This approach allows the caller to retain control over when to add data to this buffer and a more natural fit into higher-level language's own stream abstractions instead of having to handle IO wait in the callback. The in-memory buffer size of 2MB is chosen somewhat arbitrarily to be a round multiple of usual page sizes and a value where most blobs seem likely to be either going to be way below or way over that size. It's also a round number of pages. This implementation re-uses the helper we have from `_fromchunks()` so we end up writing everything to disk, but hopefully more efficiently than with a default filebuf. A later optimisation can be to avoid writing the in-memory contents to disk, with some extra complexity.
* | | | filebuf: allow using a custom buffer sizeCarlos Martín Nieto2016-03-222-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | Allow setting the buffer size on open in order to use this data structure more generally as a spill buffer, with larger buffer sizes for specific use-cases.
* | | | Merge pull request #3559 from yongthecoder/masterCarlos Martín Nieto2016-03-221-2/+7
|\ \ \ \ | |/ / / |/| | | Add a sanity check in git_indexer_commit to avoid subtraction overflow.
| * | | Avoid subtraction overflow in git_indexer_commitYong Li2016-01-041-2/+7
| | | |
* | | | tree: store the entries in a growable arraycmn/tree-reuseCarlos Martín Nieto2016-03-202-60/+38
| | | | | | | | | | | | | | | | | | | | | | | | Take advantage of the constant size of tree-owned arrays and store them in an array instead of a pool. This still lets us free them all at once but lets the system allocator do the work of fitting them in.
* | | | tree: re-use the id and filename in the odb objectCarlos Martín Nieto2016-03-206-51/+64
| |_|/ |/| | | | | | | | | | | Instead of copying over the data into the individual entries, point to the originals, which are already in a format we can use.
* | | Merge pull request #3699 from libgit2/cmn/win32-free-tlsEdward Thomson2016-03-181-0/+14
|\ \ \ | | | | | | | | win32: free thread-local data on thread exit
| * | | win32: free thread-local data on thread exitcmn/win32-free-tlsCarlos Martin Nieto2016-03-181-0/+14
| | | |
* | | | merge drivers: handle configured but not found driverEdward Thomson2016-03-171-4/+13
| | | |
* | | | merge driver: remove `check` callbackEdward Thomson2016-03-174-120/+68
| | | | | | | | | | | | | | | | | | | | | | | | Since the `apply` callback can defer, the `check` callback is not necessary. Removing the `check` callback further makes the `payload` unnecessary along with the `cleanup` callback.
* | | | merge driver: correct global initializationEdward Thomson2016-03-175-94/+160
| | | |
* | | | merge driver: get a pointer to favorEdward Thomson2016-03-172-4/+9
| | | |
* | | | merge driver: correct indentationEdward Thomson2016-03-172-30/+30
| | | |
* | | | merge driver: allow custom default driverEdward Thomson2016-03-173-42/+70
| | | | | | | | | | | | | | | | | | | | | | | | Allow merge users to configure a custom default merge driver via `git_merge_options`. Similarly, honor the `merge.default` configuration option.
* | | | merge driver: introduce custom merge driversEdward Thomson2016-03-174-129/+623
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consumers can now register custom merged drivers with `git_merge_driver_register`. This allows consumers to support the merge drivers, as configured in `.gitattributes`. Consumers will be asked to perform the file-level merge when a custom driver is configured.
* | | | Fix rebase bug and include test for merge=unionStan Hu2016-03-171-1/+1
| | | |
* | | | Support union merges via .gitattributes fileStan Hu2016-03-171-0/+26
| | | |
* | | | Merge pull request #3673 from libgit2/cmn/commit-with-signatureEdward Thomson2016-03-171-0/+64
|\ \ \ \ | | | | | | | | | | commit: add function to attach a signature to a commit
| * | | | commit: add function to attach a signature to a commitcmn/commit-with-signatureCarlos Martín Nieto2016-03-151-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | In combination with the function which creates a commit into a buffer, this allows us to more easily create signed commits.
* | | | | commit: fix extraction of single-line signaturescmn/extract-oneline-sigCarlos Martín Nieto2016-03-171-1/+1
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | The function to extract signatures suffers from a similar bug to the header field finding one by having an unecessary line feed check as a break condition of its loop. Fix that and add a test for this single-line signature situation.
* | | | Split the page size from the mmap alignmentcmn/pool-limitCarlos Martín Nieto2016-03-165-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While often similar, these are not the same on Windows. We want to use the page size on Windows for the pools, but for mmap we need to use the allocation granularity as the alignment. On the other platforms these values remain the same.
* | | | Merge pull request #3677 from pks-t/pks/coverity-fixes-round7Carlos Martín Nieto2016-03-146-14/+39
|\ \ \ \ | | | | | | | | | | Coverity fixes round 7
| * | | | config_cache: check return value of `git_config__lookup_entry`Patrick Steinhardt2016-03-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers of `git_config__cvar` already handle the case where the function returns an error due to a failed configuration variable lookup, but we are actually swallowing errors when calling `git_config__lookup_entry` inside of the function. Fix this by returning early when `git_config__lookup_entry` returns an error. As we call `git_config__lookup_entry` with `no_errors == false` which leads us to call `get_entry` with `GET_NO_MISSING` we will not return early when the lookup fails due to a missing entry. Like this we are still able to set the default value of the cvar and exit successfully.
| * | | | filebuf: handle write error in `lock_file`Patrick Steinhardt2016-03-111-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When writing to a file with locking not check if writing the locked file actually succeeds. Fix the issue by returning error code and message when writing fails.
| * | | | config_file: handle error when trying to lock strmapPatrick Steinhardt2016-03-111-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accessing the current values map is handled through the `refcounder_strmap_take` function, which first acquires a mutex before accessing its values. While this assures everybody is trying to access the values with the mutex only we do not check if the locking actually succeeds. Fix the issue by checking if acquiring the lock succeeds and returning `NULL` if we encounter an error. Adjust callers.
| * | | | blame: handle error when resoling HEAD in normalize_optionsPatrick Steinhardt2016-03-111-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When normalizing options we try to look up HEAD's OID. While this action may fail in malformed repositories we never check the return value of the function. Fix the issue by converting `normalize_options` to actually return an error and handle the error in `git_blame_file`.
| * | | | blame_git: handle error returned by `git_commit_parent`Patrick Steinhardt2016-03-111-1/+2
| | | | |
| * | | | refdb_fs: fail if refcache returns NULL pointerPatrick Steinhardt2016-03-111-0/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | We usually check entries returned by `git_sortedcache_entry` for NULL pointers. As we have a write lock in `packed_write`, though, it really should not happen that the function returns NULL. Assert that ref is not NULL to silence a Coverity warning.
* | | | Merge pull request #3647 from pks-t/pks/coverity-fixes-round6Carlos Martín Nieto2016-03-147-15/+29
|\ \ \ \ | | | | | | | | | | Coverity fixes round 6
| * | | | diff_tform: fix potential NULL pointer accessPatrick Steinhardt2016-03-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the user passes in a diff which has no repository associated we may call `git_config__get_int_force` with a NULL-pointer configuration. Even though `git_config__get_int_force` is designed to swallow errors, it is not intended to be called with a NULL pointer configuration. Fix the issue by only calling `git_config__get_int_force` only when configuration could be retrieved from the repository.
| * | | | submodule: avoid passing NULL pointers to strncmpPatrick Steinhardt2016-03-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In C89 it is undefined behavior to pass `NULL` pointers to `strncmp` and later on in C99 it has been explicitly stated that functions with an argument declared as `size_t nmemb` specifying the array length shall always have valid parameters, no matter if `nmemb` is 0 or not (see ISO 9899 §7.21.1.2). The function `str_equal_no_trailing_slash` always passes its parameters to `strncmp` if their lengths match. This means if one parameter is `NULL` and the other one either `NULL` or a string with length 0 we will pass the pointers to `strncmp` and cause undefined behavior. Fix this by explicitly handling the case when both lengths are 0.
| * | | | pack-objects: fix memory leak on overflowPatrick Steinhardt2016-03-111-1/+3
| | | | |
| * | | | index: assert required OID are non-NULLPatrick Steinhardt2016-03-111-3/+9
| | | | |
| * | | | object: avoid call of memset with ouf of bounds pointerPatrick Steinhardt2016-03-111-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When computing a short OID we do this by first copying the leading parts into the new OID structure and then setting the trailing part to zero. In the case of the desired length being `GIT_OID_HEXSZ - 1` we will call `memset` with an out of bounds pointer and a length of 0. While this seems to cause no problems for common platforms the C89 standard does not explicitly state that calling `memset` with an out of bounds pointer and length of 0 is valid. Fix the potential issue by using the newly introduced `git_oid__cpy_prefix` function.