summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Add missing license headersPatrick Steinhardt2017-07-037-0/+49
| | | | | Some implementation files were missing the license headers. This commit adds them.
* Fix missing include for header filesPatrick Steinhardt2017-07-039-3/+19
| | | | | | | | | | | | Some of our header files are not included at all by any of their implementing counter-parts. Including them inside of these files leads to some compile errors mostly due to unknown types because of missing includes. But there's also one case where a declared function does not match the implementation's prototype. Fix all these errors by fixing up the prototype and adding missing includes. This is preparatory work for fixing up missing includes in the implementation files.
* win32: fix circular include deps with w32_crtdbgPatrick Steinhardt2017-06-303-107/+107
| | | | | | | | | | | | | | The current order of declarations and includes between "common.h" and "w32_crtdbg_stacktrace.h" is rather complicated. Both header files make use of things defined in the other one and are thus circularly dependent on each other. This makes it currently impossible to compile the "w32_crtdbg_stacktrace.c" file when including "common.h" inside of "w32_crtdbg_stacktrace.h". We can disentangle the mess by moving declaration of the inline crtdbg functions into the "w32_crtdbg_stacktrace.h" file and adding additional includes inside of it, such that all required functions are available to it. This allows us to break the dependency cycle.
* Convert port with htons() in p_getaddrinfo()Ian Douglas Scott2017-06-231-1/+1
| | | | `sin_port` should be in network byte order.
* merge: fix potential free of uninitialized memoryPatrick Steinhardt2017-06-211-1/+1
| | | | | | | | | | The function `merge_diff_mark_similarity_exact` may error our early and, when it does so, free the `ours_deletes_by_oid` and `theirs_deletes_by_oid` variables. While the first one can never be uninitialized due to the first call actually assigning to it, the second variable can be freed without being initialized. Fix the issue by initializing both variables to `NULL`.
* Merge pull request #4202 from mitesch/linear_exact_renameEdward Thomson2017-06-211-31/+152
|\ | | | | merge: perform exact rename detection in linear time
| * merge: perform exact rename detection in linear timeMichael Tesch2017-05-171-31/+152
| | | | | | | | | | | | | | | | | | The current exact rename detection has order n^2 complexity. We can do better by using a map to first aggregate deletes and using that to match deletes to adds. This results in a substantial performance improvement for merges with a large quantity of adds and deletes.
* | repository: remove trailing whitespaceAriel Davis2017-06-191-2/+2
| |
* | repository: do not initialize templates if dir is an empty stringAriel Davis2017-06-191-1/+7
| |
* | Adding git_filter_init for initializing `git_filter` struct + unit test Mohseen Mukaddam2017-06-131-1/+7
| |
* | Merge pull request #4263 from libgit2/ethomson/config_for_inmemory_repoEdward Thomson2017-06-121-9/+6
|\ \ | | | | | | Allow creation of a configuration object in an in-memory repository
| * | repository: don't fail to create config option in inmemory repoEdward Thomson2017-06-121-6/+3
| | | | | | | | | | | | | | | When in an in-memory repository - without a configuration file - do not fail to create a configuration object.
| * | repository_item_path: return ENOTFOUND when appropriateEdward Thomson2017-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | Disambiguate error values: return `GIT_ENOTFOUND` when the item cannot exist in the repository (perhaps because the repository is inmemory or otherwise not backed by a filesystem), return `-1` when there is a hard failure.
| * | repository_item_path: error messages lowercasedEdward Thomson2017-06-121-2/+2
| | |
* | | Merge pull request #4261 from RogerGee/fix_wait_while_ackEdward Thomson2017-06-121-1/+2
|\ \ \ | | | | | | | | smart_protocol: fix parsing of server ACK responses
| * | | smart_protocol: fix parsing of server ACK responsesRoger Gee2017-06-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix ACK parsing in wait_while_ack() internal function. This patch handles the case where multi_ack_detailed mode sends 'ready' ACKs. The existing functionality would bail out too early, thus causing the processing of the ensuing packfile to fail if/when 'ready' ACKs were sent.
* | | | odb_read_prefix: reset error in backends loopethomson/read_prefixEdward Thomson2017-06-121-1/+4
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | When looking for an object by prefix, we query all the backends so that we can ensure that there is no ambiguity. We need to reset the `error` value between backends; otherwise the first backend may find an object by prefix, but subsequent backends may not. If we do not reset the `error` value then it will remain at `GIT_ENOTFOUND` and `read_prefix_1` will fail, despite having actually found an object.
* | | Merge pull request #4088 from chescock/packfile-name-using-complete-hashEdward Thomson2017-06-111-8/+4
|\ \ \ | | | | | | | | Ensure packfiles with different contents have different names
| * | | indexer: name pack files after trailer hashChris Hescock2017-05-191-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream git.git has changed the way how packfiles are named. Previously, they were using a hash of the contained object's OIDs, which has then been changed to use the hash of the complete packfile instead. See 1190a1acf (pack-objects: name pack files after trailer hash, 2013-12-05) in the git.git repository for more information on this change. This commit changes our logic to match the behavior of core git.
* | | | Merge pull request #4260 from libgit2/ethomson/forced_checkout_2Edward Thomson2017-06-112-4/+5
|\ \ \ \ | |_|/ / |/| | | Update to forced checkout and untracked files
| * | | git_futils_rmdir: only allow `EBUSY` when askedethomson/forced_checkout_2Edward Thomson2017-06-101-0/+3
| | | | | | | | | | | | | | | | | | | | Only ignore `EBUSY` from `rmdir` when the `GIT_RMDIR_SKIP_NONEMPTY` bit is set.
| * | | checkout: cope with untracked files in directory deletionEdward Thomson2017-06-101-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When deleting a directory during checkout, do not simply delete the directory, since there may be untracked files. Instead, go into the iterator and examine each file. In the original code (the code with the faulty assumption), we look to see if there's an index entry beneath the directory that we want to remove. Eg, it looks to see if we have a workdir entry foo and an index entry foo/bar.txt. If this is not the case, then the working directory must have precious files in that directory. This part is okay. The part that's not okay is if there is an index entry foo/bar.txt. It just blows away the whole damned directory. That's not cool. Instead, by simply pushing the directory itself onto the stack and iterating each entry, we will deal with the files one by one - whether they're in the index (and can be force removed) or not (and are precious). The original code was a bad optimization, assuming that we didn't need to git_iterator_advance_into if there was any index entry in the folder. That's wrong - we could have optimized this iff all folder entries are in the index. Instead, we need to simply dig into the directory and analyze its entries.
* | | | settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`Patrick Steinhardt2017-06-088-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially, the setting has been solely used to enable the use of `fsync()` when creating objects. Since then, the use has been extended to also cover references and index files. As the option is not yet part of any release, we can still correct this by renaming the option to something more sensible, indicating not only correlation to objects. This commit renames the option to `GIT_OPT_ENABLE_FSYNC_GITDIR`. We also move the variable from the object to repository source code.
* | | | Merge pull request #4255 from pks-t/pks/buffer-grow-errorsEdward Thomson2017-06-085-20/+21
|\ \ \ \ | | | | | | | | | | Buffer growing cleanups
| * | | | buffer: use `git_buf_init` with lengthPatrick Steinhardt2017-06-082-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `git_buf_init` function has an optional length parameter, which will cause the buffer to be initialized and allocated in one step. This can be used instead of static initialization with `GIT_BUF_INIT` followed by a `git_buf_grow`. This patch does so for two functions where it is applicable.
| * | | | buffer: return errors for `git_buf_init` and `git_buf_attach`Patrick Steinhardt2017-06-082-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both the `git_buf_init` and `git_buf_attach` functions may call `git_buf_grow` in case they were given an allocation length as parameter. As such, it is possible for these functions to fail when we run out of memory. While it won't probably be used anytime soon, it does indeed make sense to also record this fact by returning an error code from both functions. As they belong to the internal API only, this change does not break our interface.
| * | | | buffer: consistently use `ENSURE_SIZE` to grow buffers on-demandPatrick Steinhardt2017-06-081-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `ENSURE_SIZE` macro can be used to grow a buffer if its currently allocated size does not suffice a required target size. While most of the code already uses this macro, the `git_buf_join` and `git_buf_join3` functions do not yet use it. Due to the macro first checking whether we have to grow the buffer at all, this has the benefit of saving a function call when it is not needed. While this is nice to have, it will probably not matter at all performance-wise -- instead, this only serves for consistency across the code.
| * | | | buffer: fix `ENSURE_SIZE` macro referencing wrong variablePatrick Steinhardt2017-06-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the `ENSURE_SIZE` macro gets a reference to both the buffer that is to be resized and a new size, we were not consistently referencing the passed buffer, but instead a variable `buf`, which is not passed in. Funnily enough, we never noticed because our buffers seem to always be named `buf` whenever the macro was being used. Fix the macro by always using the passed-in buffer. While at it, add braces around all mentions of passed-in variables as should be done with macros to avoid subtle errors. Found-by: Edward Thompson
| * | | | buffer: rely on `GITERR_OOM` set by `git_buf_try_grow`Patrick Steinhardt2017-06-082-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `git_buf_try_grow` consistently calls `giterr_set_oom` whenever growing the buffer fails due to insufficient memory being available. So in fact, we do not have to do this ourselves when a call to any buffer-growing function has failed due to an OOM situation. But we still do so in two functions, which this patch cleans up.
* | | | | Merge pull request #4253 from pks-t/pks/cov-fixesEdward Thomson2017-06-085-15/+31
|\ \ \ \ \ | | | | | | | | | | | | Coverity fixes
| * | | | | refdb_fs: be explicit about using null-OID if we cannot resolve refPatrick Steinhardt2017-06-081-2/+3
| | | | | |
| * | | | | path: only set dotgit flags when configs were readPatrick Steinhardt2017-06-081-4/+5
| | | | | |
| * | | | | worktree: use `git__free` instead of `free`Patrick Steinhardt2017-06-081-1/+1
| | | | | |
| * | | | | refs: properly report errors from `update_wt_heads`Patrick Steinhardt2017-06-081-6/+16
| | | | | |
| * | | | | fileops: check return value of `git_path_dirname`Patrick Steinhardt2017-06-081-2/+6
| |/ / / /
* | | | | Merge pull request #4258 from pks-t/pks/sha1dc-updateEdward Thomson2017-06-084-52/+136
|\ \ \ \ \ | | | | | | | | | | | | SHA1DC update
| * | | | | sha1dc: update to fix errors with endianess and unaligned accessPatrick Steinhardt2017-06-074-52/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates our version of SHA1DC to e139984 (Merge pull request #35 from lidl/master, 2017-05-30).
* | | | | | Merge pull request #4236 from pks-t/pks/index-v4-fixesEdward Thomson2017-06-072-43/+76
|\ \ \ \ \ \ | |/ / / / / |/| | | | | Fix path computations for compressed index entries
| * | | | | index: verify we have enough space left when writing index entriesPatrick Steinhardt2017-06-061-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In our code writing index entries, we carry around a `disk_size` representing how much memory we have in total and pass this value to `git_encode_varint` to do bounds checks. This does not make much sense, as at the time when passing on this variable it is already out of date. Fix this by subtracting used memory from `disk_size` as we go along. Furthermore, assert we've actually got enough space left to do the final path memcpy.
| * | | | | index: fix shared prefix computation when writing index entryPatrick Steinhardt2017-06-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using compressed index entries, each entry's path is preceded by a varint encoding how long the shared prefix with the previous index entry actually is. We currently encode a length of `(path_len - same_len)`, which is doubly wrong. First, `path_len` is already set to `path_len - same_len` previously. Second, we want to encode the shared prefix rather than the un-shared suffix length. Fix this by using `same_len` as the varint value instead.
| * | | | | index: also sanity check entry size with compressed entriesPatrick Steinhardt2017-06-061-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a check in place whether the index has enough data left for the required footer after reading an index entry, but this was only used for uncompressed entries. Move the check down a bit so that it is executed for both compressed and uncompressed index entries.
| * | | | | index: remove file-scope entry size macrosPatrick Steinhardt2017-06-061-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All index entry size computations are now performed in `index_entry_size`. As such, we do not need the file-scope macros for computing these sizes anymore. Remove them and move the `entry_size` macro into the `index_entry_size` function.
| * | | | | index: don't right-pad paths when writing compressed entriesPatrick Steinhardt2017-06-061-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our code to write index entries to disk does not check whether the entry that is to be written should use prefix compression for the path. As such, we were overallocating memory and added bogus right-padding into the resulting index entries. As there is no padding allowed in the index version 4 format, this should actually result in an invalid index. Fix this by re-using the newly extracted `index_entry_size` function.
| * | | | | index: move index entry size computation into its own functionPatrick Steinhardt2017-06-061-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create a new function `index_entry_size` which encapsulates the logic to calculate how much space is needed for an index entry, whether it is simple/extended or compressed/uncompressed. This can later be re-used by our code writing index entries.
| * | | | | index: set last written index entry in foreach-entry-loopPatrick Steinhardt2017-06-061-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last written disk entry is currently being written inside of the function `write_disk_entry`. Make behavior a bit more obviously by instead setting it inside of `write_entries` while iterating all entries.
| * | | | | index: set last entry when reading compressed entriesPatrick Steinhardt2017-06-061-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To calculate the path of a compressed index entry, we need to know the preceding entry's path. While we do actually set the first predecessor correctly to "", we fail to update this while reading the entries. Fix the issue by updating `last` inside of the loop. Previously, we've been passing a double-pointer to `read_entry`, which it didn't update. As it is more obvious to update the pointer inside the loop itself, though, we can simply convert it to a normal pointer.
| * | | | | index: fix confusion with shared prefix in compressed path namesPatrick Steinhardt2017-06-061-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The index version 4 introduced compressed path names for the entries. From the git.git index-format documentation: At the beginning of an entry, an integer N in the variable width encoding [...] is stored, followed by a NUL-terminated string S. Removing N bytes from the end of the path name for the previous entry, and replacing it with the string S yields the path name for this entry. But instead of stripping N bytes from the previous path's string and using the remaining prefix, we were instead simply concatenating the previous path with the current entry path, which is obviously wrong. Fix the issue by correctly copying the first N bytes of the previous entry only and concatenating the result with our current entry's path.
| * | | | | varint: fix computation for remaining buffer spacePatrick Steinhardt2017-06-061-1/+1
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When encoding varints to a buffer, we want to remain sure that the required buffer space does not exceed what is actually available. Our current check does not do the right thing, though, in that it does not honor that our `pos` variable counts the position down instead of up. As such, we will require too much memory for small varints and not enough memory for big varints. Fix the issue by correctly calculating the required size as `(sizeof(varint) - pos)`. Add a test which failed before.
* | | | | openssl_stream: fix building with libresslMarc-Antoine Perennou2017-06-071-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSL v1.1 has introduced a new way of initializing the library without having to call various functions of different subsystems. In libgit2, we have been adapting to that change with 88520151f (openssl_stream: use new initialization function on OpenSSL version >=1.1, 2017-04-07), where we added an #ifdef depending on the OpenSSL version. This change broke building with libressl, though, which has not changed its API in the same way. Fix the issue by expanding the #ifdef condition to use the old way of initializing with libressl. Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
* | | | Merge branch 'pr/4228'Edward Thomson2017-06-041-7/+66
|\ \ \ \