summaryrefslogtreecommitdiff
path: root/src/fetch.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't reset need_packEtienne Samson2014-03-301-1/+2
| | | While looping over multiple heads, an up-to-date head will clobber the `remote->need_pack` setting, preventing the rest of the machinery from building and downloading a pack-file, breaking fetches.
* - need_pack was not set to 0 when local fetch was already present causing ↵Miha2014-02-251-1/+3
| | | | negotiate_fetch access violation
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
* remote: fix a couple of leaksCarlos Martín Nieto2013-11-111-1/+4
|
* remote: make _ls return the list directlyCarlos Martín Nieto2013-11-111-23/+20
| | | | | | | | | | | The callback-based method of listing remote references dates back to the beginning of the network code's lifetime, when we didn't know any better. We need to keep the list around for update_tips() after disconnect() so let's make use of this to simply give the user a pointer to the array so they can write straightforward code instead of having to go through a callback.
* remote: store dwimed refspecs separatelyCarlos Martín Nieto2013-11-011-9/+13
| | | | | This allows us to add e.g. "HEAD" as a refspec when none are given without overwriting the user's data.
* remote: download HEAD when no refspecs are givenCarlos Martín Nieto2013-11-011-5/+6
| | | | | | | The correct behaviour when a remote has no refspecs (e.g. a URL from the command-line) is to download the remote's HEAD. Let's do that. This fixes #1261.
* remote: put the _download() callback with the othersCarlos Martín Nieto2013-10-021-5/+3
| | | | | | The text progress and update_tips callbacks are already part of the struct, which was meant to unify the callback setup, but the download one was left out.
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+2
| | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* remote: correctly interpret tagopt '--tags'Carlos Martín Nieto2013-05-071-3/+9
| | | | | | | When tagopt is set to '--tags', we should only take the default tags refspec into account and ignore any configured ones. Bring the code into compliance.
* remote: handle multiple refspecsCarlos Martín Nieto2013-04-201-2/+1
| | | | | | | | | | | | | A remote can have a multitude of refspecs. Up to now our git_remote's have supported a single one for each fetch and push out of simplicity to get something working. Let the remotes and internal code know about multiple remotes and get the tests passing with them. Instead of setting a refspec, the external users can clear all and add refspecs. This should be enough for most uses, though we're still missing a querying function.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* create callback to handle packs from fetch, move the indexer to odb_packEdward Thomson2012-11-051-1/+0
|
* Reorganize transport architecture (squashed 3)Philip Kelley2012-11-011-382/+11
|
* Remove 'bytes' param from git_remote_downloadBen Straub2012-10-241-10/+4
|
* Network progress: rename thingsBen Straub2012-10-241-10/+10
| | | | | | | git_indexer_stats and friends -> git_transfer_progress* Also made git_transfer_progress members more sanely named.
* gitno_buffer: callback on each packetBen Straub2012-10-191-0/+33
| | | | | The fetch code takes advantage of this to implement a progress callback every 100kb of transfer.
* Fetch/indexer: progress callbacksBen Straub2012-10-191-4/+11
|
* Add git_indexer_stats field to git_remoteBen Straub2012-10-191-3/+3
| | | | | Also removing all the *stats parameters from external APIs that don't need them anymore.
* fetch: declare variables at the top of the blockCarlos Martín Nieto2012-10-181-1/+2
|
* remote: support fetch cancelationCarlos Martín Nieto2012-10-181-5/+28
| | | | | | Introduce git_remote_stop() which sets a variable that is checked by the fetch process in a few key places. If this is variable is set, the fetch is aborted.
* test: fix some memory leaksnulltoken2012-10-151-3/+9
|
* remote: support downloading all tagsCarlos Martín Nieto2012-09-301-10/+17
| | | | Also honor remote.$name.tagopt = --tags.
* Diff iteratorsRussell Belfer2012-09-051-1/+1
| | | | | | | | | | | This refactors the diff output code so that an iterator object can be used to traverse and generate the diffs, instead of just the `foreach()` style with callbacks. The code has been rearranged so that the two styles can still share most functions. This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses that as a common error code for marking the end of iteration when using a iterator style of object.
* indexer: kill git_indexer_stats.data_receivedCarlos Martín Nieto2012-08-261-10/+4
| | | | | | | It's not really needed with the current code as we have EOS and the sideband's flush to tell us we're done. Keep the distinction between processed and received objects.
* network: add sideband supportCarlos Martín Nieto2012-08-241-8/+58
| | | | | This lets us notify the user of what the remote end is doing while we wait for it to start sending us the packfile.
* indexer: recognize and mark when all of the packfile has been downloadedCarlos Martín Nieto2012-08-241-1/+4
| | | | | We can't always rely on the network telling us when the download is finished. Recognize it from the indexer itself.
* remote: add missing include git2/remote.hMichael Schubert2012-08-041-1/+0
| | | | | Otherwise we get an incomplete type error, since git_remote_callbacks isn't declared yet.
* fetch: remove timeout codeCarlos Martín Nieto2012-07-301-13/+0
|
* transport: store the refs in a common areaCarlos Martín Nieto2012-07-301-1/+1
| | | | | | | | 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-26/+60
| | | | | | | | 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-20/+58
|
* remote: start moving the protocol to a common areaCarlos Martín Nieto2012-07-301-6/+123
| | | | | | | 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.
* indexer: don't use '/objects/pack/' unconditionallyCarlos Martín Nieto2012-06-281-2/+7
| | | | | Not everyone who indexes a packfile wants to put it in the standard git repository location.
* http: add https support when GnuTLS is availableCarlos Martín Nieto2012-05-191-2/+2
| | | | | | | | 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.
* refs: git_reference_listall -> git_reference_listVicent Martí2012-05-181-1/+1
|
* fetch: filter tag annotation pseudo-refs while generating wantsCarlos Martín Nieto2012-05-091-0/+4
| | | | | | | These objects aren't considered as being advertised, so asking for them will cause the remote end to close the connection. This makes the checking in update_tips() unnecessary, because they don't get inserted in the list.
* Remove old and unused error codesVicent Martí2012-05-021-9/+1
|
* transports: buffer the git requests before sending themCarlos Martín Nieto2012-04-251-0/+41
| | | | | | 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-33/+23
| | | | | | | | 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.
* error-handling: fetchCarlos Martín Nieto2012-04-111-44/+39
|
* 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-8/+14
| | | | | | | | | | | | | | | | | | | | 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.
* remote: Cleanup the remotes coderepo-ownershipVicent Marti2011-11-281-67/+43
| | | | | | - Hide the remaining transports code - Drop `git_headarray`, switch to using a callback to list refs. Makes the code cleaner.
* repository: Change ownership semanticsVicent Marti2011-11-261-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
* filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanupsRussell Belfer2011-11-221-1/+1
| | | | | | | | Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT and make git_filebuf_open and git_filebuf_cleanup safe to be called multiple times on the same buffer. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* *: correct and codify various file permissionsBrodie Rao2011-10-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
* fetch: add a generic pack-download functionCarlos Martín Nieto2011-10-121-0/+58
| | | | | | | Taken mostly from the git transport's version, this can be used by any transport that takes its pack data from the network. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* transport: don't have an extra send-wants stepCarlos Martín Nieto2011-10-121-6/+1
| | | | | | | It's a bit awkward to run it as an extra step, and HTTP may need to send the wants list several times. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* fetch: move 'head' so it's visible to the whole functionCarlos Martín Nieto2011-10-091-1/+2
| | | | Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>