Commit Graph

9774 Commits

Author SHA1 Message Date
Elliot Saba
e56e4c76b9 CMakeLists: Move http-parser block down by zlib, update error message 2016-12-30 17:59:47 -08:00
Elliot Saba
236a690ce4 Allow Windows with WinHTTP to use external http-parser 2016-11-20 22:46:01 -08:00
Carlos Martín Nieto
ae5838f118 Merge pull request #4010 from libgit2/ethomson/clar_threads
Introduce some clar helpers for child threads
2016-11-18 21:01:51 +01:00
Edward Thomson
6367c58cd4 tests: handle life without threads 2016-11-18 19:00:14 +00:00
Edward Thomson
6a05c7a0ef threads::refdb tests: use new threaded clar assert 2016-11-18 16:52:28 +00:00
Edward Thomson
bbf22f8229 clar: Introduce assertion helpers for threads
Don't `cl_git_pass` in a child thread.  When the assertion fails, clar
will `longjmp` to its error handler, but:

> The effect of a call to longjmp() where initialization of the jmp_buf
> structure was not performed in the calling thread is undefined.

Instead, set up an error context that threads can populate, and the
caller can check.
2016-11-18 16:52:28 +00:00
Edward Thomson
99479062db core::init tests: reverse init/shutdown
We want a predictable number of initializations in our multithreaded
init test, but we also want to make sure that we have _actually_
initialized `git_libgit2_init` before calling `git_thread_create` (since
it now has a sanity check that `git_libgit2_init` has been called).

Since `git_thread_create` is internal-only, keep this sanity check.
Flip the invocation so that we `git_libgit2_init` before our thread
tests and `git_libgit2_shutdown` again after.
2016-11-18 16:52:28 +00:00
Edward Thomson
82f15896de threads: introduce git_thread_exit
Introduce `git_thread_exit`, which will allow threads to terminate at an
arbitrary time, returning a `void *`.  On Windows, this means that we
need to store the current `git_thread` in TLS, so that we can set its
`return` value when terminating.

We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from
threads; we return `void *`.
2016-11-18 07:34:09 -05:00
Carlos Martín Nieto
6b0510e5e1 Merge pull request #4009 from pranitbauva1997/fix-string-format
use `giterr_set_str()` wherever possible
2016-11-17 15:45:23 +01:00
Pranit Bauva
65b78ea301 use giterr_set_str() wherever possible
`giterr_set()` is used when it is required to format a string, and since
we don't really require it for this case, it is better to stick to
`giterr_set_str()`.

This also suppresses a warning(-Wformat-security) raised by the compiler.

Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
2016-11-17 01:12:12 +05:30
Carlos Martín Nieto
a6763ff93a Merge pull request #4007 from libgit2/cmn/bump-v25
Bump version number to v0.25
2016-11-15 19:04:18 +01:00
Carlos Martín Nieto
0cd162be88 Merge pull request #4008 from pks-t/pks/sortedcache-fd-leak
sortedcache: plug leaked file descriptor
2016-11-15 16:28:10 +01:00
Patrick Steinhardt
613381fc14 patch_parse: fix memory leak 2016-11-15 13:33:05 +01:00
Patrick Steinhardt
24b2182c5a sortedcache: plug leaked file descriptor 2016-11-15 12:53:53 +01:00
Carlos Martín Nieto
1db3035d74 Merge pull request #3996 from pks-t/pks/curl-lastsocket-deprecation
curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough
2016-11-15 12:18:49 +01:00
Carlos Martín Nieto
5569778a52 Bump version number to v0.25 2016-11-15 11:15:40 +01:00
Carlos Martín Nieto
f5ea9d4a5f Merge pull request #3962 from libgit2/ethomson/issue_template
Introduce a GitHub Issue Template
2016-11-15 11:02:30 +01:00
Carlos Martín Nieto
7ebf099d79 Merge pull request #4004 from libgit2/cmn/changelog
CHANGELOG: fill in some updates we missed
2016-11-15 10:54:15 +01:00
Patrick Steinhardt
5cbd52607c curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough
The `CURLINFO_LASTSOCKET` information has been deprecated since
curl version 7.45.0 as it may result in an overflow in the
returned socket on certain systems, most importantly on 64 bit
Windows. Instead, a new call `CURLINFO_ACTIVESOCKET` has been
added which instead returns a `curl_socket_t`, which is always
sufficiently long to store a socket.

As we need to provide backwards compatibility with curl versions
smaller than 7.45.0, alias CURLINFO_ACTIVESOCKET to
CURLINFO_LASTSOCKET on platforms without CURLINFO_ACTIVESOCKET.
2016-11-15 09:12:40 +01:00
Edward Thomson
1d683c1d2e Merge pull request #4006 from libgit2/cmn/compress-buf-free
Plug a leak in the refs compressor
2016-11-14 19:21:56 +00:00
Edward Thomson
8c984fea02 Introduce a GitHub Issue Template 2016-11-14 17:16:37 +00:00
Carlos Martín Nieto
06de4e759a CHANGELOG: fill in some updates we missed 2016-11-14 17:58:58 +01:00
Carlos Martín Nieto
21e0fc32ab Plug a leak in the refs compressor 2016-11-14 17:55:49 +01:00
Carlos Martín Nieto
a39f18ac77 Merge pull request #3998 from pks-t/pks/repo-discovery
Repository discovery starting from files
2016-11-14 17:10:43 +01:00
Edward Thomson
df045cef68 Merge pull request #4003 from libgit2/cmn/tree-updater-ordering
Use the sorted input in the tree updater
2016-11-14 12:12:38 +00:00
Edward Thomson
904e1e75f9 Merge pull request #3561 from libgit2/cmn/refdb-para
Concurrency fixes for the reference db
2016-11-14 11:52:49 +00:00
Carlos Martín Nieto
8977658519 tree: look for conflicts in the new tree when updating
We look at whether we're trying to replace a blob with a tree during the
update phase, but we fail to look at whether we've just inserted a blob
where we're now trying to insert a tree.

