summaryrefslogtreecommitdiff
path: root/src/transports/git.c
Commit message (Collapse)AuthorAgeFilesLines
* net: rename gitno_connection_data to git_net_urlEdward Thomson2019-06-101-16/+11
| | | | | | | | | | "Connection data" is an imprecise and largely incorrect name; these structures are actually parsed URLs. Provide a parser that takes a URL string and produces a URL structure (if it is valid). Separate the HTTP redirect handling logic from URL parsing, keeping a `gitno_connection_data_handle_redirect` whose only job is redirect handling logic and does not parse URLs itself.
* streams: fix callers potentially only writing partial dataPatrick Steinhardt2019-01-311-10/+6
| | | | | | | | | | | | | | | | | | | | | Similar to the write(3) function, implementations of `git_stream_write` do not guarantee that all bytes are written. Instead, they return the number of bytes that actually have been written, which may be smaller than the total number of bytes. Furthermore, due to an interface design issue, we cannot ever write more than `SSIZE_MAX` bytes at once, as otherwise we cannot represent the number of bytes written to the caller. Unfortunately, no caller of `git_stream_write` ever checks the return value, except to verify that no error occurred. Due to this, they are susceptible to the case where only partial data has been written. Fix this by introducing a new function `git_stream__write_full`. In contrast to `git_stream_write`, it will always return either success or failure, without returning the number of bytes written. Thus, it is able to write all `SIZE_MAX` bytes and loop around `git_stream_write` until all data has been written. Adjust all callers except the BIO callbacks in our mbedtls and OpenSSL streams, which already do the right thing and require the amount of bytes written.
* git transport: only write INT_MAX bytesEdward Thomson2019-01-251-5/+9
| | | | | The transport code returns an `int` with the number of bytes written; thus only attempt to write at most `INT_MAX`.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-6/+6
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-1/+1
|
* stream: Gather streams to src/streamsEtienne Samson2017-10-231-1/+1
|
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-3/+3
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* git: put NULL check at the topCarlos Martín Nieto2015-10-301-2/+5
|
* git: accept NULL as argument to its stream freeCarlos Martín Nieto2015-10-301-2/+2
|
* Handle ssh:// and git:// urls containing a '~' character.Simon2015-08-031-0/+2
| | | | | For such a path '/~/...' the leading '/' is stripped so the server will get a path starting with '~' and correctly handle it.
* Merge pull request #2990 from leoyanggit/custom_paramEdward Thomson2015-03-241-1/+3
|\ | | | | Add a custom param to git_smart_subtransport_definition
| * Add a custom param to git_smart_subtransport_definitionLeo Yang2015-03-181-1/+3
| | | | | | | | | | The smart transport has already take the payload param. For the sub transport a payload param is useful for the implementer.
* | git: make sure to close the network streamCarlos Martín Nieto2015-03-211-0/+1
|/ | | | | In case of a bad url or other error during the connection setup, we close the stream via free.
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-2/+2
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Port the TCP transport to the new stream APICarlos Martín Nieto2014-12-101-57/+71
|
* Custom transport: minor cleanupsEdward Thomson2014-08-141-0/+1
| | | | | | | | | | | | * Move the transport registration mechanisms into a new header under 'sys/' because this is advanced stuff. * Remove the 'priority' argument from the registration as it adds unnecessary complexity. (Since transports cannot decline to operate, only the highest priority transport is ever executed.) Users who require per-priority transports can implement that in their custom transport themselves. * Simplify registration further by taking a scheme (eg "http") instead of a prefix (eg "http://").
* Further EUSER and error propagation fixesRussell Belfer2013-12-111-11/+16
| | | | | | | | | | | | | This continues auditing all the places where GIT_EUSER is being returned and making sure to clear any existing error using the new giterr_user_cancel helper. As a result, places that relied on intercepting GIT_EUSER but having the old error preserved also needed to be cleaned up to correctly stash and then retrieve the actual error. Additionally, as I encountered places where error codes were not being propagated correctly, I tried to fix them up. A number of those fixes are included in the this commit as well.
* Use http_parser_parse_url to parse urlsBen Straub2013-11-041-42/+30
|
* Initialize variablesBen Straub2013-10-301-2/+2
|
* Address feedbackBen Straub2013-02-041-4/+4
|
* Remove double-free segfaultsBen Straub2013-01-311-6/+6
|
* Enhance url parsing to include passwordsBen Straub2013-01-311-4/+6
|
* Stash username from url (but don't use it yet)Ben Straub2013-01-301-4/+6
|
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Remove casts of return values of type void *Philip Kelley2012-11-291-2/+2
|
* Push! By schu, phkelley, and congyiwu, et alPhilip Kelley2012-11-281-8/+81
|
* Reorganize transport architecture (squashed 3)Philip Kelley2012-11-011-130/+160
|
* network: add sideband supportCarlos Martín Nieto2012-08-241-1/+1
| | | | | This lets us notify the user of what the remote end is doing while we wait for it to start sending us the packfile.
* transport: store the refs in a common areaCarlos Martín Nieto2012-07-301-79/+23
| | | | | | | | Instad of each transport having its own function and logic to get to its refs, store them directly in transport. Leverage the new gitno_buffer to make the parsing and storing of the refs use common code and get rid of the git_protocol struct.
* remote: use the same code to control git and httpCarlos Martín Nieto2012-07-301-37/+1
| | | | | | | | This allows us to add capabilitites to both at the same time, keeps them in sync and removes a lot of code. gitno_buffer now uses a callback to fill its buffer, allowing us to use the same interface for git and http (which uses callbacks).
* network: implement multi_ack for the git transportCarlos Martín Nieto2012-07-301-0/+10
|
* remote: start moving the protocol to a common areaCarlos Martín Nieto2012-07-301-156/+6
| | | | | | | For the transition, http is going to keep its own logic until the git/common code catches up with the implied multi_ack that http has. This also has the side-effect of making the code cleaner and more correct regardingt he protocol.
* transports: fix bugletMichael Schubert2012-06-051-1/+1
|
* Merge pull request #697 from carlosmn/sslVicent Martí2012-06-051-27/+24
|\ | | | | Add HTTPS support
| * http: add https support when GnuTLS is availableCarlos Martín Nieto2012-05-191-27/+24
| | | | | | | | | | | | | | | | If it's not available, an error saying so will be returned when trying to use a https:// URL. This also unifies a lot of the network code to use git_transport in many places instead of an socket descriptor.
* | Fix git_close/http_close/local_close to set the transport's connected ↵Arthur Schreiber2012-06-021-0/+2
|/ | | | attribute to 0.
* errors: Rename error codesbreaking-changesVicent Martí2012-05-181-3/+3
|
* errors: Rename the generic return codesVicent Martí2012-05-181-5/+5
|
* transport git: don't use 'error' uninitializedCarlos Martín Nieto2012-05-061-1/+1
|
* Merge remote-tracking branch 'scottjg/fix-mingw32' into developmentVicent Martí2012-05-051-10/+13
|\ | | | | | | | | | | | | | | Conflicts: src/netops.c src/netops.h src/transports/http.c tests-clar/clar
| * Fix gitno_connect() error handling on WindowsScott J. Goldman2012-05-051-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | gitno_connect() can return an error or socket, which is fine on most platforms where sockets are file descriptors (signed int), but on Windows, SOCKET is an unsigned type, which is problematic when we are trying to test if the socket was actually a negative error code. This fix seperates the error code and socket in gitno_connect(), and fixes the error handling in do_connect() functions to compensate. It appears that git_connect() and the git-transport do_connect() functions had bugs in the non-windows cases too (leaking sockets, and not properly reporting connection error, respectively) so I went ahead and fixed those too.
* | Remove old and unused error codesVicent Martí2012-05-021-1/+1
| |
* | transports: buffer the git requests before sending themCarlos Martín Nieto2012-04-251-48/+24
| | | | | | | | | | | | Trying to send every single line immediately won't give us any speed improvement and duplicates the code we need for other transports. Make the git transport use the same buffer functions as HTTP.
* | fetch: use the streaming indexer when downloading a packCarlos Martín Nieto2012-04-251-2/+2
| | | | | | | | | | | | | | | | This changes the git_remote_download() API, but the existing one is silly, so you don't get to complain. The new API allows to know how much data has been downloaded, how many objects we expect in total and how many we've processed.
* | Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-3/+4
| | | | | | | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* | error-handling: git transportCarlos Martín Nieto2012-04-111-134/+127
| |
* | error-handling: RepositoryVicent Martí2012-03-071-1/+4
|/ | | | | | | | This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.