summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* sha1_lookup: drop sha1_entry_pos functionpeff/drop-sha1-entry-posJeff King2017-08-093-224/+0
| | | | | | | | | | | | | This was pulled over from git.git, and is an experiment in making binary-searching lists of sha1s faster. It was never compiled by default (nor was it used upstream by default without a special environment variable). Unfortunately, it is actually slower in practice, and upstream is planning to drop it in git/git@f1068efefe6dd3beaa89484db5e2db730b094e0b (which has some timing results). It's worth doing the same here for simplicity.
* Merge pull request #4304 from pks-t/pks/patch-buffersEdward Thomson2017-07-312-4/+4
|\ | | | | patch_generate: represent buffers as void pointers
| * patch_generate: represent buffers as void pointersPatrick Steinhardt2017-07-102-4/+4
| | | | | | | | | | | | | | | | | | | | | | Pointers to general data should usually be used as a void pointer such that it is possible to hand in variables of a different pointer type without the need to cast. This is the same when creating patches from buffers, where the buffers may contain arbitrary data. Instead of requiring the caller to care whether his buffer is e.g. `char *` or `unsigned char *`, we should instead just accept a `void *`. This is also consistent in how we tread other types like for example `git_blob`, which also just has a void pointer as its raw contents.
* | Merge pull request #4323 from libgit2/ethomson/remove_sys_remote_hEdward Thomson2017-07-311-16/+0
|\ \ | | | | | | Remove unused 'sys/remote.h' header
| * | Remove unused 'sys/remote.h' headerethomson/remove_sys_remote_hEdward Thomson2017-07-311-16/+0
| | |
* | | Merge branch '4233'Edward Thomson2017-07-315-13/+137
|\ \ \ | |/ / |/| |
| * | changelog: update to reflect `detached` api nameEdward Thomson2017-07-311-1/+1
| | |
| * | remote: test creating and fetching detached remotesPatrick Steinhardt2017-05-051-0/+38
| | |
| * | tests: online::remotes: add defines for URL and refspecPatrick Steinhardt2017-05-051-5/+6
| | | | | | | | | | | | | | | | | | The repository URL is duplicated several times and can be de-duplicated like this. Furthermore, exchange the static refspec variable with a define to reduce BSS size.
| * | remote: add function to create detached remotesEric Myhre2017-05-054-7/+40
| | | | | | | | | | | | | | | | | | | | | | | | Right now it is only possible to create remotes from a repository. While this is probably the most common use-case, there are commands which make sense even without a repository, e.g. the equivalence of `git ls-remote`. Add a new function `git_remote_create_detached`, which simply accepts a URL.
| * | remote: reject various actions for detached remotesPatrick Steinhardt2017-05-052-0/+50
| | | | | | | | | | | | | | | | | | | | | There are only few actions which actually make sense for a detached remote, like e.g. `git_remote_ls`, `git_remote_prune`. For all the other actions, we have to report an error when the remote has no repository attached to it. This commit does so and implements some tests.
| * | remote: improve error message if no URL is setPatrick Steinhardt2017-05-051-1/+3
| | | | | | | | | | | | | | | | | | | | | The current error message when connecting to a remote when no URL is set is missing information on whether it is missing a fetch or push URL. Furthermore, it results in undefined behavior when using a remote without name. Fix both issues.
* | | Merge pull request #4320 from pks-t/pks/rebase-submodule-assertsEdward Thomson2017-07-281-7/+7
|\ \ \ | | | | | | | | tests: rebase::submodule: verify initialization method calls
| * | | tests: rebase::submodule: verify initialization method callsPatrick Steinhardt2017-07-281-7/+7
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | Some return codes for functions which may fail are not being checked in `test_rebase_submodule__initialize`. This may lead us to not notice errors when initializing the environment and would possibly result in either memory corruption or segfaults as soon as any of the initialization steps fails. Fix this by wrapping these function calls into `cl_git_pass`.
* | | Merge pull request #4275 from tiennou/fix-rebase-submodule-testEdward Thomson2017-07-273-7/+36
|\ \ \ | | | | | | | | tests: rewrite rebase-submodule .gitmodule file
| * | | tests: fix the rebase-submodule testEtienne Samson2017-07-252-7/+36
| | | |
| * | | Remove invalid submoduleEtienne Samson2017-07-201-0/+0
| | | | | | | | | | | | Fixes #4274
* | | | Merge pull request #4314 from pks-t/pks/timsortEdward Thomson2017-07-261-1/+0
|\ \ \ \ | | | | | | | | | | tsort: remove idempotent conditional assignment
| * | | | tsort: remove idempotent conditional assignmentPatrick Steinhardt2017-07-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The conditional `run < minrun` can never be true directly after assigning `run = minrun`. Remove it to avoid confusion.
* | | | | Merge pull request #4317 from libgit2/ethomson/libcurl_buildEdward Thomson2017-07-263-12/+17
|\ \ \ \ \ | | | | | | | | | | | | Build with patched libcurl
| * | | | | travis: only install custom libcurl on trustyEdward Thomson2017-07-241-4/+8
| | | | | |
| * | | | | travis: only kill our own sshdEdward Thomson2017-07-241-1/+2
| | | | | |
| * | | | | travis: use trustyEdward Thomson2017-07-241-0/+1
| | | | | |
| * | | | | travis: build with patched libcurlEdward Thomson2017-07-242-11/+10
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | Ubuntu trusty has a bug in curl when using NTLM credentials in a proxy, dereferencing a null pointer and causing segmentation faults. Use a custom-patched version of libcurl that avoids this issue.
* | | | | Merge pull request #4311 from libgit2/ethomson/win32_remediateEdward Thomson2017-07-262-5/+11
|\ \ \ \ \ | |/ / / / |/| | | | win32: provide fast-path for retrying filesystem operations
| * | | | win32: provide fast-path for retrying filesystem operationsethomson/win32_remediateEdward Thomson2017-07-261-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using the `do_with_retries` macro for retrying filesystem operations in the posix emulation layer, allow the remediation function to return `GIT_RETRY`, meaning that the error was believed to be remediated, and the operation should be retried immediately, without a sleep. This is a slightly more general solution to the problem fixed in #4312.
| * | | | Updated changelogCarson Howard2017-07-261-0/+3
| | | | |
| * | | | fixed win32 p_unlink retry sleep issueCarson Howard2017-07-261-1/+6
| |/ / / | | | | | | | | Fixed an issue where the retry logic on p_unlink sleeps before it tries setting a file to write mode causing unnecessary slowdown.
* | | | Merge pull request #4250 from pks-t/pks/config-file-iterationEdward Thomson2017-07-192-173/+209
|\ \ \ \ | | | | | | | | | | Configuration file fixes with includes
| * | | | config_file: refuse modifying included variablesPatrick Steinhardt2017-07-152-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modifying variables pulled in by an included file currently succeeds, but it doesn't actually do what one would expect, as refreshing the configuration will cause the values to reappear. As we are currently not really able to support this use case, we will instead just return an error for deleting and setting variables which were included via an include.
| * | | | config_file: move reader into `config_read` onlyPatrick Steinhardt2017-07-152-45/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, we have multiple call sites which initialize a `reader` structure. As the structure is only actually used inside of `config_read`, we can instead just move the reader inside of the `config_read` function. Instead, we can just pass in the configuration file into `config_read`, which eases code readability.
| * | | | config_file: refresh all files if includes were modifiedPatrick Steinhardt2017-07-152-36/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we only re-parse the top-level configuration file when it has changed itself. This can cause problems when an include is changed, as we were not updating all values correctly. Instead of conditionally reparsing only refreshed files, the logic becomes much clearer and easier to follow if we always re-parse the top-level configuration file when either the file itself or one of its included configuration files has changed on disk. This commit implements this logic. Note that this might impact performance in some cases, as we need to re-read all configuration files whenever any of the included files changed. It could increase performance to just re-parse include files which have actually changed, but this would compromise maintainability of the code without much gain. The only case where we will gain anything is when we actually use includes and when only these includes are updated, which will probably be quite an unusual scenario to actually be worthwhile to optimize.
| * | | | config_file: remove unused backend field from parse dataPatrick Steinhardt2017-07-151-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | The backend passed to `config_read` is never actually used anymore, so we can remove it from the function and the `parse_data` structure.
| * | | | config_file: pass reader directly to callbacksPatrick Steinhardt2017-07-151-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the callbacks passed to `config_parse` got the reader via a pointer to a pointer. This allowed the callbacks to update the callers `reader` variable when the array holding it has been reallocated. As the array is no longer present, we can simply the code by making the reader a simple pointer.
| * | | | config_file: refactor include handlingPatrick Steinhardt2017-07-151-98/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code for configuration files uses the `reader` structure to parse configuration files and store additional metadata like the file's path and checksum. These structures are stored within an array in the backend itself, which causes multiple problems. First, it does not make sense to keep around the file's contents with the backend itself. While this data is usually free'd before being added to the backend, this brings along somewhat intricate lifecycle problems. A better solution would be to store only the file paths as well as the checksum of the currently parsed content only. The second problem is that the `reader` structures are stored inside an array. When re-parsing configuration files due to changed contents, we may cause this array to be reallocated, requiring us to update pointers hold by callers. Furthermore, we do not keep track of includes which are already associated to a reader inside of this array. This causes us to add readers multiple times to the backend, e.g. in the scenario of refreshing configurations. This commit fixes these shortcomings. We introduce a split between the parsing data and the configuration file's metadata. The `reader` will now only hold the file's contents and the parser state and the new `config_file` structure holds the file's path and checksum. Furthermore, the new structure is a recursive structure in that it will also hold references to the files it directly includes. The diskfile is changed to only store the top-level configuration file. These changes allow us further refactorings and greatly simplify understanding the code.
| * | | | tests: config::include: use init and cleanup functionsPatrick Steinhardt2017-07-151-43/+15
| |/ / /
* | | | Merge pull request #4272 from pks-t/pks/patch-idEdward Thomson2017-07-195-1/+313
|\ \ \ \ | |/ / / |/| | | Patch ID calculation
| * | | diff: implement function to calculate patch IDPatrick Steinhardt2017-06-265-1/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream git project provides the ability to calculate a so-called patch ID. Quoting from git-patch-id(1): A "patch ID" is nothing but a sum of SHA-1 of the file diffs associated with a patch, with whitespace and line numbers ignored." Patch IDs can be used to identify two patches which are probably the same thing, e.g. when a patch has been cherry-picked to another branch. This commit implements a new function `git_diff_patchid`, which gets a patch and derives an OID from the diff. Note the different terminology here: a patch in libgit2 are the differences in a single file and a diff can contain multiple patches for different files. The implementation matches the upstream implementation and should derive the same OID for the same diff. In fact, some code has been directly derived from the upstream implementation. The upstream implementation has two different modes to calculate patch IDs, which is the stable and unstable mode. The old way of calculating the patch IDs was unstable in a sense that a different ordering the diffs was leading to different results. This oversight was fixed in git 1.9, but as git tries hard to never break existing workflows, the old and unstable way is still default. The newer and stable way does not care for ordering of the diff hunks, and in fact it is the mode that should probably be used today. So right now, we only implement the stable way of generating the patch ID.
* | | | Merge pull request #4306 from libgit2/cmn/tag-bad-signaturePatrick Steinhardt2017-07-141-0/+1
|\ \ \ \ | | | | | | | | | | signature: don't leave a dangling pointer to the strings on parse failure
| * | | | signature: don't leave a dangling pointer to the strings on parse failurecmn/tag-bad-signatureCarlos Martín Nieto2017-07-121-0/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the signature is invalid but we detect that after allocating the strings, we free them. We however leave that pointer dangling in the structure the caller gave us, which can lead to double-free. Set these pointers to `NULL` after freeing their memory to avoid this.
* | | | Merge pull request #4287 from AndreyG/reset/interface-cosmeticsPatrick Steinhardt2017-07-102-9/+9
|\ \ \ \ | |_|_|/ |/| | | git_reset_*: pass parameters as const pointers
| * | | git_reset_*: pass parameters as const pointersAndrey Davydov2017-06-302-9/+9
| | | |
* | | | Merge pull request #4291 from pks-t/pks/regex-header-confusionPatrick Steinhardt2017-07-071-0/+1
|\ \ \ \ | |/ / / |/| | | tests: config: fix missing declaration causing error
| * | | tests: config: fix missing declaration causing errorPatrick Steinhardt2017-07-051-0/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On systems where we pull in our distributed version of the regex library, all tests in config::readonly fail. This error is actually quite interesting: the test suite is unable to find the declaration of `git_path_exists` and assumes it has a signature of `int git_path_exists(const char *)`. But actually, it has a `bool` return value. Due to this confusion, some wrong conversion is done by the compiler and the `cl_assert(!git_path_exists("file"))` checks erroneously fail, even when the function does in fact return the correct value. The error is actually introduced by 56893bb9a (cmake: consistently use TARGET_INCLUDE_DIRECTORIES if available, 2017-06-28), unfortunately introduced by myself. Due to the delayed addition of include directories, we will now find the "config.h" header inside of the "deps/regex" directory instead of inside the "src/" directory, where it should be. As such, we are missing definitions for the `git_config_file__ondisk` and `git_path_exists` symbols. The correct fix here would be to fix the order in which include search directories are added. But due to the current restructuring of CMakeBuild.txt, I'm refraining from doing so and delay the proper fix a bit. Instead, we paper over the issue by explicitly including "path.h" to fix its prototype. This ignores the issue that `git_config_file__ondisk` is undeclared, as its signature is correctly identified by the compiler.
* | | Merge branch 'AndreyG/cmake/modernization'Patrick Steinhardt2017-06-281-1/+10
|\ \ \
| * | | cmake: consistently use TARGET_INCLUDE_DIRECTORIES if availablePatrick Steinhardt2017-06-281-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using INCLUDE_DIRECTORIES again for the libgit2_clar test suite, we should just be using TARGET_INCLUDE_DIRECTORIES again if the CMake version is greater than 2.8.11.
| * | | cmake: use `target_include_directories` for modern cmakeAndrey Davydov2017-06-281-1/+11
| | | | | | | | | | | | | | | | Apply `target_include_directories` when CMAKE_VERSION >= 2.8.12
* | | | Merge pull request #4280 from ids1024/htonsPatrick Steinhardt2017-06-271-1/+1
|\ \ \ \ | |/ / / |/| | | Convert port with htons() in p_getaddrinfo()
| * | | Convert port with htons() in p_getaddrinfo()Ian Douglas Scott2017-06-231-1/+1
| |/ / | | | | | | | | | `sin_port` should be in network byte order.
* | | Merge pull request #4235 from pks-t/pks/out-of-tree-buildsPatrick Steinhardt2017-06-274-18/+29
|\ \ \ | | | | | | | | Out of tree builds