summaryrefslogtreecommitdiff
path: root/src/remote.c
Commit message (Collapse)AuthorAgeFilesLines
* git__getenv: utf-8 aware env readerEdward Thomson2015-07-021-9/+18
| | | | | | Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere. Make `cl_getenv` use this to keep consistent memory handling around return values (free everywhere, as opposed to only some platforms).
* Merge pull request #3255 from libgit2/cmn/rename-unspecifiedEdward Thomson2015-06-251-2/+2
|\ | | | | Rename FALLBACK to UNSPECIFIED
| * Rename FALLBACK to UNSPECIFIEDcmn/rename-unspecifiedCarlos Martín Nieto2015-06-251-2/+2
| | | | | | | | | | Fallback describes the mechanism, while unspecified explains what the user is thinking.
* | remote: insert refspecs with no rhs in FETCH_HEADcmn/fetch-spec-fetchheadCarlos Martín Nieto2015-06-251-3/+14
|/ | | | | | | | | When a refspec contains no rhs and thus won't cause an explicit update, we skip all the logic, but that means that we don't update FETCH_HEAD with it, which is what the implicit rhs is. Add another bit of logic which puts those remote heads in the list of updates so we put them into FETCH_HEAD.
* remote: return EINVALIDSPEC when given an empty URLcmn/url-emptyCarlos Martín Nieto2015-06-161-2/+6
| | | | | | This is what we used to return in the settter and there's tests in bindings which ask for this. There's no particular reason to stop doing so.
* remote: some error-handling issues from CoverityCarlos Martín Nieto2015-06-071-2/+3
|
* remote: apply insteadOf configuration.Patrick Steinhardt2015-05-311-5/+70
| | | | | | | | A remote's URLs are now modified according to the url.*.insteadOf and url.*.pushInsteadOf configurations. This allows a user to replace URL prefixes by setting the corresponding keys. E.g. "url.foo.insteadOf = bar" would replace the prefix "bar" with the new prefix "foo".
* remote: call the update_tips callback for opportunisitc updatesCarlos Martín Nieto2015-05-281-9/+31
| | | | | These are updates, same as the rest, we should call this callback. As we are using the callback, let's make sure to skip unnecessary updates.
* remote: validate refspecs before adding to configCarlos Martín Nieto2015-05-281-0/+10
| | | | | | | When we moved from acting on the instance to acting on the configuration, we dropped the validation of the passed refspec, which can lead to writing an invalid refspec to the configuration. Bring that validation back.
* remote: remove fetch parameter from create_anonymousCarlos Martín Nieto2015-05-281-2/+2
| | | | | | An anonymous remote is not configured and cannot therefore have configured refspecs. Remove the parameter which adds this from the constructor.
* remote: get rid of the run-time refspec settersCarlos Martín Nieto2015-05-171-22/+6
| | | | | | | | These were left over from the culling as it's not clear which use-cases might benefit from this. It is not clear that we want to support any use-case which depends on changing the remote's idea of the base refspecs rather than passing in different per-operation refspec list, so remove these functions.
* remote: simplify anonymous creationCarlos Martín Nieto2015-05-131-8/+1
| | | | | We're down to simply having it be a call to create_internal() so let's simply do that. The rest of the code is just a distraction.
* remote: remove git_remote_save()Carlos Martín Nieto2015-05-131-24/+0
| | | | | It has now become a no-op, so remove the function and all references to it.
* remote: remove live changing of refspecsCarlos Martín Nieto2015-05-131-30/+42
| | | | | | | | | | | | The base refspecs changing can be a cause of confusion as to what is the current base refspec set and complicate saving the remote's configuration. Change `git_remote_add_{fetch,push}()` to update the configuration instead of an instance. This finally makes `git_remote_save()` a no-op, it will be removed in a later commit.
* remote: move the tagopt setting to the fetch optionsCarlos Martín Nieto2015-05-131-44/+59
| | | | | This is another option which we should not be keeping in the remote, but is specific to each particular operation.
* remote: move the update_fetchhead setting to the optionsCarlos Martín Nieto2015-05-131-19/+9
| | | | | | While this will rarely be different from the default, having it in the remote adds yet another setting it has to keep around and can affect its behaviour. Move it to the options.
* remote: move the transport ctor to the callbacksCarlos Martín Nieto2015-05-131-22/+5
| | | | | | | Instead of having it set in a different place from every other callback, put it the main structure. This removes some state from the remote and makes it behave more like clone, where the constructors are passed via the options.
* remote: add prune option to fetchCarlos Martín Nieto2015-05-131-1/+11
| | | | | Add a prune setting in the fetch options to allow to fall back to the configuration (the default) or to set it on or off.
* remote: remove url and pushurl from the save logicCarlos Martín Nieto2015-05-131-35/+53
| | | | | | As a first step in removing the repository-saving logic, don't allow chaning the url or push url from a remote object, but change the configuration on the configuration immediately.
* Remove the callbacks struct from the remoteCarlos Martín Nieto2015-05-131-52/+71
| | | | | | | | | | | | | | Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
* push: remove own copy of callbacksCarlos Martín Nieto2015-05-131-7/+1
| | | | | | | | | The push object knows which remote it's associated with, and therefore does not need to keep its own copy of the callbacks stored in the remote. Remove the copy and simply access the callbacks struct within the remote.
* Merge pull request #3059 from libgit2/cmn/negotiation-notifyEdward Thomson2015-05-011-1/+2
|\ | | | | [WIP/RFC] push: report the update plan to the caller
| * push: report the update plan to the callercmn/negotiation-notifyCarlos Martín Nieto2015-04-191-1/+2
| | | | | | | | | | | | | | | | | | It can be useful for the caller to know which update commands will be sent to the server before the packfile is pushed up. git does this via the pre-push hook. We don't have hooks, but as it adds introspection into what is happening, we can add a callback which performs the same function.
* | Fix some build warningsLeo Yang2015-04-281-4/+4
|/ | | | | | | | | | | | In checkout.c and filter.c we were casting a sub struct to a parent struct which breaks the strict aliasing rules in C. However we can use .parent or .base to access the parent struct to avoid the build warnings. In remote.c the local variable error was not initialized or updated in some cases. For unintialized error a build warning will be generated. So always keep error variable up-to-date.
* Merge pull request #2955 from git-up/update_tips_fixesCarlos Martín Nieto2015-03-181-0/+4
|\ | | | | Update tips fixes
| * Fixed active refspecs not reset by git_remote_upload()Pierre-Olivier Latour2015-03-111-0/+4
| |
* | Initialize refs vector in git_remote_update_tips().Sebastian Bauer2015-03-171-1/+1
|/ | | | | Otherwise, bailing out early when ls_to_vector() fails accesses uninitialized memory.
* config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-031-3/+6
| | | | | | | | | | | | | | | This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
* push: remove reflog message overrideCarlos Martín Nieto2015-03-031-4/+3
| | | | We always use "update by push".
* Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-031-15/+12
| | | | | | | | | | The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-2/+1
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* remote: plug leakEdward Thomson2015-01-081-5/+5
|
* Fix intentation.David Calavera2015-01-051-1/+1
|
* Load prune configuration when a remote is created.David Calavera2015-01-051-14/+34
|
* Fixed internal push state not being cleared on downloadPierre-Olivier Latour2015-01-011-0/+5
| | | | git_remote_download() must also clear the internal push state resulting from a possible earlier push operation. Otherwise calling git_remote_update_tips() will execute the push version instead of the fetch version and among other things, tags won't be updated.
* Merge pull request #2761 from libgit2/cmn/fetch-pruneEdward Thomson2014-12-301-0/+167
|\ | | | | Remote-tracking branch prunning
| * fetch: remove the prune setterCarlos Martín Nieto2014-12-141-5/+0
| | | | | | | | | | | | | | | | This option does not get persisted to disk, which makes it different from the rest of the setters. Remove it until we go all the way. We still respect the configuration option, and it's still possible to perform a one-time prune by calling the function.
| * fetch: perform prune in separate stepsCarlos Martín Nieto2014-12-141-45/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For each remote-tracking branch we want to remove, we need to consider it against every other refspec in case we have overlapping refspecs, such as with refs/heads/*:refs/remotes/origin/* refs/pull/*/head:refs/remotes/origin/pr/* as we'd otherwise remove too many refspecs. Create a list of condidates, which are the references matching the rhs of any active refspec and then filter that list by removing those entries for which we find a remove reference with any active refspec. Those which are left after this are removed.
| * fetch: prune after updating tipsCarlos Martín Nieto2014-12-141-3/+6
| | | | | | | | | | This makes a fetch+prune more similar to a connect+prune and makes it more likely that we see errors in the decision to prune a reference.
| * Test that prune overlapping works as expected.David Calavera2014-12-141-1/+0
| |
| * remote: prune refs when fetchingLinquize2014-12-141-0/+103
| |
* | remote: remove git_push from the public APIcmn/hide-pushCarlos Martín Nieto2014-12-301-12/+41
|/ | | | | Instead we provide git_remote_upload() and git_remote_update_tips() in order to have a parallel API for fetching and pushing.
* push: fold unpack_ok() into finish()Carlos Martín Nieto2014-12-101-6/+0
| | | | | The push cannot be successful if we sent a bad packfile. We should return an error in that case instead of storing it elsewhere.
* remote: verify there is a push foreach callback setCarlos Martín Nieto2014-11-231-1/+2
|
* Plug leaksCarlos Martín Nieto2014-11-231-0/+1
| | | | Valgrind is now clean except for libssl and libgcrypt.
* remote: clarify which list of references _ls() returnsCarlos Martín Nieto2014-11-191-1/+1
| | | | | Make it clear that this is not the ls-remote command but a way to access the data we have and how long it's kept around.
* Merge pull request #2608 from libgit2/cmn/remote-pushEdward Thomson2014-11-181-0/+60
|\ | | | | Provide a convenience function `git_remote_push()`
| * remote: use configured push refspecs if none are givencmn/remote-pushCarlos Martín Nieto2014-11-091-3/+13
| | | | | | | | | | If the user does not pass any refspecs to push, try to use those configured via the configuration or via add_push().
| * remote: introduce git_remote_push()Carlos Martín Nieto2014-11-091-0/+50
| | | | | | | | | | | | | | | | | | This function, similar in style to git_remote_fetch(), performs all the steps required for a push, with a similar interface. The remote callbacks struct has learnt about the push callbacks, letting us set the callbacks a single time instead of setting some in the remote and some in the push operation.
* | Fixed active_refspecs field not initialized on new git_remote objectsPierre-Olivier Latour2014-11-171-0/+4
|/ | | | | | | | | When creating a new remote, contrary to loading one from disk, active_refspecs was not populated. This means that if using the new remote to push, git_push_update_tips() will be a no-op since it checks the refspecs passed during the push against the base ones i.e. active_refspecs. And therefore the local refs won't be created or updated after the push operation.