summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* refdb: bubble up recursive rm when locking a refcmn/refdb-fs-errorsCarlos Martín Nieto2016-12-161-2/+2
| | | | | Failure to bubble up this error means some locking errors do not get reported as such on Windows.
* Fix potential use of uninitialized valuesPatrick Steinhardt2016-12-123-3/+5
|
* graph: flag fields should be declared as unsignedPatrick Steinhardt2016-12-121-1/+1
|
* transports: smart: do not redeclare loop countersPatrick Steinhardt2016-12-121-4/+4
|
* path: remove unused local variablePatrick Steinhardt2016-12-121-1/+0
|
* revwalk: do not re-declare `commit` variablePatrick Steinhardt2016-12-121-1/+1
|
* odb_mempack: mark zero-length array as GIT_FLEX_ARRAYPatrick Steinhardt2016-12-121-1/+1
|
* Merge pull request #4020 from novalis/rebase-detachedEdward Thomson2016-12-071-1/+1
|\ | | | | git_rebase_init: correctly handle detached HEAD
| * git_rebase_init: correctly handle detached HEADDavid Turner2016-12-011-1/+1
| | | | | | | | | | | | | | | | git_rebase_finish relies on head_detached being set, but rebase_init_merge was only setting it when branch->ref_name was unset. But branch->ref_name would be set to "HEAD" in the case of detached HEAD being either implicitly (NULL) or explicitly passed to git_rebase_init.
* | Properly pass `wchar *` type to giterr_setBoris Barbulovski2016-12-061-1/+1
| |
* | Properly pass `wchar *` type to giterr_setBoris Barbulovski2016-11-201-1/+1
|/
* Merge pull request #4010 from libgit2/ethomson/clar_threadsCarlos Martín Nieto2016-11-184-0/+28
|\ | | | | Introduce some clar helpers for child threads
| * threads: introduce `git_thread_exit`Edward Thomson2016-11-184-0/+28
| | | | | | | | | | | | | | | | | | | | 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 *`.
* | use `giterr_set_str()` wherever possiblePranit Bauva2016-11-172-2/+2
|/ | | | | | | | | | `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>
* Merge pull request #4008 from pks-t/pks/sortedcache-fd-leakCarlos Martín Nieto2016-11-152-1/+4
|\ | | | | sortedcache: plug leaked file descriptor
| * patch_parse: fix memory leakPatrick Steinhardt2016-11-151-1/+3
| |
| * sortedcache: plug leaked file descriptorPatrick Steinhardt2016-11-151-0/+1
| |
* | Merge pull request #3996 from pks-t/pks/curl-lastsocket-deprecationCarlos Martín Nieto2016-11-151-3/+14
|\ \ | |/ |/| curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough
| * curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enoughPatrick Steinhardt2016-11-151-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #4006 from libgit2/cmn/compress-buf-freeEdward Thomson2016-11-141-0/+2
|\ \ | | | | | | Plug a leak in the refs compressor
| * | Plug a leak in the refs compressorcmn/compress-buf-freeCarlos Martín Nieto2016-11-141-0/+2
| | |
* | | Merge pull request #3998 from pks-t/pks/repo-discoveryCarlos Martín Nieto2016-11-141-1/+1
|\ \ \ | | | | | | | | Repository discovery starting from files
| * | | repository: do not interpret all files as gitlinks in discoveryPatrick Steinhardt2016-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge pull request #4003 from libgit2/cmn/tree-updater-orderingEdward Thomson2016-11-141-2/+5
|\ \ \ \ | |_|/ / |/| | | Use the sorted input in the tree updater
| * | | tree: look for conflicts in the new tree when updatingcmn/tree-updater-orderingCarlos Martín Nieto2016-11-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | tree: use the sorted update list in our loopCarlos Martín Nieto2016-11-141-2/+2
| |/ / | | | | | | | | | | | | The loop is made with the assumption that the inputs are sorted and not using it leads to bad outputs.
* | | refdb: bubble up locked files on the read sideCarlos Martín Nieto2016-11-143-19/+29
| | | | | | | | | | | | | | | | | | 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.
* | | refdb: remove a check-delete race when removing a loose refCarlos Martín Nieto2016-11-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | sortedcache: check file size after opening the fileCarlos Martín Nieto2016-11-141-5/+13
| | | | | | | | | | | | | | | | | | | | | 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.
* | | refdb: bubble up the error code when compressing the dbCarlos Martín Nieto2016-11-141-4/+5
| | | | | | | | | | | | | | | 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.
* | | refdb: refactor the lockfile cleanupCarlos Martín Nieto2016-11-141-15/+9
| | | | | | | | | | | | | | | 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.
* | | refdb: don't report failure for expected errorsCarlos Martín Nieto2016-11-141-20/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | fileops: save errno and report file existenceCarlos Martín Nieto2016-11-141-1/+9
| | | | | | | | | | | | | | | | | | 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.
* | | refdb: make ref deletion after pack saferCarlos Martín Nieto2016-11-141-7/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | refdb: bubble up errorsCarlos Martín Nieto2016-11-141-9/+10
|/ / | | | | | | | | We can get useful information like GIT_ELOCKED out of this instead of just -1.
* | Merge pull request #4002 from pks-t/pks/giterr-formatCarlos Martín Nieto2016-11-1410-43/+44
|\ \ | | | | | | giterr format
| * | path: pass string instead of git_buf to giterr_setPatrick Steinhardt2016-11-141-1/+1
| | |
| * | checkout: pass string instead of git_buf to `giterr_set`Patrick Steinhardt2016-11-141-2/+2
| | |
| * | common: cast precision specifiers to intPatrick Steinhardt2016-11-142-3/+3
| | |
| * | common: use PRIuZ for size_t in `giterr_set` callsPatrick Steinhardt2016-11-145-36/+36
| | |
| * | common: mark printf-style formatting for `giterr_set`Patrick Steinhardt2016-11-141-1/+2
| | |
* | | Merge pull request #3983 from pks-t/pks/smart-early-eofCarlos Martín Nieto2016-11-141-2/+6
|\ \ \ | | | | | | | | transports: smart: abort on early end of stream
| * | | transports: smart: abort receiving packets on end of streamPatrick Steinhardt2016-11-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to receive packets from the remote, we loop until either an error distinct to `GIT_EBUFS` occurs or until we successfully parsed the packet. This does not honor the case where we are looping over an already closed socket which has no more data, leaving us in an infinite loop if we got a bogus packet size or if the remote hang up. Fix the issue by returning `GIT_EEOF` when we cannot read data from the socket anymore.
| * | | transports: smart: abort ref announcement on early end of streamPatrick Steinhardt2016-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reading a server's reference announcements via the smart protocol, we expect the server to send multiple flushes before the protocol is finished. If we fail to receive new data from the socket, we will only return an end of stream error if we have not seen any flush yet. This logic is flawed in that we may run into an infinite loop when receiving a server's reference announcement with a bogus flush packet. E.g. assume the last flushing package is changed to not be '0000' but instead any other value. In this case, we will still await one more flush package and ignore the fact that we are not receiving any data from the socket, causing an infinite loop. Fix the issue by always returning `GIT_EEOF` if the socket indicates an end of stream.
* | | | Merge pull request #3992 from joshtriplett/env-namespacePatrick Steinhardt2016-11-141-5/+8
|\ \ \ \ | |_|/ / |/| | | git_repository_open_ext: fix handling of $GIT_NAMESPACE
| * | | git_repository_open_ext: fix handling of $GIT_NAMESPACEJosh Triplett2016-11-111-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing code would set a namespace of "" (empty string) with GIT_NAMESPACE unset. In a repository where refs/heads/namespaces/ exists, that can produce incorrect results. Detect that case and avoid setting the namespace at all. Since that makes the last assignment to error conditional, and the previous assignment can potentially get GIT_ENOTFOUND, set error to 0 explicitly to prevent the call from incorrectly failing with GIT_ENOTFOUND.
* | | | fileops: fix typos in `git_futils_creat_locked{,with_path}`Patrick Steinhardt2016-11-141-2/+2
| |_|/ |/| |
* | | curl_stream: check for -1 after CURLINFO_LASTSOCKETAlex Crichton2016-11-111-0/+6
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're recently trying to upgrade to the current master of libgit2 in Cargo but we're unfortunately hitting a segfault in one of our tests. This particular test is just a small smoke test that https works (e.g. it's configured in libgit2). It attempts to clone from a URL which simply immediately drops connections after they're accepted (e.g. terminate abnormally). We expect to see a standard error from libgit2 but unfortunately we're seeing a segfault. This segfault is happening inside of the `wait_for` function of `curl_stream.c` at the line `FD_SET(fd, &errfd)` because `fd` is -1. This ends up doing an out-of-bounds array access that faults the program. I tracked back to where this -1 came from to the line here (returned by `CURLINFO_LASTSOCKET`) and added a check to return an error.
* | Merge pull request #3974 from libgit2/pks/synchronize-shutdownPatrick Steinhardt2016-11-041-4/+19
|\ \ | | | | | | global: synchronize initialization and shutdown with pthreads
| * | global: reset global state on shutdown without threadingPatrick Steinhardt2016-11-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When threading is not enabled for libgit2, we keep global state in a simple static variable. When libgit2 is shut down, we clean up the global state by freeing the global state's dynamically allocated memory. When libgit2 is built with threading, we additionally free the thread-local storage and thus completely remove the global state. In a non-threaded build, though, we simply leave the global state as-is, which may result in an error upon reinitializing libgit2. Fix the issue by zeroing out the variable on a shutdown, thus returning it to its initial state.