Update the check to look at both places. The test for this was
previously succeeding due to the bu where we did not look at the sorted
output.
2016-11-14 12:44:52 +01:00
Carlos Martín Nieto
b85929c523 tree: use the sorted update list in our loop
The loop is made with the assumption that the inputs are sorted and not
using it leads to bad outputs.
2016-11-14 12:44:01 +01:00
Carlos Martín Nieto
1d41b86cd0 tree: add a failing test for unsorted input
We do not currently use the sorted version of this input in the
function, which means we produce bad results.
2016-11-14 12:22:20 +01:00
Carlos Martín Nieto
aef54a466a refdb: use a constant for the number of per-thread creations/deletes 2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
ce5553d48b refdb: bubble up locked files on the read side
On Windows we can find locked files even when reading a reference or the
packed-refs file. Bubble up the error in this case as well to allow
callers on Windows to retry more intelligently.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
7c32d87450 refdb: expect threaded test deletes to race
At times we may try to delete a reference which a different thread has
already taken care of.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
33248b9edb refdb: remove a check-delete race when removing a loose ref
It does not help us to check whether the file exists before trying to
unlink it since it might be gone by the time unlink is called.

Instead try to remove it and handle the resulting error if it did not
exist.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
40ffa07f4f sortedcache: check file size after opening the file
Checking the size before we open the file descriptor can lead to the
file being replaced from under us when renames aren't quite atomic, so
we can end up reading too little of the file, leading to us thinking the
file is corrupted.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
26416f6d20 refdb: add retry logic to the threaded tests
The logic simply consists of retrying for as long as the library says
the data is locked, but it eventually gets through.
2016-11-14 11:35:38 +01:00
Carlos Martín Nieto
2e09106e7a refdb: bubble up the error code when compressing the db
This allows the caller to know the errors was e.g. due to the
packed-refs file being already locked and they can try again later.
2016-11-14 11:35:37 +01:00
Carlos Martín Nieto
dd1ca6f15a refdb: refactor the lockfile cleanup
We can reduce the duplication by cleaning up at the beginning of the
loop, since it's something we want to do every time we continue.
2016-11-14 11:35:35 +01:00
Carlos Martín Nieto
7ea4710ae3 refdb: don't report failure for expected errors
There might be a few threads or processes working with references
concurrently, so fortify the code to ignore errors which come from
concurrent access which do not stop us from continuing the work.

This includes ignoring an unlinking error. Either someone else removed
it or we leave the file around. In the former case the job is done, and
in the latter case, the ref is still in a valid state.
2016-11-14 11:34:14 +01:00
Carlos Martín Nieto
f94825c10c fileops: save errno and report file existence
We need to save the errno, lest we clobber it in the giterr_set()
call. Also add code for reporting that a path component is missing,
which is a distinct failure mode.
2016-11-14 11:34:14 +01:00
Carlos Martín Nieto
2d9aec99fb refdb: make ref deletion after pack safer
In order not to undo concurrent modifications to references, we must
make sure that we only delete a loose reference if it still has the same
value as when we packed it.

This means we need to lock it and then compare the value with the one we
put in the packed file.
2016-11-14 11:34:08 +01:00
Carlos Martín Nieto
9914efec2a refdb: bubble up errors
We can get useful information like GIT_ELOCKED out of this instead of
just -1.
2016-11-14 11:25:58 +01:00
Carlos Martín Nieto
7da4c429ea refdb: adjust the threading tests to what we promise
We say it's going to work if you use a different repository in each
thread. Let's do precisely that in our code instead of hoping re-using
the refdb is going to work.

This test does fail currently, surfacing existing bugs.
2016-11-14 11:25:58 +01:00
Patrick Steinhardt
0f31609611 repository: do not interpret all files as gitlinks in discovery
When trying to find a discovery, we walk up the directory
structure checking if there is a ".git" file or directory and, if
so, check its validity. But in the case that we've got a ".git"
file, we do not want to unconditionally assume that the file is
in fact a ".git" file and treat it as such, as we would error out
if it is not.

Fix the issue by only treating a file as a gitlink file if it
ends with "/.git". This allows users of the function to discover
a repository by handing in any path contained inside of a git
repository.
2016-11-14 10:53:08 +01:00
Patrick Steinhardt
4dbaf3cd62 test: discover: fix indentation 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
5242c42488 test: discover: split up monolithic test into smaller ones 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
07afeb23ae test: discover: pass constants to ensure_repository_discover 2016-11-14 10:53:08 +01:00
Patrick Steinhardt
2382b0f877 test: discover: move layout creation into test initializer 2016-11-14 10:53:08 +01:00
Carlos Martín Nieto
e1c14335d8 Merge pull request #4002 from pks-t/pks/giterr-format
giterr format
2016-11-14 10:48:57 +01:00
Carlos Martín Nieto
cc5966b071 Merge pull request #3983 from pks-t/pks/smart-early-eof
transports: smart: abort on early end of stream
2016-11-14 10:39:45 +01:00
Carlos Martín Nieto
eb71490ac2 Merge pull request #3985 from libgit2/cmn/threading-update
Update THREADING for OpenSSL 1.1
2016-11-14 10:19:30 +01:00