src/remote.c


Log

Author Commit Date CI Message
Carlos Martín Nieto 9a97f49e 2014-12-21T15:31:03 config: borrow refcounted references 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.
Carlos Martín Nieto 412a3808 2015-01-15T15:31:23 push: remove reflog message override We always use "update by push".
Carlos Martín Nieto 659cf202 2015-01-07T12:23:05 Remove the signature from ref-modifying functions 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.
Edward Thomson 392702ee 2015-02-09T23:41:13 allocations: test for overflow of requested size Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
Edward Thomson a8846da7 2015-01-08T13:45:22 remote: plug leak
David Calavera 66b71ea5 2015-01-05T13:33:36 Fix intentation.
David Calavera 1ef3f0ce 2015-01-05T13:24:11 Load prune configuration when a remote is created.
Pierre-Olivier Latour c070ac64 2015-01-01T04:14:58 Fixed internal push state not being cleared on download 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.
Edward Thomson a3ef70bb 2014-12-30T11:53:55 Merge pull request #2761 from libgit2/cmn/fetch-prune Remote-tracking branch prunning
Carlos Martín Nieto fe794b2e 2014-12-16T08:57:05 remote: remove git_push from the public API Instead we provide git_remote_upload() and git_remote_update_tips() in order to have a parallel API for fetching and pushing.
Carlos Martín Nieto 26186b15 2014-12-14T21:01:19 fetch: remove the prune setter 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.
Carlos Martín Nieto 59ff8b67 2014-12-14T18:24:54 fetch: perform prune in separate steps 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.
Carlos Martín Nieto 8c13eaed 2014-12-14T17:00:54 fetch: prune after updating tips 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.
David Calavera 439e19f6 2014-11-12T17:12:30 Test that prune overlapping works as expected.
Linquize 5f473947 2014-09-22T23:17:35 remote: prune refs when fetching
Carlos Martín Nieto d524b2d3 2014-12-10T17:23:33 push: fold unpack_ok() into finish() The push cannot be successful if we sent a bad packfile. We should return an error in that case instead of storing it elsewhere.
Carlos Martín Nieto 52ee0e8e 2014-11-23T21:26:53 remote: verify there is a push foreach callback set
Carlos Martín Nieto f7fcb18f 2014-11-23T14:12:54 Plug leaks Valgrind is now clean except for libssl and libgcrypt.
Carlos Martín Nieto 699dfcc3 2014-11-19T15:49:02 remote: clarify which list of references _ls() returns 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.
Edward Thomson 45301cca 2014-11-18T11:44:59 Merge pull request #2608 from libgit2/cmn/remote-push Provide a convenience function `git_remote_push()`
Pierre-Olivier Latour d3cd7da5 2014-10-28T20:56:18 Fixed active_refspecs field not initialized on new git_remote objects 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.
Carlos Martín Nieto 64e3e6d4 2014-10-11T12:25:50 remote: use configured push refspecs if none are given If the user does not pass any refspecs to push, try to use those configured via the configuration or via add_push().
Carlos Martín Nieto 3149547b 2014-10-10T12:39:53 remote: introduce git_remote_push() 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.
Pierre-Olivier Latour e284c451 2014-10-28T22:18:38 Changed GIT_REMOTE_DOWNLOAD_TAGS_ALL to behave like git 1.9.0
Edward Thomson 02bc5233 2014-11-08T17:05:13 Merge pull request #2698 from libgit2/cmn/fetchhead-refactor Refactor fetchhead
Carlos Martín Nieto 2c9b9c8b 2014-11-08T20:40:02 remote: refactor the reference-update decision This is an ugly chunk of code, so let's put it into its own function.
Carlos Martín Nieto 64fdd86d 2014-11-08T20:21:14 remote: don't check for upstream on an anonymous remote If the remote is anonymous, then we cannot check for any configuration, as there is no name. Check for this before we try to use the name, which may be a NULL pointer. This fixes #2697.
Carlos Martín Nieto e235db02 2014-11-08T20:09:11 remote: use git_branch_upstream_remote() This reduces the clutter somewhat and lets us see what we're asking about the reference.
Carlos Martín Nieto 209425ce 2014-11-08T13:25:51 remote: rename _load() to _lookup() This brings it in line with the rest of the lookup functions.
Edward Thomson f890a84f 2014-11-06T10:19:22 Merge pull request #2682 from libgit2/cmn/fetch-tags-refspec remote: check for the validity of the refspec when updating FETCH_HEAD
Edward Thomson cce27d82 2014-11-03T14:07:20 git_remote_rename: propogate GIT_ENOTFOUND
Carlos Martín Nieto 6d20006f 2014-11-02T20:11:54 remote: check the relevance of the refspec when updating FETCH_HEAD Before trying to rtransform using the given refspec to figure out what the name of the upstream branch is on the remote, we must make sure that the target of the refspec applies to the current branch's upstream.
Carlos Martín Nieto a68e217f 2014-11-02T21:57:14 remote: unify the creation code The create function with default refspec is the same as the one with a custom refspec, but it has the default refspec, so we can create the one on top of the other.
Pierre-Olivier Latour 64bcf567 2014-10-26T10:30:05 Fixed potential crash with uninitialized variables
Edward Thomson 5b0c6306 2014-10-26T22:38:30 Remove unused warning on non-win32
Edward Thomson cdd71711 2014-10-13T14:34:32 Clean up some memory leaks
Carlos Martín Nieto 46c8f7f8 2014-10-24T16:25:59 remote: accept a repo and name for renaming Remote objects are not meant to be changed from under the user. We did this in rename, but only the name and left the refspecs, such that a save would save the wrong refspecs (and a fetch and anything else would use the wrong refspecs). Instead, let's simply take a name and not change any loaded remote from under the user.
Edward Thomson 12f32d91 2014-10-14T16:31:55 Remote paths: canonicalize UNC paths on Win32 Git for Windows will handle UNC paths only when in forward-slash format, eg "//server/path". When given a UNC path as a remote, rewrite standard format ("\\server\path") into this ridiculous format.
Edward Thomson a6ed1fcb 2014-10-10T12:21:28 Merge pull request #2593 from libgit2/cmn/remote-delete-name remote: accept a repository and remote name for deletion
Carlos Martín Nieto 2139c9b7 2014-10-10T17:50:28 Merge pull request #2542 from linquize/fetch-head Do not error out when fetching from second remote
Arthur Schreiber 8e398e4c 2014-10-10T13:17:53 Treat an empty list of refspecs the same as a NULL value.
Carlos Martín Nieto eecc1772 2014-10-09T17:02:11 Fix an uninitialized variable
Carlos Martín Nieto 262eec23 2014-09-30T16:07:30 remote: accept a repository and remote name for deletion We don't need the remote loaded, and the function extracted both of these from the git_remote in order to do its work, so let's remote a step and not ask for the loaded remote at all. This fixes #2390.
Carlos Martín Nieto c5837cad 2014-07-04T09:03:33 remote: implement opportunistic remote-tracking branch updates When a list of refspecs is passed to fetch (what git would consider refspec passed on the command-line), we not only need to perform the updates described in that refspec, but also update the remote-tracking branch of the fetched remote heads according to the remote's configured refspecs. These "fetches" are not however to be written to FETCH_HEAD as they would be duplicate data, and it's not what the user asked for.
Carlos Martín Nieto 2cdd5c57 2014-07-03T07:56:31 remote: store passive refspecs The configured/base fetch refspecs need to be taken into account in order to implement opportunistic remote-tracking branch updates. DWIM them and store them in the struct, but don't do anything with them yet.
Carlos Martín Nieto c300d84a 2014-07-03T07:54:26 remote: don't DWIM refspecs unnecessarily We can only DWIM when we've connected to the remote and have the list of the remote's references. Adding or setting the refspecs should not trigger an attempt to DWIM the refspecs as we typically cannot do it, and even if we did, we would not use them for the current fetch.
Carlos Martín Nieto 3f894205 2014-06-06T15:01:45 remote: allow overriding the refspecs for download and fetch With opportunistic ref updates, git has introduced the concept of having base refspecs *and* refspecs that are active for a particular fetch. Let's start by letting the user override the refspecs for download.
Carlos Martín Nieto 0fef3899 2014-09-16T01:25:53 Merge remote-tracking branch 'upstream/master' into cmn/host-cert-info
Carlos Martín Nieto 41698f22 2014-09-11T10:04:05 net: remove support for outright ignoring certificates This option make it easy to ignore anything about the server we're connecting to, which is bad security practice. This was necessary as we didn't use to expose detailed information about the certificate, but now that we do, we should get rid of this. If the user wants to ignore everything, they can still provide a callback which ignores all the information passed.
Carlos Martín Nieto 9b940586 2014-07-04T12:45:43 Provide a callback for certificate validation If the certificate validation fails (or always in the case of ssh), let the user decide whether to allow the connection. The data structure passed to the user is the native certificate information from the underlying implementation, namely OpenSSL or WinHTTP.
Vicent Marti a7fcac13 2014-09-15T20:26:12 Merge pull request #2554 from linquize/fetch-head-tag When auto follow tags, FETCH_HEAD should list only newly followed tags
Linquize d908351a 2014-09-05T22:31:53 When auto follow tags, FETCH_HEAD should list only newly followed tags
Linquize f49819aa 2014-08-31T17:38:38 When updating FETCH_HEAD, do not treat it as error if the remote of current branch is from another remote
Carlos Martín Nieto 0cdaa376 2014-08-10T17:50:46 remote: short-circuit the default branch check if there is none If we do not have a HEAD ref in the heads, we already know there is no default branch. Return immedately.
Carlos Martín Nieto 38952604 2014-07-14T20:29:53 remote: restrict default branch to branches namespace
Jacques Germishuys dc8adda4 2014-08-15T22:51:19 git_remote_ls() should return an error if the transport is not available
Philip Kelley 1697cd6f 2014-06-25T13:20:27 Improvements to git_transport extensibility git_remote_set_transport now takes a transport factory rather than a transport git_clone_options now allows the caller to specify a remote creation callback
Carlos Martín Nieto 231f350d 2014-06-06T22:55:34 remote: don't free the remote on delete This was a bad idea. Don't free except in the free function.
Carlos Martín Nieto d1544564 2014-06-06T22:38:26 remote: handle symrefs when renaming A symref inside the namespace gets renamed, we should make it point to the target's new name. This is for the origin/HEAD -> origin/master type of situations.
Carlos Martín Nieto 72bca13e 2014-06-06T16:33:54 remote: return problem refspecs instead of using a callback There is no reason why we need to use a callback here. A string array fits better with the usage, as this is not an event and we don't need anything from the user.
Carlos Martín Nieto 61dcfe14 2014-06-06T15:57:37 remote: make sure the name stays valid on rename We must make sure that the name pointer remains valid, so make sure to allocate the new one before freeing the old one and swap them so the user never sees an invalid pointer.
Carlos Martín Nieto 5a49ff9f 2014-06-06T15:54:42 remote: remove rename code for anonymous remotes We don't allow renames of anonymous remotes, so there's no need to handle them. A remote is always associated with a repository, so there's no need to check for that.
Carlos Martín Nieto a52ab4b8 2014-06-06T01:09:49 remote: tighten up reference renaming Tighten up which references we consider for renaming so we don't try to rename unrelated ones and end up with unexplained references. If there is a reference on the target namespace, git overwrites it, so let's do the same.
Vicent Marti bccb36eb 2014-06-03T17:25:59 Merge pull request #2389 from arthurschreiber/arthur/set-error-when-no-remote-found Remote: Set an error when a remote cannot be found.
Carlos Martín Nieto 8a9419aa 2014-06-01T02:16:07 remote: build up the list of refs to remove When removing the remote-tracking branches, build up the list and remove in two steps, working around an issue with the iterator. Removing while we're iterating over the refs can cause us to miss references.
Arthur Schreiber d723dbed 2014-05-30T19:26:49 Remote: Set an error when a remote cannot be found. Inside `git_remote_load`, the calls to `get_optional_config` use `giterr_clear` to unset any errors that are set due to missing config keys. If neither a fetch nor a push url config was found for a remote, we should set an error again.
Carlos Martín Nieto d22db24f 2014-05-21T09:32:35 remote: add api to guess the remote's default branch If the remote supports the symref protocol extension, then we return that, otherwise we guess with git's rules.
Vicent Marti 228272ef 2014-05-16T11:56:37 Merge pull request #2313 from libgit2/cmn/remote-delete Remote deletion
Carlos Martín Nieto ec8a949a 2014-04-30T09:20:03 remote: remove remote-tracking branches on delete When we delete a remote, we also need to go through its fetch refspecs and remove the references they create locally.
Russell Belfer d2c4d1c6 2014-05-12T10:04:52 Merge pull request #2188 from libgit2/cmn/config-snapshot Configuration snapshotting
Carlos Martín Nieto ac99d86b 2014-05-07T11:34:32 repository: introduce a convenience config snapshot method Accessing the repository's config and immediately taking a snapshot of it is a common operation, so let's provide a convenience function for it.
Russell Belfer bc91347b 2014-04-30T11:16:31 Fix remaining init_options inconsistencies There were a couple of "init_opts()" functions a few more cases of structure initialization that I somehow missed.
Jacques Germishuys 183aa4f8 2014-04-30T17:46:53 Check for NULL before passing it to vsnprintf
Carlos Martín Nieto 5cdac19c 2014-04-30T08:29:14 remote: move branch upstream deletion to use an iterator This should make it more readable and allocate a bunch fewer strings.
nulltoken 40e48ea4 2013-11-15T15:36:37 remote: Introduce git_remote_delete()
Vicent Marti 8443ed6c 2014-04-25T02:10:19 Merge pull request #2284 from jacquesg/push-progress-callback Fire progress and update tips callbacks also for pushes.
Carlos Martín Nieto 2efd7df6 2014-04-19T15:34:12 remote: provide read access to the callback structure This should make it easier for bindings to dynamically override their own callbacks.
Jacques Germishuys 98020d3a 2014-04-21T10:55:37 Rename progress callback to sideband_progress
Carlos Martín Nieto 29c4cb09 2014-03-15T03:53:36 Use config snapshotting This way we can assume we have a consistent view of the config situation when we're looking up remote, branch, pack-objects, etc.
Vicent Marti 923c8400 2014-04-04T14:24:08 Merge pull request #2215 from libgit2/rb/submodule-cache-fixes Improve submodule cache management
Carlos Martín Nieto 67d4997a 2014-04-02T18:44:01 remote: mark branch for-merge even if we're unborn When the current branch is unborn, git will still mark the current branch's upstream for-merge if there is an upstream configuration. The only non-constrived case is cloning from an empty repository which then gains history. origin's master should be marked for-merge. In order to do this, we cannot use the high-level wrappers that expect a reference, as we may not have one. Move over to the internal ones that expect a reference name, which we do have.
Russell Belfer 8286300a 2013-12-18T11:48:57 Fix git_submodule_sync and add new config helper This fixes `git_submodule_sync` to correctly update the remote URL of the default branch of the submodule along with the URL in the parent repository config (i.e. match core Git's behavior). Also move some useful helper logic from the submodule code into a shared config API `git_config__update_entry` that can either set or delete an entry with constraints like not overwriting or not creating a new entry. I used that helper to update a couple other places in the code.
Carlos Martín Nieto fd536d29 2014-03-26T11:15:57 remote: rename inmemory to anonymous and swap url and fetch order The order in this function is the opposite to what create_with_fetchspec() has, so change this one, as url-then-refspec is what git does. As we need to break compilation and the swap doesn't do that, let's take this opportunity to rename in-memory remotes to anonymous as that's really what sets them apart.
Matthew Bowen b9f81997 2014-03-05T21:49:23 Added function-based initializers for every options struct. The basic structure of each function is courtesy of arrbee.
Brian Lambert 06a8f5c3 2014-03-05T00:00:41 Fixed missing error check on call to git_remote_download in git_remote_fetch. Moved error check to statement following git_remote_disconnect so that the disconnect happens regardless of the result of the download call.
Ben Straub db55bb73 2014-02-06T11:18:10 Correct default reflog message for git_remote_fetch
Ben Straub c3ab1e5a 2014-02-04T20:38:13 Add reflog parameters to remote apis Also added a test for git_remote_fetch.
Ben Straub ccf6ce5c 2014-01-28T11:30:36 Ensure renaming a reference updates the reflog
Carlos Martín Nieto bf522e08 2014-01-26T16:59:36 refspec: move to git_buf for outputting strings
Arthur Schreiber 991b2840 2014-01-26T19:35:02 Make sure git_remote_dup copies a remote's refspecs correctly.
Arthur Schreiber 11f6ad5f 2014-01-15T21:15:34 Add some missing const declarations.
Carlos Martín Nieto 0b28217b 2014-01-15T12:51:31 refs: remove the _with_log differentiation Any well-behaved program should write a descriptive message to the reflog whenever it updates a reference. Let's make this more prominent by removing the version without the reflog parameters.
Arthur Schreiber 99dcb218 2014-01-14T21:08:20 We don't need memset here.
Arthur Schreiber 616cd137 2014-01-14T21:08:09 Don't duplicate state that's only used when fetching.
Arthur Schreiber 40ef47dd 2014-01-14T21:03:01 Add `git_remote_dup`.
Russell Belfer 9cfce273 2013-12-12T12:11:38 Cleanups, renames, and leak fixes This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
Russell Belfer 26c1cb91 2013-12-09T09:44:03 One more rename/cleanup for callback err functions
Russell Belfer c7b3e1b3 2013-12-06T15:42:20 Some callback error check style cleanups I find this easier to read...
Russell Belfer 25e0b157 2013-12-06T15:07:57 Remove converting user error to GIT_EUSER 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.
Russell Belfer fcd324c6 2013-12-06T15:04:31 Add git_vector_free_all There are a lot of places that we call git__free on each item in a vector and then call git_vector_free on the vector itself. This just wraps that up into one convenient helper function.