summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* object validation: free some memleaksethomson/memleakEdward Thomson2017-05-012-0/+7
|
* signature: free dup'd buffers on parse errorEdward Thomson2017-05-011-1/+4
|
* remote: free the config snapshotEdward Thomson2017-05-011-8/+8
| | | | This reverts commit 5552237 and frees the snapshot properly.
* worktrees: cleanup some memory leaksEdward Thomson2017-05-013-7/+10
| | | | | Be sure to clean up looked up references. Free buffers instead of merely clearing them. Use `git__free` instead of `free`.
* Merge pull request #4197 from pks-t/pks/verify-object-hashesEdward Thomson2017-05-017-25/+162
|\ | | | | Verify object hashes
| * odb: verify hashes in read_prefix_1Patrick Steinhardt2017-04-281-0/+12
| | | | | | | | | | | | While the function reading an object from the complete OID already verifies OIDs, we do not yet do so for reading objects from a partial OID. Do so when strict OID verification is enabled.
| * odb: improve error handling in read_prefix_1Patrick Steinhardt2017-04-281-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | The read_prefix_1 function has several return statements springled throughout the code. As we have to free memory upon getting an error, the free code has to be repeated at every single retrun -- which it is not, so we have a memory leak here. Refactor the code to use the typical `goto out` pattern, which will free data when an error has occurred. While we're at it, we can also improve the error message thrown when multiple ambiguous prefixes are found. It will now include the colliding prefixes.
| * odb: add option to turn off hash verificationPatrick Steinhardt2017-04-285-5/+29
| | | | | | | | | | | | | | | | | | | | | | Verifying hashsums of objects we are reading from the ODB may be costly as we have to perform an additional hashsum calculation on the object. Especially when reading large objects, the penalty can be as high as 35%, as can be seen when executing the equivalent of `git cat-file` with and without verification enabled. To mitigate for this, we add a global option for libgit2 which enables the developer to turn off the verification, e.g. when he can be reasonably sure that the objects on disk won't be corrupted.
| * odb: verify object hashesPatrick Steinhardt2017-04-285-4/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream git.git project verifies objects when looking them up from disk. This avoids scenarios where objects have somehow become corrupt on disk, e.g. due to hardware failures or bit flips. While our mantra is usually to follow upstream behavior, we do not do so in this case, as we never check hashes of objects we have just read from disk. To fix this, we create a new error class `GIT_EMISMATCH` which denotes that we have looked up an object with a hashsum mismatch. `odb_read_1` will then, after having read the object from its backend, hash the object and compare the resulting hash to the expected hash. If hashes do not match, it will return an error. This obviously introduces another computation of checksums and could potentially impact performance. Note though that we usually perform I/O operations directly before doing this computation, and as such the actual overhead should be drowned out by I/O. Running our test suite seems to confirm this guess. On a Linux system with best-of-five timings, we had 21.592s with the check enabled and 21.590s with the ckeck disabled. Note though that our test suite mostly contains very small blobs only. It is expected that repositories with bigger blobs may notice an increased hit by this check. In addition to a new test, we also had to change the odb::backend::nonrefreshing test suite, which now triggers a hashsum mismatch when looking up the commit "deadbeef...". This is expected, as the fake backend allocated inside of the test will return an empty object for the OID "deadbeef...", which will obviously not hash back to "deadbeef..." again. We can simply adjust the hash to equal the hash of the empty object here to fix this test.
| * tests: object: test looking up corrupted objectsPatrick Steinhardt2017-04-281-0/+30
| | | | | | | | | | | | We currently have no tests which check whether we fail reading corrupted objects. Add one which modifies contents of an object stored on disk and then tries to read the object.
| * tests: object: create sandboxPatrick Steinhardt2017-04-281-3/+2
| | | | | | | | | | | | | | | | | | | | | | The object::lookup tests do use the "testrepo.git" repository in a read-only way, so we do not set up the repository as a sandbox but simply open it. But in a future commit, we will want to test looking up objects which are corrupted in some way, which requires us to modify the on-disk data. Doing this in a repository without creating the sandbox will modify contents of our libgit2 repository, though. Create the repository in a sandbox to avoid this.
| * tests: odb: make hash of fake backend configurablePatrick Steinhardt2017-04-281-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | In the odb::backend::nonrefreshing test suite, we set up a fake backend so that we are able to determine if backend functions are called correctly. During the setup, we also parse an OID which is later on used to read out the pseudo-object. While this procedure works right now, it will create problems later when we implement hash verification for looked up objects. The current OID ("deadbeef") will not match the hash of contents we give back to the ODB layer and thus cannot be verified. Make the hash configurable so that we can simply switch the returned for single tests.
* | Merge pull request #4206 from libgit2/cmn/transport-get-proxyEdward Thomson2017-05-012-0/+16
|\ \ | | | | | | transport: provide a getter for the proxy options
| * | transport: provide a getter for the proxy optionscmn/transport-get-proxyCarlos Martín Nieto2017-04-172-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | As with the callbacks, third-party implementations of smart subtransports cannot reach into the opaque struct and thus cannot know what options the user set. Add a getter for these options to copy the proxy options into something external implementors can use.
* | | Merge pull request #4216 from pks-t/pks/debian-test-failuresEdward Thomson2017-05-014-2/+7
|\ \ \ | | | | | | | | Debian HTTPS feature test failure
| * | | tests: core::features: only check for HTTPS if it is supportedPatrick Steinhardt2017-04-251-0/+2
| | | |
| * | | cmake: define GIT_HTTPS when HTTPS is supportedPatrick Steinhardt2017-04-253-2/+5
| | | |
* | | | Merge branch 'pr/4225'Edward Thomson2017-05-012-3/+3
|\ \ \ \
| * | | | git_remote_push: document that NULL refspecs allowedEdward Thomson2017-05-011-2/+2
| | | | |
| * | | | Allow NULL refspec in git_remote_pushYichao Yu2017-04-291-1/+1
| | |_|/ | |/| | | | | | | | | | Since this is allowed in `git_remote_upload`
* | | | Merge pull request #4224 from yuyichao/push-free-configEdward Thomson2017-05-011-1/+0
|\ \ \ \ | |/ / / |/| | | Do not free config when creating remote
| * | | Do not free config when creating remoteYichao Yu2017-04-291-1/+0
|/ / / | | | | | | | | | The regression was introduced in 22261344de18b3cc60ee6937468d66a6a6a28875
* | | Merge pull request #4191 from pks-t/pks/wt-ref-renamesEdward Thomson2017-04-287-124/+257
|\ \ \ | | | | | | | | Branch renames with worktrees
| * | | refs: update worktree HEADs when renaming branchesPatrick Steinhardt2017-04-053-8/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever we rename a branch, we update the repository's symbolic HEAD reference if it currently points to the branch that is to be renamed. But with the introduction of worktrees, we also have to iterate over all HEADs of linked worktrees to adjust them. Do so.
| * | | branch: use `foreach_head` to see if a branch is checked outPatrick Steinhardt2017-04-051-49/+16
| | | | | | | | | | | | | | | | | | | | Previously, we have extracted the logic to find and iterate over all HEADs of a repository. Use this function in `git_branch_is_checked_out`.
| * | | repository: add function to iterate over all HEADsPatrick Steinhardt2017-04-052-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we already provide functions to get the current repository's HEAD, it is quite involved to iterate over HEADs of both the repository and all linked work trees. This commit implements a function `git_repository_foreach_head`, which accepts a callback which is then called for all HEAD files.
| * | | repository: get worktree HEAD via `git_reference__read_head`Patrick Steinhardt2017-04-051-50/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The functions `git_repository_head_for_worktree` and `git_repository_detached_head_for_worktree` both implement their own logic to read the HEAD reference file. Use the new function `git_reference__read_head` instead to unify the code paths.
| * | | repository: extract function to get path to a file in a work treePatrick Steinhardt2017-04-051-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `read_worktree_head` has the logic embedded to construct the path to `HEAD` in the work tree's git directory, which is quite useful for other callers. Extract the logic into its own function to make it reusable by others.
| * | | repository: set error message if trying to set HEAD to a checked out onePatrick Steinhardt2017-04-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If trying to set the HEAD of a repository to another reference, we have to check whether this reference is already checked out in another linked work tree. If it is, we will refuse setting the HEAD and return an error, but do not set a meaningful error message. Add one.
| * | | refs: implement function to read references from filePatrick Steinhardt2017-04-052-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we only provide functions to read references directly from a repository's reference store via e.g. `git_reference_lookup`. But in some cases, we may want to read files not connected to the current repository, e.g. when looking up HEAD of connected work trees. This commit implements `git_reference__read_head`, which will read out and allocate a reference at an arbitrary path.
| * | | tests: worktree::refs: convert spaces to tabsPatrick Steinhardt2017-04-051-14/+14
| | | |
* | | | Merge pull request #4219 from pks-t/pks/socket-stream-addrinfo-loopEdward Thomson2017-04-261-4/+2
|\ \ \ \ | | | | | | | | | | socket_stream: continue to next addrinfo on socket creation failure
| * | | | socket_stream: continue to next addrinfo on socket creation failurePatrick Steinhardt2017-04-261-4/+2
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When connecting to a remote via socket stream, we first use getaddrinfo to obtain the possible connection methods followed by creating and connecting the socket. But when creating the socket, we error out as soon as we get an invalid socket instead of trying out other address hints returned by addrinfo. Fix this by continuing on invalid socket instead of returning an error. This fixes connection establishment with musl libc.
* | | | Merge pull request #4217 from pks-t/pks/readonly-cfg-backendEdward Thomson2017-04-263-22/+106
|\ \ \ \ | | | | | | | | | | Honor read-only flag when writing to config backends
| * | | | tests: config: verify functionality with read-only backendsPatrick Steinhardt2017-04-261-0/+64
| | | | |
| * | | | config: skip r/o backends when writingPatrick Steinhardt2017-04-261-22/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Configuration backends have a readonly-flag which is currently used to distinguish configuration snapshots. But somewhat unexpectedly, we do not use the flag to prevent writing to a readonly backend but happily proceed to do so. This commit modifies logic to also honor the readonly flag for configuration setters. We will now traverse through all backends and pick the first one which is not marked as read-only whenever we want to write new configuration.
| * | | | config_file: add missing include for `git_config_backend`Patrick Steinhardt2017-04-251-0/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | The config_file.h header provides some inline declarations accessing the `git_config_backend`, but misses its declaration. Add the missing include for "git2/sys/config.h" to add it.
* | | | Merge pull request #4215 from pks-t/pks/diff-stack-freeEdward Thomson2017-04-251-1/+1
|\ \ \ \ | |/ / / |/| | | diff_parse: free object instead of its pointer
| * | | diff_parse: free object instead of its pointerPatrick Steinhardt2017-04-251-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | In e7330016a (diff_parse: check return value of `git_diff_init_options`, 2017-03-20), we've introduced an error check whether we're able to correctly initialize the diff options. This simple commit actually introduced a segfault in that we now try to free the pointer to the allocated diff in an error case, instead of the allocated diff itself. This commit fixes the issue.
* | | Merge pull request #4210 from pks-t/pks/misc-fixesPatrick Steinhardt2017-04-212-1/+3
|\ \ \ | | | | | | | | Misc fixes
| * | | tests: threads::diff: fix warning for unused variablePatrick Steinhardt2017-04-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The threads::diff test suite has a static variable `_retries`, which is used on Windows platforms only. As it is unused on other systems, the compiler throws a warning there. Fix the warning by wrapping the declaration in an ifdef.
| * | | global: fix typo in `git_libgit2_init` descriptionPatrick Steinhardt2017-04-211-1/+1
|/ / /
* | | Merge pull request #4192 from libgit2/ethomson/win32_posixCarlos Martín Nieto2017-04-179-111/+407
|\ \ \ | |_|/ |/| | Refactor some of the win32 POSIX emulation
| * | win32: `remediation` not `cleanup`ethomson/win32_posixEdward Thomson2017-04-171-2/+2
| | | | | | | | | | | | | | | | | | The `remediation` function is run in the retry loop in order to attempt to fix any problems that the prior run encountered. There is nothing "cleaned up". Clarify the name.
| * | win32: only set `git_win32__retries` where it existsEdward Thomson2017-04-051-0/+5
| | |
| * | win32: enable `p_utimes` for readonly filesEdward Thomson2017-04-053-88/+160
| | | | | | | | | | | | | | | Instead of failing to set the timestamp of a read-only file (like any object file), set it writable temporarily to update the timestamp.
| * | win32: make posix emulation retries configurableEdward Thomson2017-04-033-1/+11
| | | | | | | | | | | | | | | | | | | | | POSIX emulation retries should be configurable so that tests can disable them. In particular, maniacally threading tests may end up trying to open locked files and need retries, which will slow continuous integration tests significantly.
| * | win32: do not inherit file descriptorsEdward Thomson2017-04-031-1/+8
| | |
| * | Allow to configure default file share mode for opening filesSven Strickroth2017-04-035-11/+37
| | | | | | | | | | | | | | | | | | This can prevent FILE_SHARED_VIOLATIONS when used in tools such as TortoiseGit TGitCache and FILE_SHARE_DELETE, because files can be opened w/o being locked any more. Signed-off-by: Sven Strickroth <email@cs-ware.de>
| * | win32: deduplicate code: use p_open in p_creatSven Strickroth2017-04-021-8/+1
| | | | | | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>